[GHC] #10072: Panic: generalised wildcards in RULES

#10072: Panic: generalised wildcards in RULES -------------------------------------+------------------------------------- Reporter: thomasw | Owner: thomasw Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1-rc2 (Type checker) | Operating System: Unknown/Multiple Keywords: | Type of failure: Compile-time Architecture: | crash Unknown/Multiple | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Generalised wildcards (PartialTypeSignatures) in the binder type annotation of a RULE cause panics. Minimal example: {{{#!hs module WildcardInRuleBndrSig where {-# RULES "map/empty" forall (f :: a -> _). map f [] = [] #-} }}} Output: {{{ WildcardInRuleBndrSig.hs:3:31:ghc-stage1: panic! (the 'impossible' happened) (GHC version 7.11.20150209 for x86_64-unknown-linux): No skolem info: w__alY[sk] }}} When a wildcard is generalised over, the error message reporting the inferred type gives some extra info about the type variables occurring in the inferred type. This extra information is retrieved by looking up the skolem information (`getSkolemInfo`) for the type variables in the enclosing implications (`cec_encl`). The problem is that there are no enclosing implications in this case, hence the panic. Note that with the flags `-XPartialTypeSignatures` and `-fno-warn-partial- type-signatures` enabled, there is no panic, as no error/warning message is constructed. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10072 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10072: Panic: generalised wildcards in RULES -------------------------------------+------------------------------------- Reporter: thomasw | Owner: thomasw Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.10.1-rc2 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: Compile-time | Test Case: crash | Blocking: Blocked By: | Differential Revisions: Related Tickets: | -------------------------------------+------------------------------------- Comment (by thomasw): Bug discovered while working on Phab:D613, where I also proposed an unsatisfactory stopgap solution: not printing extra skolem information when there is none. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10072#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10072: Panic: generalised wildcards in RULES -------------------------------------+------------------------------------- Reporter: thomasw | Owner: thomasw Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.10.1-rc2 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: Compile-time | Test Case: crash | Blocking: Blocked By: | Differential Revisions: Related Tickets: | -------------------------------------+------------------------------------- Comment (by simonpj): We should never generalise over wildcards! Thomas, are you ok to look into this one? Yell if you need help. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10072#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10072: Panic: generalised wildcards in RULES -------------------------------------+------------------------------------- Reporter: thomasw | Owner: thomasw Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.10.1-rc2 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: Compile-time | Test Case: crash | Blocking: Blocked By: | Differential Revisions: Related Tickets: | -------------------------------------+------------------------------------- Comment (by thomasw): Replying to [comment:2 simonpj]:
We should never generalise over wildcards!
I'm confused, we do generalise over wildcards when possible, right? When I say "the wildcard is generalised over", I mean that when the wildcard is not instantiated to a monotype, we replace it with a fresh type variable and universally quantify it. This is what we have being doing the whole time, e.g.: {{{#!hs foo :: _ -> _ foo x = x -- Inferred: w_ -> w_ }}} What I expected in the example in the description above (and what indeed happens) is that the wildcard is generalised over and that we get `a -> w_` as type for `f`.
Thomas, are you ok to look into this one? Yell if you need help.
I see two ways to solve it: 1. Don't print skolem information when there is none (easy). 2. Generate an `Implication` with the right skolem information (harder). Which solution do you prefer? If you prefer 2, I'd appreciate some pointers as to where/when these `Implication` constraints should be generated. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10072#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10072: Panic: generalised wildcards in RULES
-------------------------------------+-------------------------------------
Reporter: thomasw | Owner: thomasw
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler (Type | Version: 7.10.1-rc2
checker) | Keywords:
Resolution: | Architecture:
Operating System: Unknown/Multiple | Unknown/Multiple
Type of failure: Compile-time | Test Case:
crash | Blocking:
Blocked By: | Differential Revisions:
Related Tickets: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#10072: Panic: generalised wildcards in RULES -------------------------------------+------------------------------------- Reporter: thomasw | Owner: thomasw Type: bug | Status: merge Priority: normal | Milestone: Component: Compiler (Type | Version: 7.10.1-rc2 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: Compile-time | Test Case: crash | typecheck/should_compile/T10072 Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => merge * testcase: => typecheck/should_compile/T10072 Comment: I think I have fixed this. Probably worth merging to 7.10. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10072#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10072: Panic: generalised wildcards in RULES -------------------------------------+------------------------------------- Reporter: thomasw | Owner: thomasw Type: bug | Status: closed Priority: normal | Milestone: 7.10.1 Component: Compiler (Type | Version: 7.10.1-rc2 checker) | Keywords: Resolution: fixed | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: Compile-time | Test Case: crash | typecheck/should_compile/T10072 Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: merge => closed * resolution: => fixed * milestone: => 7.10.1 Comment: Merged to `ghc-7.10` (via 20ccf72614bab9a00767b2514b7cded4b6e3084e). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10072#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC