on master help sign in
Use iWarn for parse errors
commitfb4c5e49d0c9d29b02dff8a8b5c0fe20ecc348d2 authorJason Felice <jason.m.felice@gmail.com> dateMon 11 Dec 2017, 11:52 (9 years ago) parent10763d2
5 files changed+20−22
src/Idris/Output.hs+1−1 src/Idris/Parser.hs+1−3 src/Idris/Parser/Stack.hs+1−1 test/layout001/expected+11−11 test/regression002/expected+6−6
src/Idris/Output.hs+1−1
@@ -90,7 +90,7 @@ iWarn fc err =
9090 else Nothing
9191 where
9292 sourceLine :: Maybe String
93− sourceLine = listToMaybe . drop (si - 1) . lines $ src
93+ sourceLine = listToMaybe . drop (si - 1) . (++ ["<end of file>"]) . lines $ src
9494
9595 haveSource :: Bool
9696 haveSource = isJust sourceLine
src/Idris/Parser.hs+1−3
@@ -1519,10 +1519,8 @@ parseProg syn fname input mrk
15191519 = do i <- getIState
15201520 case runparser mainProg i fname input of
15211521 Left err -> do let fc = errorExtent err
1522+ iWarn fc (Util.Pretty.string $ errorMessage err)
15221523 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)
15261524 putIState (i { errSpan = Just fc })
15271525 return []
15281526 Right (x, i) -> do putIState i
src/Idris/Parser/Stack.hs+1−1
@@ -72,7 +72,7 @@ errorExtent (ParseError _ err) = sourcePositionFC pos
7272
7373-- | A single-line parse error message, including location.
7474errorMessage :: ParseError -> String
75−errorMessage (ParseError _ err) = P.parseErrorTextPretty err
75+errorMessage (ParseError _ err) = init (P.parseErrorTextPretty err)
7676
7777-- | A fully formatted parse error, with caret and bar, etc.
7878prettyError :: ParseError -> String
test/layout001/expected+11−11
@@ -1,58 +1,58 @@
1−./layout001a.idr:5:1:
1+layout001a.idr:5:1:
22 |
335 | y
44 | ^
55Wrong indention: should be greater than context indentation
66
7−./layout001b.idr:5:3:
7+layout001b.idr:5:3:
88 |
995 | = y
1010 | ^
1111Wrong indention: should be greater than context indentation
1212
13−./layout001c.idr:3:1:
13+layout001c.idr:3:1:
1414 |
15153 | 2
1616 | ^
1717Wrong indention: should be greater than context indentation
1818
19−./layout001e.idr:6:1:
19+layout001e.idr:6:1:
2020 |
21216 | 3
2222 | ^
2323Wrong indention: should be greater than context indentation
2424
25−./layout001f.idr:6:2:
25+layout001f.idr:6:2:
2626 |
27276 | 3
2828 | ^
2929Wrong indention: should be greater than context indentation
3030
31−./layout001g.idr:6:3:
31+layout001g.idr:6:3:
3232 |
33336 | 3
3434 | ^
3535Wrong indention: should be greater than context indentation
3636
37−./layout001h.idr:6:3:
37+layout001h.idr:6:3:
3838 |
39396 | 3
4040 | ^
4141Wrong indention: should be greater than context indentation
4242
43−./layout001i.idr:6:4:
43+layout001i.idr:6:4:
4444 |
45456 | 3
4646 | ^
4747Wrong indention: should be greater than context indentation
4848
49−./layout001j.idr:6:5:
49+layout001j.idr:6:5:
5050 |
51516 | 3
5252 | ^
5353Wrong indention: should be greater than context indentation
5454
55−./layout001l.idr:6:1:
55+layout001l.idr:6:1:
5656 |
57576 | y
5858 | ^
@@ -68,7 +68,7 @@ When checking right hand side of term with expected type
6868When checking an application of function Prelude.Applicative.pure:
6969 No such variable f
7070
71−./mplus2.idr:17:37:
71+mplus2.idr:17:37:
7272 |
737317 | `mplus` pure f
7474 | ^
test/regression002/expected+6−6
@@ -182,13 +182,13 @@ When checking right hand side of uhOh with expected type
182182
183183No such variable Bogus
184184
185−./badbangop.idr:7:1:
185+badbangop.idr:7:1:
186186 |
1871877 | (!) : List a -> Nat -> Maybe a
188188 | ^
189189! is not a valid operator
190190
191−./baddoublebang.idr:6:28:
191+baddoublebang.idr:6:28:
192192 |
1931936 | doubleBang mmn = do pure !!mmn
194194 | ^
@@ -308,15 +308,15 @@ reg070.idr:7:1-7:
308308 | ~~~~~~~
309309Test_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
310310
311−./reg076.idr:8:1:
311+reg076.idr:8:1:
312312 |
313−8 | <empty line>
313+8 | <end of file>
314314 | ^
315315Missing fixity declaration for Main.:>
316316
317−./reg077.idr:3:1:
317+reg077.idr:3:1:
318318 |
319−3 | <empty line>
319+3 | <end of file>
320320 | ^
321321Missing fixity declaration for Main.:>>
322322