[GHC] #10998: Parser should suggest -XMagicHash

#10998: Parser should suggest -XMagicHash -------------------------------------+------------------------------------- Reporter: osa1 | Owner: Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.10.2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- When using GHCi, this is leading to a weird situation where GHCi is actually suggesting an identifier with `#` in it, but also rejecting when you actually type it: {{{ ➜ ~ ghc-stage2 --interactive GHCi, version 7.11.20151016: http://www.haskell.org/ghc/ :? for help λ:1> :m + GHC.Prim λ:2> :t unsafe unsafeCoerce# unsafeFreezeArrayArray# unsafeFreezeSmallArray# unsafeThawSmallArray# unsafeFreezeArray# unsafeFreezeByteArray# unsafeThawArray# λ:2> :t unsafeCoerce# <interactive>:1:14: error: parse error (possibly incorrect indentation or mismatched brackets) λ:3> :set -XMagicHash λ:4> :t unsafeCoerce# unsafeCoerce# :: a -> b }}} (also tried with 7.10) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10998 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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: | -------------------------------------+------------------------------------- Changes (by thomie): * component: Compiler => Compiler (Parser) Comment: Good idea. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10998#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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 rwbarton): Probably rather more common is the case `unsafeCoerce# foo`, and now this is not a parse error but rather an out-of-scope variable error (for both `unsafeCoerce` and `#`). Would be nice to catch this case too, perhaps by checking, when raising an out-of-scope error for `#`, whether it immediately follows a letter-type identifier? Also be sure not to suggest `-XMagicHash` if it is on already (e.g. `:t foo #`). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10998#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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'll work on this once I'm done with Phab:D1342. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10998#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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
participants (1)
-
GHC