Skip to content

Commit

Permalink
Add end FC to error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
croyzor committed Oct 24, 2024
1 parent f244c75 commit a30672c
Show file tree
Hide file tree
Showing 70 changed files with 74 additions and 75 deletions.
7 changes: 6 additions & 1 deletion brat/Brat/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,13 @@ addSrcContext _ _ (Right r) = Right r
addSrcContext fname cts (Left err@Err{fc=fc}) = Left (SrcErr msg err)
where
msg = case fc of
Just fc -> unlines (errHeader (fname ++ '@':show (start fc)):showFileContext cts fc)
Just fc -> unlines (errHeader (fname ++ '@':prettyLoc fc):showFileContext cts fc)
Nothing -> errHeader fname
prettyLoc fc = let Pos startLine startCol = start fc
Pos endLine endCol = end fc
in if startLine == endLine
then show startLine ++ ":" ++ show startCol ++ "-" ++ show endCol
else show (start fc) ++ "-" ++ show (end fc)

showFileContext :: String -> FC -> [String]
showFileContext contents fc = let
Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/binding/cons.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/binding/cons.brat@7:10
Error in test/golden/binding/cons.brat@7:10-23
badUncons(cons(stuff)) = stuff
^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/binding/let.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/binding/let.brat@7:14
Error in test/golden/binding/let.brat@7:14-36
badBinding = let x = twoThings in x
^^^^^^^^^^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/apply_two_thunks.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/apply_two_thunks.brat@9:9
Error in test/golden/error/apply_two_thunks.brat@9:9-18
go(n) = thunks(n)
^^^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/arith_implicit_conversion.brat@2:20
Error in test/golden/error/arith_implicit_conversion.brat@2:20-21
f(x, y) = x + (x * y)
^

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/arith_implicit_conversion2.brat@2:16
Error in test/golden/error/arith_implicit_conversion2.brat@2:16-17
f(x, y) = x + (y - x)
^

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/arith_implicit_conversion3.brat@2:11
Error in test/golden/error/arith_implicit_conversion3.brat@2:11-12
f(x, y) = y + x
^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/bad_rpat.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/bad_rpat.brat@2:8
Error in test/golden/error/bad_rpat.brat@2:8-19
test = cons(1, [])
^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/bad_underscore.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/bad_underscore.brat@2:12
Error in test/golden/error/bad_underscore.brat@2:12-18
uscore = { i => _ }
^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/bad_underscore2.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/bad_underscore2.brat@2:13
Error in test/golden/error/bad_underscore2.brat@2:13-14
uscore(i) = _
^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/badvec.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/badvec.brat@2:6
Error in test/golden/error/badvec.brat@2:6-9
v3 = [1]
^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/badvec2.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/badvec2.brat@2:6
Error in test/golden/error/badvec2.brat@2:6-9
v3 = nil
^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/badvec3.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/badvec3.brat@2:6
Error in test/golden/error/badvec3.brat@2:6-18
v3 = cons(1, nil)
^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/badvec4.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/badvec4.brat@2:6
Error in test/golden/error/badvec4.brat@2:6-11
v3 = [1,2]
^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/empty_into.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/empty_into.brat@5:11
Error in test/golden/error/empty_into.brat@5:11-21
intoErr = |> makeInt
^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/fanin-diff-types.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/fanin-diff-types.brat@2:5
Error in test/golden/error/fanin-diff-types.brat@2:5-13
f = { [\/] }
^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/fanin-dynamic-length.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/fanin-dynamic-length.brat@2:8
Error in test/golden/error/fanin-dynamic-length.brat@2:8-16
f(n) = { [\/] }
^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/fanin-list.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/fanin-list.brat@2:5
Error in test/golden/error/fanin-list.brat@2:5-13
f = { [\/] }
^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/fanin-not-enough-overs.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/fanin-not-enough-overs.brat@2:5
Error in test/golden/error/fanin-not-enough-overs.brat@2:5-13
f = { [\/] }
^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/fanin-too-many-overs.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/fanin-too-many-overs.brat@2:5
Error in test/golden/error/fanin-too-many-overs.brat@2:5-13
f = { [\/] }
^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/fanout-diff-types.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/fanout-diff-types.brat@2:5
Error in test/golden/error/fanout-diff-types.brat@2:5-13
f = { [/\] }
^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/fanout-dynamic-length.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/fanout-dynamic-length.brat@2:8
Error in test/golden/error/fanout-dynamic-length.brat@2:8-16
f(n) = { [/\] }
^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/fanout-list.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/fanout-list.brat@2:5
Error in test/golden/error/fanout-list.brat@2:5-13
f = { [/\] }
^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/fanout-not-enough-overs.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/fanout-not-enough-overs.brat@2:5
Error in test/golden/error/fanout-not-enough-overs.brat@2:5-13
f = { [/\] }
^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/fanout-too-many-overs.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/fanout-too-many-overs.brat@2:5
Error in test/golden/error/fanout-too-many-overs.brat@2:5-13
f = { [/\] }
^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/inconsistentclauses.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/inconsistentclauses.brat@1:1
Error in test/golden/error/inconsistentclauses.brat@1:1-3:9
f(Bool, Nat) -> Nat
^^^^^^^^^^^^^^^^^^^
f(true, n) = 1
Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/kbadvec.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/kbadvec.brat@2:17
Error in test/golden/error/kbadvec.brat@2:17-20
triple = { b => [b] }
^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/kbadvec2.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/kbadvec2.brat@2:17
Error in test/golden/error/kbadvec2.brat@2:17-20
triple = { b => nil }
^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/kbadvec3.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/kbadvec3.brat@2:19
Error in test/golden/error/kbadvec3.brat@2:19-31
constNil = { b => cons(1, nil) }
^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/kbadvec4.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/kbadvec4.brat@2:7
Error in test/golden/error/kbadvec4.brat@2:7-12
f = { [1,2] => true }
^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/kvarnotfound.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/kvarnotfound.brat@2:12
Error in test/golden/error/kvarnotfound.brat@2:12-13
f = { x => y }
^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/multilambda-id.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/multilambda-id.brat@2:15
Error in test/golden/error/multilambda-id.brat@2:15-16
f = { true => |
^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/multilambda-id2.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/multilambda-id2.brat@2:12
Error in test/golden/error/multilambda-id2.brat@2:12-13
g = { 0 => ||succ(n) => | }
^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/multilambda-id3.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/multilambda-id3.brat@2:15
Error in test/golden/error/multilambda-id3.brat@2:15-18
f = { true => |;||false =>|;|;|}
^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/nameclash1.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/nameclash1.brat@1:1
Error in test/golden/error/nameclash1.brat@1:1-16
type Nat(x) = x
^^^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/nameclash2.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/nameclash2.brat@2:1
Error in test/golden/error/nameclash2.brat@2:1-16
type A(x,y) = y
^^^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/no_thunk.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/no_thunk.brat@8:14
Error in test/golden/error/no_thunk.brat@8:14-15
Rz(2.0 / n); X
^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/noovers.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/noovers.brat@2:2
Error in test/golden/error/noovers.brat@2:2-8
f(a, b) = []
^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/pair.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/pair.brat@5:8
Error in test/golden/error/pair.brat@5:8-11
pair = row -- Distinct from a pair
^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/pass.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/pass.brat@5:12
Error in test/golden/error/pass.brat@5:12-13
f = { .., (x => x) }
^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/pass_empty.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/pass_empty.brat@2:17
Error in test/golden/error/pass_empty.brat@2:17-19
f = { (x => x), .. }
^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/portpull-ambiguous.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/portpull-ambiguous.brat@6:22
Error in test/golden/error/portpull-ambiguous.brat@6:22-31
id2 = x, y => (id,id)(a1:x, y)
^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/portpull.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/portpull.brat@6:22
Error in test/golden/error/portpull.brat@6:22-31
id2 = x,y => (id, id)(a1:x, y)
^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/simpleterm.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/simpleterm.brat@2:10
Error in test/golden/error/simpleterm.brat@2:10-14
simple = true
^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/type-arith.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/type-arith.brat@1:20
Error in test/golden/error/type-arith.brat@1:20-25
f(n :: #, Vec(Nat, n ^ 3)) -> Bool
^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/type-arith2.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/type-arith2.brat@1:20
Error in test/golden/error/type-arith2.brat@1:20-25
f(n :: #, Vec(Nat, n * n)) -> Bool
^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/unmatched_bracket.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/unmatched_bracket.brat@1:17
Error in test/golden/error/unmatched_bracket.brat@1:17-19
f(n, Vec([], n) -> Vec([], n) -- First bracket never closed
^^

Expand Down
6 changes: 0 additions & 6 deletions brat/test/golden/error/unreachablebranch.brat.golden
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
Error in test/golden/error/unreachablebranch.brat@FC {start = Pos {line = 3, col = 2}, end = Pos {line = 3, col = 10}}:
f(0) = []
^^^^^^^^

Branch cannot be reached

2 changes: 1 addition & 1 deletion brat/test/golden/error/varnotfound.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/varnotfound.brat@2:8
Error in test/golden/error/varnotfound.brat@2:8-9
f(x) = g(x)
^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/vecpat.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/vecpat.brat@3:5
Error in test/golden/error/vecpat.brat@3:5-10
fst3(nil) = none
^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/vecpat2.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/vecpat2.brat@3:5
Error in test/golden/error/vecpat2.brat@3:5-14
fst3(some(x)) = none
^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/error/vecpat3.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/error/vecpat3.brat@3:5
Error in test/golden/error/vecpat3.brat@3:5-12
fst3([a,b]) = none
^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/imports/alias-clash.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in alias-clash@2:15
Error in alias-clash@2:15-16
import lib as A (z)
^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/imports/non-existent1.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in non-existent1@1:16
Error in non-existent1@1:16-17
import lib (x, a)
^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/imports/non-existent2.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in non-existent2@1:23
Error in non-existent2@1:23-24
import lib hiding (y, a)
^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/imports/use-illegal-z.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/imports/use-illegal-z.brat@4:14
Error in test/golden/imports/use-illegal-z.brat@4:14-15
main = x, y, z
^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/imports/use-illegal-z2.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/imports/use-illegal-z2.brat@4:22
Error in test/golden/imports/use-illegal-z2.brat@4:22-27
main = lib.x, lib.y, lib.z
^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/imports/use-illegal-z3.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/imports/use-illegal-z3.brat@4:14
Error in test/golden/imports/use-illegal-z3.brat@4:14-15
main = x, y, z
^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/imports/use-illegal-z4.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/imports/use-illegal-z4.brat@4:22
Error in test/golden/imports/use-illegal-z4.brat@4:22-27
main = lib.x, lib.y, lib.z
^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/imports/use-unqualified.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/imports/use-unqualified.brat@4:8
Error in test/golden/imports/use-unqualified.brat@4:8-9
main = x
^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/imports/use-without-rename.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/imports/use-without-rename.brat@4:8
Error in test/golden/imports/use-without-rename.brat@4:8-13
main = lib.x
^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/kernel/classical_return.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/kernel/classical_return.brat@5:1
Error in test/golden/kernel/classical_return.brat@5:1-6:18
-- `Bool`. We could probably catch this and make the error message nicer.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
f :: { Qubit -o Qubit, Int }
Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/kernel/copy.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/kernel/copy.brat@2:8
Error in test/golden/kernel/copy.brat@2:8-21
copy = { q => q, q }
^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/kernel/delete.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/kernel/delete.brat@2:13
Error in test/golden/kernel/delete.brat@2:13-29
deleteFst = { q0, q1 => q1 }
^^^^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion brat/test/golden/kernel/deleteFst.brat.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error in test/golden/kernel/deleteFst.brat@2:13
Error in test/golden/kernel/deleteFst.brat@2:13-29
deleteFst = { q0, q1 => q1 }
^^^^^^^^^^^^^^^^

Expand Down
Loading

0 comments on commit a30672c

Please sign in to comment.