on master help sign in
New formatting for some error messages
commite9f70393c5b7479918e9420c191f60fe61e84bb8 authorJason Felice <jason.m.felice@gmail.com> dateTue 31 Oct 2017, 16:20 (9 years ago) parent2e33b4b
3 files changed+89−83
src/Idris/Parser/Helpers.hs+10−3 test/layout001/expected+67−70 test/regression002/expected+12−10
src/Idris/Parser/Helpers.hs+10−3
@@ -46,10 +46,13 @@ import qualified Text.Megaparsec.Char.Lexer as P hiding (space)
4646type IdrisParser = StateT IState IdrisInnerParser
4747type IdrisInnerParser = P.Parsec Void String
4848type ParseState = P.State String
49−type ParseError = P.ParseError (P.Token String) Void
49+data ParseError = ParseError String (P.ParseError (P.Token String) Void)
50+
51+parseErrorPretty :: ParseError -> String
52+parseErrorPretty (ParseError s err) = P.parseErrorPretty' s err
5053
5154parseErrorDoc :: ParseError -> PP.Doc
52−parseErrorDoc = PP.string . P.parseErrorPretty
55+parseErrorDoc = PP.string . parseErrorPretty
5356
5457-- | Generalized monadic parsing constraint type
5558type MonadicParsing m = (P.MonadParsec Void String m, Tok.TokenParsing m)
@@ -82,7 +85,11 @@ instance {-# OVERLAPPING #-} Tok.TokenParsing IdrisParser where
8285
8386-- | Helper to run Idris inner parser based stateT parsers
8487runparser :: StateT st IdrisInnerParser res -> st -> String -> String -> Either ParseError res
85−runparser p i inputname s = P.parse (evalStateT p i) inputname s
88+runparser p i inputname s =
89+ case P.parse (evalStateT p i) inputname s of
90+ Left err -> Left $ ParseError s err
91+ Right v -> Right v
92+
8693
8794highlightP :: FC -> OutputAnnotation -> IdrisParser ()
8895highlightP fc annot = do ist <- get
test/layout001/expected+67−70
@@ -1,76 +1,73 @@
1−./layout001a.idr:5:1: error: Wrong
2− indention: should be greater
3− than context
4− indentation, expected: space
5−y
6−^
7−./layout001b.idr:5:3: error: Wrong
8− indention: should be greater
9− than context
10− indentation, expected: space
11−= y
12− ^
13−./layout001c.idr:3:1: error: Wrong
14− indention: should be greater
15− than context
16− indentation, expected: space
17−2
18−^
19−./layout001e.idr:6:1: error: Wrong
20− indention: should be greater
21− than context
22− indentation, expected: space
23−3
24−^
25−./layout001f.idr:6:2: error: Wrong
26− indention: should be greater
27− than context
28− indentation, expected: space
29− 3
30− ^
31−./layout001g.idr:6:3: error: Wrong
32− indention: should be greater
33− than context
34− indentation, expected: space
35− 3
36− ^
37−./layout001h.idr:6:3: error: Wrong
38− indention: should be greater
39− than context
40− indentation, expected: space
41− 3
42− ^
43−./layout001i.idr:6:4: error: Wrong
44− indention: should be greater
45− than context
46− indentation, expected: space
47− 3
48− ^
49−./layout001j.idr:6:5: error: Wrong
50− indention: should be greater
51− than context
52− indentation, expected: space
53− 3
54− ^
55−./layout001l.idr:6:1: error: Wrong
56− indention: should be greater
57− than context
58− indentation, expected: space
59−y
60−^
1+./layout001a.idr:5:1:
2+ |
3+5 | y
4+ | ^
5+Wrong indention: should be greater than context indentation
6+
7+./layout001b.idr:5:3:
8+ |
9+5 | = y
10+ | ^
11+Wrong indention: should be greater than context indentation
12+
13+./layout001c.idr:3:1:
14+ |
15+3 | 2
16+ | ^
17+= is not a valid operator
18+Wrong indention: should be greater than context indentation
19+
20+./layout001e.idr:6:1:
21+ |
22+6 | 3
23+ | ^
24+Wrong indention: should be greater than context indentation
25+
26+./layout001f.idr:6:2:
27+ |
28+6 | 3
29+ | ^
30+Wrong indention: should be greater than context indentation
31+
32+./layout001g.idr:6:3:
33+ |
34+6 | 3
35+ | ^
36+Wrong indention: should be greater than context indentation
37+
38+./layout001h.idr:6:3:
39+ |
40+6 | 3
41+ | ^
42+Wrong indention: should be greater than context indentation
43+
44+./layout001i.idr:6:4:
45+ |
46+6 | 3
47+ | ^
48+Wrong indention: should be greater than context indentation
49+
50+./layout001j.idr:6:5:
51+ |
52+6 | 3
53+ | ^
54+Wrong indention: should be greater than context indentation
55+
56+./layout001l.idr:6:1:
57+ |
58+6 | y
59+ | ^
60+Wrong indention: should be greater than context indentation
61+
6162mplus1.idr:13:31:When checking right hand side of term with expected type
6263 Maybe Int
6364
6465When checking an application of function Prelude.Applicative.pure:
6566 No such variable f
66−./mplus2.idr:17:37: error: not
67− end of block, expected: ")",
68− "->", ";", "in",
69− ambiguous use of a left-associative operator,
70− ambiguous use of a non-associative operator,
71− ambiguous use of a right-associative operator,
72− do block expression,
73− end of input
74− `mplus` pure f
75− ^
67+./mplus2.idr:17:37:
68+ |
69+17 | `mplus` pure f
70+ | ^
71+not end of block
72+
7673mplus3.idr:11:1:warning - Unreachable case: term
test/regression002/expected+12−10
@@ -72,16 +72,18 @@ reg049.idr:5:6:When checking right hand side of uhOh with expected type
7272 Void
7373
7474No such variable Bogus
75−./badbangop.idr:7:1: error: ! is
76− not a valid
77− operator, expected: space
78−(!) : List a -> Nat -> Maybe a
79−^
80−./baddoublebang.idr:6:28: error: unexpected
81− Operator without known fixity:
82− !!, expected: space
83−doubleBang mmn = do pure !!mmn
84− ^
75+./badbangop.idr:7:1:
76+ |
77+7 | (!) : List a -> Nat -> Maybe a
78+ | ^
79+! is not a valid operator
80+
81+./baddoublebang.idr:6:28:
82+ |
83+6 | doubleBang mmn = do pure !!mmn
84+ | ^
85+unexpected Operator without known fixity: !!
86+
8587reg054.idr:18:5:When checking left hand side of inf:
8688When checking an application of constructor Main.MkInfer:
8789 Attempting concrete match on polymorphic argument: 0