[GHC] #9922: Partial type signatures + extensions panic

#9922: Partial type signatures + extensions panic -------------------------------------+------------------------------------- Reporter: monoidal | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.9 checker) | Operating System: Keywords: | Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: Compile- Difficulty: Unknown | time crash Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Partial type signatures combined with the following GHC extensions cause a panic: {{{#!hs class C a where default f :: _ -- DefaultSignatures instance Num Bool where negate :: _ -- InstanceSigs deriving instance _ -- StandaloneDeriving }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9922 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9922: Partial type signatures + extensions panic -------------------------------------+------------------------------------- Reporter: monoidal | Owner: thomasw Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: time crash | Test Case: | Blocking: | Differential Revisions: D595 | -------------------------------------+------------------------------------- Changes (by thomasw): * owner: => thomasw * differential: => D595 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9922#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9922: Partial type signatures + extensions panic -------------------------------------+------------------------------------- Reporter: monoidal | Owner: thomasw Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: time crash | Test Case: | Blocking: | Differential Revisions: Phab:D595 | -------------------------------------+------------------------------------- Changes (by thomasw): * differential: D595 => Phab:D595 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9922#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9922: Partial type signatures + extensions panic -------------------------------------+------------------------------------- Reporter: monoidal | Owner: thomasw Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: time crash | Test Case: | Blocking: | Differential Revisions: Phab:D595 | -------------------------------------+------------------------------------- Comment (by thomasw): Thanks for finding all the panics I caused :) I fixed it in Phab:D595. Happy holidays. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9922#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9922: Partial type signatures + extensions panic -------------------------------------+------------------------------------- Reporter: monoidal | Owner: thomasw Type: bug | Status: patch Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.9 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: time crash | Test Case: | Blocking: | Differential Revisions: Phab:D595 | -------------------------------------+------------------------------------- Changes (by hvr): * status: new => patch * milestone: => 7.10.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9922#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9922: Partial type signatures + extensions panic -------------------------------------+------------------------------------- Reporter: monoidal | Owner: thomasw Type: bug | Status: patch Priority: normal | Milestone: 7.10.1 Component: Compiler (Type | Version: 7.9 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: Compile-time | Test Case: crash | Blocking: Blocked By: | Differential Revisions: Phab:D595 Related Tickets: | -------------------------------------+------------------------------------- Comment (by simonpj): Austin: let's merge this to 7.10.1. Thomas: I'm not very happy with the way that wild-card error reporting is done. I think we discussed this before, but left it on one side until it was all working. Which it now is. What I suggest is this: Things I dislike: * I dislike the `checkParitalTypeSignature` and `checkNoPartialType` stuff in `RdrHsSyn`. The only checks that belong in `RdrHsSym` are ones that prevent you building a syntax tree at all. All other checks are best done later, when good error reporting is easier, and you can recover from errors. * I particularly hate the `RnTypes.extractWildcards` stuff. It's like a whole extra renaming pass over the type, changing `HsWildCardTy` to `HsNamedWildCardTy` with an `Exact` `RdrName` in it. Yuk! Here is a possible plan: * Remove all the checking from `RdrHsSyn`, unless we can't build a syntax tree without it. * Collapse `HsWildcardTy` and `HsNamedWildcardTy` into one, with a boolean (or a `Named`/`Anonymous` flag) to distinguish. * Provide a specialised version of `rnLHsType`, perhpas `rnLHsTypeWithWildCards`, that does the inital pass to find the named wildcards and bring them into scope. This version is called in the places where you can have a type with wildcards, namely * `TypeSig` * `ExprWithTySig` * `rnHsBndrSig` * `rnLHsTypeWithWildCards` can work like this: 1. Collect all the named wildcards, and bring them into scope. This is a simple, ''pure'' function. 2. Call `rnLHsType`. When `rnLHsType` finds an anonymous wildcard, just make up a fresh name, rather than looking it up. 3. Collect all the wildcards (named or anonymous) to get a `[Name]`; again a pure function 4. Return the renamed type and the wildcard names That makes three passes, but each is simple. In fact (1) and (4) could perhaps be the same function, with a boolean flag to say which wildcards to return. * All this means that when `rnLHsType` is called directly (not via `rnLHsTypeWithWildCards`) on a type like `_ -> Int`, it will succeed, generateing a fresh name for the `_`. That's fine. In `tc_hs_type` we will find it is not in scope, so we can say "Unexpected wildcard in type", and the enclosing location information will nail down the details. * There are, I think, three places where `HsWithBndrs` is used: `HsDecls.HsTyPats`, `HsDecls.RuleBndr`, `HsPat.SigPatIn`. In the latter two I think that wildcards should be legal; in the first not so. (Do you have tests for all three?) So the caller of `rnHsBndrSig` should check for empty wildcards in the cases where there shouldn't be any. I this this is just in type/data family patterns. I have not throught throught the extra-constraints wild card, but I think a similar plan should work. Does this make sense? Might you do it? (To HEAD, of course.) Thanks Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9922#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9922: Partial type signatures + extensions panic -------------------------------------+------------------------------------- Reporter: monoidal | Owner: thomasw Type: bug | Status: patch Priority: normal | Milestone: 7.10.1 Component: Compiler (Type | Version: 7.9 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: Compile-time | Test Case: crash | Blocking: Blocked By: | Differential Revisions: Phab:D595 Related Tickets: | -------------------------------------+------------------------------------- Comment (by thomasw): Replying to [comment:5 simonpj]:
Thomas: I'm not very happy with the way that wild-card error reporting is done.
I agree. I have thought about it too. An "opt-in to wildcards" approach would be much better than my current "opt-out" approach, which was bound to be incomplete.
I think we discussed this before, but left it on one side until it was all working. Which it now is. What I suggest is this: .. Does this make sense? Might you do it? (To HEAD, of course.)
Looks like a good plan. I think your suggestion to provide a separate `rnLHsTypeWithWildCards` will help me overcome many of the problems I had when I last tried to refactor the renaming of wildcards. I'll start working on it as soon as the holidays are over, i.e. next week. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9922#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9922: Partial type signatures + extensions panic
-------------------------------------+-------------------------------------
Reporter: monoidal | Owner: thomasw
Type: bug | Status: patch
Priority: normal | Milestone: 7.10.1
Component: Compiler (Type | Version: 7.9
checker) | Keywords:
Resolution: | Architecture:
Operating System: Unknown/Multiple | Unknown/Multiple
Type of failure: Compile-time | Test Case:
crash | Blocking:
Blocked By: | Differential Revisions: Phab:D595
Related Tickets: |
-------------------------------------+-------------------------------------
Comment (by Austin Seipp

#9922: Partial type signatures + extensions panic -------------------------------------+------------------------------------- Reporter: monoidal | Owner: thomasw Type: bug | Status: closed Priority: normal | Milestone: 7.10.1 Component: Compiler (Type | Version: 7.9 checker) | Keywords: Resolution: fixed | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: Compile-time | Test Case: crash | Blocking: Blocked By: | Differential Revisions: Phab:D595 Related Tickets: | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: patch => closed * resolution: => fixed Comment: Merged to `ghc-7.10`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9922#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC