on master help sign in
New formatting for some error messages
e9f7039Jason Felice
src/Idris/Parser/Helpers.hs+10−3
@@ -46,10 +46,13 @@ import qualified Text.Megaparsec.Char.Lexer as P hiding (space)
46type IdrisParser = StateT IState IdrisInnerParser
46type IdrisParser = StateT IState IdrisInnerParser
47type IdrisInnerParser = P.Parsec Void String
47type IdrisInnerParser = P.Parsec Void String
48type ParseState = P.State String
48type 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
50
53
51parseErrorDoc :: ParseError -> PP.Doc
54parseErrorDoc :: ParseError -> PP.Doc
52−parseErrorDoc = PP.string . P.parseErrorPretty
55+parseErrorDoc = PP.string . parseErrorPretty
53
56
54-- | Generalized monadic parsing constraint type
57-- | Generalized monadic parsing constraint type
55type MonadicParsing m = (P.MonadParsec Void String m, Tok.TokenParsing m)
58type MonadicParsing m = (P.MonadParsec Void String m, Tok.TokenParsing m)
@@ -82,7 +85,11 @@ instance {-# OVERLAPPING #-} Tok.TokenParsing IdrisParser where
82
85
83-- | Helper to run Idris inner parser based stateT parsers
86-- | Helper to run Idris inner parser based stateT parsers
84runparser :: StateT st IdrisInnerParser res -> st -> String -> String -> Either ParseError res
87runparser :: StateT st IdrisInnerParser res -> st -> String -> String -> Either ParseError res
88+runparser p i inputname s =
85−runparser p i inputname s = P.parse (evalStateT 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+
86
93
87highlightP :: FC -> OutputAnnotation -> IdrisParser ()
94highlightP :: FC -> OutputAnnotation -> IdrisParser ()
88highlightP fc annot = do ist <- get
95highlightP fc annot = do ist <- get
test/layout001/expected+67−70
@@ -1,76 +1,73 @@
1−./layout001a.idr:5:1: error: Wrong
1+./layout001a.idr:5:1:
2+ |
3+5 | y
4+ | ^
2− indention: should be greater
5+Wrong indention: should be greater than context indentation
3− than context
6+
4− indentation, expected: space
5−y
6−^
7−./layout001b.idr:5:3: error: Wrong
7+./layout001b.idr:5:3:
8+ |
9+5 | = y
10+ | ^
8− indention: should be greater
11+Wrong indention: should be greater than context indentation
9− than context
12+
10− indentation, expected: space
11−= y
12− ^
13−./layout001c.idr:3:1: error: Wrong
13+./layout001c.idr:3:1:
14+ |
15+3 | 2
16+ | ^
17+= is not a valid operator
14− indention: should be greater
18+Wrong indention: should be greater than context indentation
15− than context
19+
16− indentation, expected: space
17−2
18−^
19−./layout001e.idr:6:1: error: Wrong
20+./layout001e.idr:6:1:
21+ |
22+6 | 3
23+ | ^
20− indention: should be greater
24+Wrong indention: should be greater than context indentation
21− than context
25+
22− indentation, expected: space
23−3
24−^
25−./layout001f.idr:6:2: error: Wrong
26+./layout001f.idr:6:2:
27+ |
28+6 | 3
29+ | ^
26− indention: should be greater
30+Wrong indention: should be greater than context indentation
27− than context
31+
28− indentation, expected: space
29− 3
30− ^
31−./layout001g.idr:6:3: error: Wrong
32+./layout001g.idr:6:3:
33+ |
34+6 | 3
35+ | ^
32− indention: should be greater
36+Wrong indention: should be greater than context indentation
33− than context
37+
34− indentation, expected: space
35− 3
36− ^
37−./layout001h.idr:6:3: error: Wrong
38+./layout001h.idr:6:3:
39+ |
40+6 | 3
41+ | ^
38− indention: should be greater
42+Wrong indention: should be greater than context indentation
39− than context
43+
40− indentation, expected: space
41− 3
42− ^
43−./layout001i.idr:6:4: error: Wrong
44+./layout001i.idr:6:4:
45+ |
46+6 | 3
47+ | ^
44− indention: should be greater
48+Wrong indention: should be greater than context indentation
45− than context
49+
46− indentation, expected: space
47− 3
48− ^
49−./layout001j.idr:6:5: error: Wrong
50+./layout001j.idr:6:5:
51+ |
52+6 | 3
53+ | ^
50− indention: should be greater
54+Wrong indention: should be greater than context indentation
51− than context
55+
52− indentation, expected: space
53− 3
54− ^
55−./layout001l.idr:6:1: error: Wrong
56+./layout001l.idr:6:1:
57+ |
58+6 | y
59+ | ^
56− indention: should be greater
60+Wrong indention: should be greater than context indentation
57− than context
61+
58− indentation, expected: space
59−y
60−^
61mplus1.idr:13:31:When checking right hand side of term with expected type
62mplus1.idr:13:31:When checking right hand side of term with expected type
62 Maybe Int
63 Maybe Int
63
64
64When checking an application of function Prelude.Applicative.pure:
65When checking an application of function Prelude.Applicative.pure:
65 No such variable f
66 No such variable f
66−./mplus2.idr:17:37: error: not
67+./mplus2.idr:17:37:
67− end of block, expected: ")",
68+ |
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
69+17 | `mplus` pure f
75− ^
70+ | ^
71+not end of block
72+
76mplus3.idr:11:1:warning - Unreachable case: term
73mplus3.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
72 Void
72 Void
73
73
74No such variable Bogus
74No such variable Bogus
75−./badbangop.idr:7:1: error: ! is
75+./badbangop.idr:7:1:
76− not a valid
76+ |
77− operator, expected: space
78−(!) : List a -> Nat -> Maybe a
77+7 | (!) : List a -> Nat -> Maybe a
79−^
78+ | ^
79+! is not a valid operator
80+
80−./baddoublebang.idr:6:28: error: unexpected
81+./baddoublebang.idr:6:28:
82+ |
83+6 | doubleBang mmn = do pure !!mmn
84+ | ^
81− Operator without known fixity:
85+unexpected Operator without known fixity: !!
82− !!, expected: space
86+
83−doubleBang mmn = do pure !!mmn
84− ^
85reg054.idr:18:5:When checking left hand side of inf:
87reg054.idr:18:5:When checking left hand side of inf:
86When checking an application of constructor Main.MkInfer:
88When checking an application of constructor Main.MkInfer:
87 Attempting concrete match on polymorphic argument: 0
89 Attempting concrete match on polymorphic argument: 0