[GHC] #13302: Let in do-notation with braces does not parse
GHC
ghc-devs at haskell.org
Sun Feb 19 19:48:32 UTC 2017
#13302: Let in do-notation with braces does not parse
-------------------------------------+-------------------------------------
Reporter: rem | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.2
Resolution: | Keywords: do-notation,
| let, parse
Operating System: MacOS X | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by rwbarton):
I believe GHC is correct here. The non-layout syntax you have in mind is
of course
{{{
do {let {x = 4}; print x}
}}}
In your first snippet there is no `{` after `let`, so layout comes into
play. It seems that you expect the layout rule to insert a `}` before the
`;`, presumably thanks to the rule
> {{{
> L (t : ts) (m : ms) = } : (L (t : ts) ms) if m ∕= 0 and parse-
error(t)
> }}}
> Note 5.
> The side condition parse-error(t) is to be interpreted as follows: if
the tokens generated so far by L together with the next token t represent
an invalid prefix of the Haskell grammar, and the tokens generated so far
by L followed by the token “}” represent a valid prefix of the Haskell
grammar, then parse-error(t) is true.
But, even as much as
{{{
do {let {x = 4; print x
}}}
is a valid prefix of the Haskell grammar, since it could continue, for
example,
{{{
= 5}; print x}
}}}
So the effect of layout does not turn your first snippet into a valid
Haskell program.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13302#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list