[GHC] #13302: Let in do-notation with braces does not parse

#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 Keywords: do-notation, | Operating System: MacOS X let, parse | Architecture: | Type of failure: GHC rejects Unknown/Multiple | valid program Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- According to the the syntax at https://www.haskell.org/onlinereport/haskell2010/haskellch10.html the following do-notation should parse: {{{#!hs do {let x = 4; print x} }}} But it doesn't. {{{#!hs do {let x = 4 in print x} }}} parses OK. Doesn't look like a new bug, I tried with GHC 7.8 and same result. Googling "haskell do {let ds; es} = let ds in do {es}" also shows quite a lot of people taught Haskell that way, so maybe it once worked? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13302 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

{{{ 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
#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 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

#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 rem): You are right, I over looked the syntax rule decls → { decl_1 ; … ; decl_n } (n ≥ 0). Closing -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13302#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13302: Let in do-notation with braces does not parse -------------------------------------+------------------------------------- Reporter: rem | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: invalid | 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: | -------------------------------------+------------------------------------- Changes (by rem): * status: new => closed * resolution: => invalid -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13302#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC