mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-17 16:38:14 +03:00
fix: Don't pass 'If' to InvalidObj when Obj actually is 'Mod' (#1327)
* fix: Don't pass 'If' to InvalidObj when Obj actually is 'Mod' * fix: Better error message * fix: Better error * fix: Show the name of the module in the error message * fix: Use `root` to get correct location for InvalidObj error * fix: keep old xobj for now
This commit is contained in:
parent
f4bcc28fc0
commit
643efd5ad6
@ -98,7 +98,7 @@ initialTypes typeEnv rootEnv root = evalState (visit rootEnv root) 0
|
||||
If -> pure (Left (InvalidObj If xobj))
|
||||
While -> pure (Left (InvalidObj While xobj))
|
||||
Do -> pure (Left (InvalidObj Do xobj))
|
||||
(Mod _ _) -> pure (Left (InvalidObj If xobj))
|
||||
m@(Mod _ _) -> pure (Left (InvalidObj m xobj))
|
||||
e@(Deftype _) -> pure (Left (InvalidObj e xobj))
|
||||
e@(External _) -> pure (Left (InvalidObj e xobj))
|
||||
e@(ExternalType _) -> pure (Left (InvalidObj e xobj))
|
||||
|
@ -103,6 +103,13 @@ instance Show TypeError where
|
||||
show (InvalidObj If xobj) =
|
||||
"I didn’t understand the `if` statement at " ++ prettyInfoFromXObj xobj
|
||||
++ ".\n\nIs it valid? Every `if` needs to follow the form `(if cond iftrue iffalse)`."
|
||||
show (InvalidObj (Mod env _) xobj) =
|
||||
let moduleName =
|
||||
case envModuleName env of
|
||||
Just name -> "the module '" ++ name ++ "'"
|
||||
Nothing -> "an unnamed module"
|
||||
in "I didn’t understand the form mentioning " ++ moduleName ++ " at " ++ prettyInfoFromXObj xobj
|
||||
++ ".\n\nAre you using a module or type where a value is expected?"
|
||||
show (InvalidObj o xobj) =
|
||||
"I didn’t understand the form `" ++ prettyObj o ++ "` at "
|
||||
++ prettyInfoFromXObj xobj
|
||||
|
Loading…
Reference in New Issue
Block a user