[GHC] #11456: Type application and :set +c command cause panic

#11456: Type application and :set +c command cause panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Keywords: | Operating System: Unknown/Multiple TypeApplications GHCi | Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Type applications and the [https://downloads.haskell.org/~ghc/master /users-guide/ghci.html#ghci-cmd-:set%20+c :set +c] command don't play nice {{{#!hs {-# LANGUAGE TypeApplications #-} a = show @Int }}} {{{ % ghci -ignore-dot-ghci GHCi, version 8.1.20160117: http://www.haskell.org/ghc/ :? for help Prelude> :set +c Prelude> :load Panic.hs [1 of 1] Compiling Main ( Panic.hs, interpreted ) Ok, modules loaded: Main. Collecting type info for 1 module(s) ... Error while getting type info from Main: ghc: panic! (the 'impossible' happened) (GHC version 8.1.20160117 for x86_64-unknown-linux): dsExpr:HsTypeOut Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug *Main> }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11456 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11456: Type application and :set +c command cause panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: | TypeApplications GHCi 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 Iceland_jack): Doesn't happen with `id @Int` -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11456#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11456: Type application and :set +c command cause panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: | TypeApplications GHCi 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): It does actually, assuming you mean replacing `show` by `id` in the ticket. `GHCi.UI.Info.processAllTypeCheckedModule` is trying to desugar all the spans in the typechecked program individually to find out their types. One of those spans is `@Int`, which can't be desugared outside of the context `show @Int`. We should skip such subexpressions: any `HsTypeOut` constructor. Since this code is written in Generics-ese, I don't feel like trying to fix it myself. (Also, surely there is a more sensible way to collect this data then desugaring every span to find out its type, when we have already type checked the whole module?) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11456#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11456: Type application and :set +c command cause panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: | TypeApplications GHCi 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 rwbarton): * cc: goldfire (added) Comment: In general, though, this is a trap for GHC API users, who might expect every `HsExpr` to be, well, an expression. Richard, did you consider representing explicit type applications with a separate constructor `HsTypeApp`? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11456#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11456: Type application and :set +c command cause panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: | TypeApplications GHCi 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): Specifically, leave `Parser.y` unchanged, but at the end of parsing, convert all `HsApp e (HsType t)` to `HsTypeApp e t` (modulo locations, etc.) Then there are no invariants of the form "`HsType` can appear only within `HsApp`", just ones of the form "the output of [stage X] cannot contain [constructor Y]". -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11456#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11456: Type application and :set +c command cause panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: | TypeApplications GHCi 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 goldfire): No, I didn't consider `HsTypeApp`. That would probably be an improvement. My choice of abstract syntax was inspired by Core, which just has `App :: CoreExpr -> CoreExpr -> CoreExpr` and `Type :: Type -> CoreExpr`. I'll look into this refactoring. It could actually simplify quite a bit. (For example, see the awful `tcSeq` and `tcTagToEnum` in !TcExpr.) Thanks for the suggestion. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11456#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11456: Type application and :set +c command cause panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: | TypeApplications GHCi Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11329 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * related: => #11329 Comment: I have this refactoring done locally and will push in (short) due course. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11456#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11456: Type application and :set +c command cause panic
-------------------------------------+-------------------------------------
Reporter: Iceland_jack | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.1
Resolution: | Keywords:
| TypeApplications GHCi
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #11329 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Richard Eisenberg

#11456: Type application and :set +c command cause panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: merge Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: | TypeApplications GHCi Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | ghci/scripts/T11456 Blocked By: | Blocking: Related Tickets: #11329 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * testcase: => ghci/scripts/T11456 * status: new => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11456#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11456: Type application and :set +c command cause panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: | TypeApplications GHCi Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | ghci/scripts/T11456 Blocked By: | Blocking: Related Tickets: #11329 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed * milestone: => 8.0.1 Comment: Merged comment:7 as 729320938b17a101c4a6b43c824edace9ebb53f6. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11456#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11456: Type application and :set +c command cause panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: | TypeApplications GHCi Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | ghci/scripts/T11456 Blocked By: | Blocking: Related Tickets: #11329 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Iceland_jack): * Attachment "Error2.hs" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11456 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11456: Type application and :set +c command cause panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: | TypeApplications GHCi Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | ghci/scripts/T11456 Blocked By: | Blocking: Related Tickets: #11329 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Iceland_jack): * Attachment "Error2.hs" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11456 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11456: Type application and :set +c command cause panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: | TypeApplications GHCi Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | ghci/scripts/T11456 Blocked By: | Blocking: Related Tickets: #11329 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): Error2.hs fails, seems like same problem and can be added to the test suite: {{{ $ ghci -ignore-dot-ghci GHCi, version 8.1.20160117: http://www.haskell.org/ghc/ :? for help Prelude> :set +c Prelude> :load /tmp/Error2.hs [1 of 1] Compiling Main ( /tmp/Error2.hs, interpreted ) Ok, modules loaded: Main. Collecting type info for 1 module(s) ... Error while getting type info from Main: ghc: panic! (the 'impossible' happened) (GHC version 8.1.20160117 for x86_64-unknown-linux): dsExpr:HsTypeOut Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug *Main> }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11456#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11456: Type application and :set +c command cause panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: | TypeApplications GHCi Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | ghci/scripts/T11456 Blocked By: | Blocking: Related Tickets: #11329 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Error2 seems to have the same mechanism (`:set +c` with a type application) as the original error, which is already in the testsuite. I personally don't think another test is warranted. Thanks for posting however -- if someone stumbles over this problem in the future, they will find your second case. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11456#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC