[GHC] #11188: Confusing "parse error in pattern" for spurious indentation.
GHC
ghc-devs at haskell.org
Mon Mar 12 14:24:38 UTC 2018
#11188: Confusing "parse error in pattern" for spurious indentation.
-------------------------------------+-------------------------------------
Reporter: andreas.abel | Owner: (none)
Type: bug | Status: new
Priority: high | Milestone:
Component: Compiler | Version: 7.10.1
(Parser) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D4497
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by osa1):
* differential: => Phab:D4497
Comment:
I think the problem here is not that it's suggesting adding more `do`s
(it's saying "possibly", meaning the reason may be something else), but
it's showing only a small part of the large expression that the parser
considers as a pattern. I submitted Phab:D4497 to improve this. Previously
the error message was:
{{{
Main.hs:2:3: error:
Parse error in pattern: putStrLn
Possibly caused by a missing 'do'?
|
2 | putStrLn "" $ do
| ^^^^^^^^^^^
}}}
this is not good enough because it doesn't show the whole part that's
considered as a pattern. With Phab:D4497:
{{{
Main.hs:2:3: error:
Parse error in pattern: putStrLn "" $ do a <- return 3 c
Possibly caused by a missing 'do'?
putStrLn "" $ do a <- return 3 c
|
2 | putStrLn "" $ do
| ^^^^^^^^^^^^^^^^...
}}}
It's now clear that left hand side of second `<-` now covers the first
`<-` because the whole part is shown.
If the error message is still not good enough perhaps we can split the
parsers for expressions and patterns (rather than using expression parser
for patterns and then doing a check to see whether it's a valid pattern).
In that case I think we'd still get a parse error in expression parser
while parsing `return 3 c <- do ...` which would raise a better error
message I think.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11188#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list