[GHC] #10243: SrcSpan incorrect for non-alphanumeric VarPat

#10243: SrcSpan incorrect for non-alphanumeric VarPat -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- There is an inconsistency when parsing patterns which contain non- alphanumeric characters. For example, {{{!#hs foo (.) = 5 }}} the pattern parses as the following. {{{ (L {tests/examples/ArgPuncParens.hs:2:5-7} (VarPat (Unqual {OccName: .})))] }}} Then consider the following similar program. {{{#!hs foo (x) = 5 }}} The parse is as follows. {{{ (L {tests/examples/ArgPuncParens.hs:2:5-7} (ParPat (L {tests/examples/ArgPuncParens.hs:2:6} (VarPat (Unqual {OccName: x})))))] }}} Notice two differences. 1. The first parse lacks a surrounding `ParPat`. 2. If the `ParPat` is deliberately omitted then the given location encompasses the surrounding parentheses which is not consistent with the second example where `VarPat` specifically refers to `x`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10243 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10243: SrcSpan incorrect for non-alphanumeric VarPat -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Description changed by mpickering: Old description:
There is an inconsistency when parsing patterns which contain non- alphanumeric characters.
For example,
{{{!#hs foo (.) = 5 }}}
the pattern parses as the following.
{{{ (L {tests/examples/ArgPuncParens.hs:2:5-7} (VarPat (Unqual {OccName: .})))] }}}
Then consider the following similar program.
{{{#!hs foo (x) = 5 }}}
The parse is as follows.
{{{ (L {tests/examples/ArgPuncParens.hs:2:5-7} (ParPat (L {tests/examples/ArgPuncParens.hs:2:6} (VarPat (Unqual {OccName: x})))))] }}}
Notice two differences.
1. The first parse lacks a surrounding `ParPat`. 2. If the `ParPat` is deliberately omitted then the given location encompasses the surrounding parentheses which is not consistent with the second example where `VarPat` specifically refers to `x`.
New description: There is an inconsistency when parsing patterns which contain non- alphanumeric characters. For example, {{{#!hs foo (.) = 5 }}} the pattern parses as the following. {{{ (L {tests/examples/ArgPuncParens.hs:2:5-7} (VarPat (Unqual {OccName: .})))] }}} Then consider the following similar program. {{{#!hs foo (x) = 5 }}} The parse is as follows. {{{ (L {tests/examples/ArgPuncParens.hs:2:5-7} (ParPat (L {tests/examples/ArgPuncParens.hs:2:6} (VarPat (Unqual {OccName: x})))))] }}} Notice two differences. 1. The first parse lacks a surrounding `ParPat`. 2. If the `ParPat` is deliberately omitted then the given location encompasses the surrounding parentheses which is not consistent with the second example where `VarPat` specifically refers to `x`. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10243#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10243: SrcSpan incorrect for non-alphanumeric VarPat -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: closed Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.1 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by rwbarton): * status: new => closed * resolution: => invalid Comment: These really do parse differently though: `(x)` is a pattern `x` enclosed in parentheses, while `(.)` is a single identifier (infix operator in prefix form). If you consult https://www.haskell.org/onlinereport/haskell2010/haskellch10.html I think you will find that these outputs match the parses specified by the Report. Please reopen if you disagree. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10243#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC