on master help sign in
Use iWarn for parse errors
fb4c5e4Jason Felice
src/Idris/Output.hs+1−1
@@ -90,7 +90,7 @@ iWarn fc err =
90 else Nothing
90 else Nothing
91 where
91 where
92 sourceLine :: Maybe String
92 sourceLine :: Maybe String
93− sourceLine = listToMaybe . drop (si - 1) . lines $ src
93+ sourceLine = listToMaybe . drop (si - 1) . (++ ["<end of file>"]) . lines $ src
94
94
95 haveSource :: Bool
95 haveSource :: Bool
96 haveSource = isJust sourceLine
96 haveSource = isJust sourceLine
src/Idris/Parser.hs+1−3
@@ -1519,10 +1519,8 @@ parseProg syn fname input mrk
1519 = do i <- getIState
1519 = do i <- getIState
1520 case runparser mainProg i fname input of
1520 case runparser mainProg i fname input of
1521 Left err -> do let fc = errorExtent err
1521 Left err -> do let fc = errorExtent err
1522+ iWarn fc (Util.Pretty.string $ errorMessage err)
1522 i <- getIState
1523 i <- getIState
1523− case idris_outputmode i of
1524− RawOutput h -> iputStrLn (show . fixColour (idris_colourRepl i) . parseErrorDoc $ err)
1525− IdeMode n h -> iWarn fc (Util.Pretty.text $ errorMessage err)
1526 putIState (i { errSpan = Just fc })
1524 putIState (i { errSpan = Just fc })
1527 return []
1525 return []
1528 Right (x, i) -> do putIState i
1526 Right (x, i) -> do putIState i
src/Idris/Parser/Stack.hs+1−1
@@ -72,7 +72,7 @@ errorExtent (ParseError _ err) = sourcePositionFC pos
72
72
73-- | A single-line parse error message, including location.
73-- | A single-line parse error message, including location.
74errorMessage :: ParseError -> String
74errorMessage :: ParseError -> String
75−errorMessage (ParseError _ err) = P.parseErrorTextPretty err
75+errorMessage (ParseError _ err) = init (P.parseErrorTextPretty err)
76
76
77-- | A fully formatted parse error, with caret and bar, etc.
77-- | A fully formatted parse error, with caret and bar, etc.
78prettyError :: ParseError -> String
78prettyError :: ParseError -> String
test/layout001/expected+11−11
@@ -1,58 +1,58 @@
1−./layout001a.idr:5:1:
1+layout001a.idr:5:1:
2 |
2 |
35 | y
35 | y
4 | ^
4 | ^
5Wrong indention: should be greater than context indentation
5Wrong indention: should be greater than context indentation
6
6
7−./layout001b.idr:5:3:
7+layout001b.idr:5:3:
8 |
8 |
95 | = y
95 | = y
10 | ^
10 | ^
11Wrong indention: should be greater than context indentation
11Wrong indention: should be greater than context indentation
12
12
13−./layout001c.idr:3:1:
13+layout001c.idr:3:1:
14 |
14 |
153 | 2
153 | 2
16 | ^
16 | ^
17Wrong indention: should be greater than context indentation
17Wrong indention: should be greater than context indentation
18
18
19−./layout001e.idr:6:1:
19+layout001e.idr:6:1:
20 |
20 |
216 | 3
216 | 3
22 | ^
22 | ^
23Wrong indention: should be greater than context indentation
23Wrong indention: should be greater than context indentation
24
24
25−./layout001f.idr:6:2:
25+layout001f.idr:6:2:
26 |
26 |
276 | 3
276 | 3
28 | ^
28 | ^
29Wrong indention: should be greater than context indentation
29Wrong indention: should be greater than context indentation
30
30
31−./layout001g.idr:6:3:
31+layout001g.idr:6:3:
32 |
32 |
336 | 3
336 | 3
34 | ^
34 | ^
35Wrong indention: should be greater than context indentation
35Wrong indention: should be greater than context indentation
36
36
37−./layout001h.idr:6:3:
37+layout001h.idr:6:3:
38 |
38 |
396 | 3
396 | 3
40 | ^
40 | ^
41Wrong indention: should be greater than context indentation
41Wrong indention: should be greater than context indentation
42
42
43−./layout001i.idr:6:4:
43+layout001i.idr:6:4:
44 |
44 |
456 | 3
456 | 3
46 | ^
46 | ^
47Wrong indention: should be greater than context indentation
47Wrong indention: should be greater than context indentation
48
48
49−./layout001j.idr:6:5:
49+layout001j.idr:6:5:
50 |
50 |
516 | 3
516 | 3
52 | ^
52 | ^
53Wrong indention: should be greater than context indentation
53Wrong indention: should be greater than context indentation
54
54
55−./layout001l.idr:6:1:
55+layout001l.idr:6:1:
56 |
56 |
576 | y
576 | y
58 | ^
58 | ^
@@ -68,7 +68,7 @@ When checking right hand side of term with expected type
68When checking an application of function Prelude.Applicative.pure:
68When checking an application of function Prelude.Applicative.pure:
69 No such variable f
69 No such variable f
70
70
71−./mplus2.idr:17:37:
71+mplus2.idr:17:37:
72 |
72 |
7317 | `mplus` pure f
7317 | `mplus` pure f
74 | ^
74 | ^
test/regression002/expected+6−6
@@ -182,13 +182,13 @@ When checking right hand side of uhOh with expected type
182
182
183No such variable Bogus
183No such variable Bogus
184
184
185−./badbangop.idr:7:1:
185+badbangop.idr:7:1:
186 |
186 |
1877 | (!) : List a -> Nat -> Maybe a
1877 | (!) : List a -> Nat -> Maybe a
188 | ^
188 | ^
189! is not a valid operator
189! is not a valid operator
190
190
191−./baddoublebang.idr:6:28:
191+baddoublebang.idr:6:28:
192 |
192 |
1936 | doubleBang mmn = do pure !!mmn
1936 | doubleBang mmn = do pure !!mmn
194 | ^
194 | ^
@@ -308,15 +308,15 @@ reg070.idr:7:1-7:
308 | ~~~~~~~
308 | ~~~~~~~
309Test_show.Te implementation of Prelude.Show.Show is possibly not total due to: Prelude.Show.Test_show.Te implementation of Prelude.Show.Show, method show
309Test_show.Te implementation of Prelude.Show.Show is possibly not total due to: Prelude.Show.Test_show.Te implementation of Prelude.Show.Show, method show
310
310
311−./reg076.idr:8:1:
311+reg076.idr:8:1:
312 |
312 |
313−8 | <empty line>
313+8 | <end of file>
314 | ^
314 | ^
315Missing fixity declaration for Main.:>
315Missing fixity declaration for Main.:>
316
316
317−./reg077.idr:3:1:
317+reg077.idr:3:1:
318 |
318 |
319−3 | <empty line>
319+3 | <end of file>
320 | ^
320 | ^
321Missing fixity declaration for Main.:>>
321Missing fixity declaration for Main.:>>
322
322