Improve message spans in TypeCheck
#93 (closed)
FixesThis branch improves the messages from the TypeCheck by always using the span from the innermost expression in which the type error occurred.
Consider the example from the issue that now emits the following error message:
1:8-1:24 Error:
Type error in application
not (f True True)
Term: (f True True)
Inferred type: [Prelude.Char]
Expected type: Prelude.Bool
Types Prelude.Bool and [Prelude.Char] are incompatible
|
1 | test = not (f True True)
| ^^^^^^^^^^^^^^^^^
Nested expressions now also yield a better span:
test = 23 + (3 * True) / 4
1:14-1:21 Error:
Missing instance for Prelude.Num Prelude.Bool
in infix application
3 * True
Term: True
|
1 | test = 23 + (3 * True) / 4
| ^^^^^^^^