[GHC] #10998: Parser should suggest -XMagicHash

GHC ghc-devs at haskell.org
Thu Oct 29 14:34:32 UTC 2015


#10998: Parser should suggest -XMagicHash
-------------------------------------+-------------------------------------
        Reporter:  osa1              |                Owner:
            Type:  bug               |               Status:  new
        Priority:  low               |            Milestone:
       Component:  Compiler          |              Version:  7.10.2
  (Parser)                           |
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by osa1):

 I think we should to be able to say, in the lexer, "print these warnings
 only
 if parsing fails". This would be very useful in cases like this. Some
 examples:

 {{{#!haskell
 λ:9> 1#2

 <interactive>:9:2: Not in scope: ‘#’
 λ:10> :set -XMagicHash
 λ:11> 1#2

 <interactive>:11:1:
     Couldn't match expected type ‘Integer -> t’ with actual type ‘Int#’
     Relevant bindings include it :: t (bound at <interactive>:11:1)
     The function ‘1#’ is applied to one argument,
     but its type ‘Int#’ has none
     In the expression: 1# 2
     In an equation for ‘it’: it = 1# 2
 }}}

 Here we shouldn't print any warnings like "Maybe you intended to use
 -XMagicHash" in the first line. But suppose this happened:

 {{{#!haskell
 λ:6> 1# +# 2#

 <interactive>:6:4: parse error on input ‘+#’
 }}}

 or see my original example above. In these cases we want to print a
 warning. I
 think only reliable way to decide when to print this warning is to check
 if
 parsing succeeded. If it's not, and if there was another way to lex some
 tokens
 with `-XMagicHash`, maybe the user is intended to use `-XMagicHash`, so
 the
 warning makes sense.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10998#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list