lang: ast, gapi, interfaces, parser: Print line numbers on error
This adds an initial implementation of printing line numbers on type unification errors. It also attempts to print a visual position indicator for most scenarios. This patch was started by Felix Frank and finished by James Shubin. Co-authored-by: Felix Frank <Felix.Frank.de@gmail.com>
This commit is contained in:
@@ -12,4 +12,4 @@ class c1($a, $b []str) {
|
||||
}
|
||||
}
|
||||
-- OUTPUT --
|
||||
# err: errUnify: unify error with: str("hello"): type error: list != str
|
||||
# err: errUnify: type error: list != str: /main.mcl @ 4:1-4:25
|
||||
|
||||
@@ -15,4 +15,4 @@ test ["x",] {
|
||||
float32 => $b,
|
||||
}
|
||||
-- OUTPUT --
|
||||
# err: errUnify: unify error with: topLevel(func() { <built-in:_operator> }): type error: int != float
|
||||
# err: errUnify: type error: int != float: /main.mcl @ 10:6-10:22
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
import "fmt"
|
||||
test fmt.printf("%d%d", 42) {} # should not pass, missing second int
|
||||
-- OUTPUT --
|
||||
# err: errUnify: unify error with: call:fmt.printf(str("%d%d"), int(42)): type error: str != list
|
||||
# err: errUnify: type error: str != list: /main.mcl @ 2:1-2:30
|
||||
|
||||
@@ -3,4 +3,4 @@ test "t1" {
|
||||
stringptr => 42, # int, not str
|
||||
}
|
||||
-- OUTPUT --
|
||||
# err: errUnify: unify error with: int(42): type error: str != int
|
||||
# err: errUnify: type error: str != int: /main.mcl @ 2:2-2:17
|
||||
|
||||
@@ -7,4 +7,4 @@ test "test" {}
|
||||
Test["${name}"] -> Test["test"] # must fail
|
||||
|
||||
-- OUTPUT --
|
||||
# err: errUnify: unify error with: var(name): type error: str != list
|
||||
# err: errUnify: type error: str != list: /main.mcl @ 6:1-6:15
|
||||
|
||||
@@ -7,4 +7,4 @@ test "test" {}
|
||||
Test["test"] -> Test["${name}"] # must fail
|
||||
|
||||
-- OUTPUT --
|
||||
# err: errUnify: unify error with: var(name): type error: str != list
|
||||
# err: errUnify: type error: str != list: /main.mcl @ 6:17-6:31
|
||||
|
||||
@@ -5,4 +5,4 @@ $name = ["a", "bb", "ccc",]
|
||||
test "${name}" {} # must fail
|
||||
|
||||
-- OUTPUT --
|
||||
# err: errUnify: unify error with: var(name): type error: str != list
|
||||
# err: errUnify: type error: str != list: /main.mcl @ 4:1-4:17
|
||||
|
||||
Reference in New Issue
Block a user