Idris2 icon indicating copy to clipboard operation
Idris2 copied to clipboard

"Error: Error:" Redundancy in Compiler Error Reporting

Open magnostherobot opened this issue 2 years ago • 0 comments

Some compiler errors seem to have "Error" printed twice before the error description when used in custom backends.

Steps to Reproduce

  1. Create the following file:
import Compiler.Common
import Idris.Syntax
import Core.Context
import Idris.Driver

compile : Ref Ctxt Defs -> Ref Syn SyntaxInfo -> String -> String ->
          ClosedTerm -> String -> Core (Maybe String)
compile _ _ _ _ _ _ = coreFail (UserError "user error when compiling")

execute : Ref Ctxt Defs -> Ref Syn SyntaxInfo -> String -> ClosedTerm -> Core ()
execute _ _ _ _ = coreFail (UserError "user error when executing")

failingCompiler : Codegen
failingCompiler = MkCG compile execute Nothing Nothing

main : IO ()
main = mainWithCodegens [("failure", failingCompiler)]
  1. Compile it with idris2 -p idris2 -p network file.idr -o out
  2. Open the new REPL by running ./build/exec/out
  3. Try :exec-ing something, such as :exec printLn "something"

Expected Behavior

The REPL should output something like Error: user error when executing.

Observed Behavior

Main> :exec printLn "something"
Error: Error: user error when executing

The first Error is red, the second is not.

Extra Information

When running this file (compiled with idris2 -p idris2 file.idr -o out):

import Core.Context

core : Core ()
core = coreFail (UserError "user error")

main : IO ()
main = coreRun core printLn pure

The output only includes one (non-red) Error:

Error: user error

magnostherobot avatar Aug 07 '22 17:08 magnostherobot