[GHC] #12130: ghc: panic! (the 'impossible' happened): find_tycon Block []
#12130: ghc: panic! (the 'impossible' happened): find_tycon Block [] -------------------------------------+------------------------------------- Reporter: jeiea | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template | Version: 8.0.1 Haskell | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Compile-time Unknown/Multiple | crash Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I just tried building yesod-simple template project with nightly-2016-05-29 snapshot and some extra-deps package, and it seems to fail due to {{{$(widgetFile ...)}}} yesod template haskell clause. It was same on linux and windows, and when I remove handler ghc fails at Application module (and seems also due to template haskell). {{{ ~/yt> stack build ... yt-0.0.0: configure Configuring yt-0.0.0... yt-0.0.0: build Preprocessing library yt-0.0.0... [1 of 9] Compiling Settings ( Settings.hs, .stack- work/dist/x86_64-linux/Cabal-1.24.0.0/build/Settings.o ) [2 of 9] Compiling Settings.StaticFiles ( Settings/StaticFiles.hs, .stack- work/dist/x86_64-linux/Cabal-1.24.0.0/build/Settings/StaticFiles.o ) [3 of 9] Compiling Import.NoFoundation ( Import/NoFoundation.hs, .stack- work/dist/x86_64-linux/Cabal-1.24.0.0/build/Import/NoFoundation.o ) [4 of 9] Compiling Foundation ( Foundation.hs, .stack- work/dist/x86_64-linux/Cabal-1.24.0.0/build/Foundation.o ) [5 of 9] Compiling Import ( Import.hs, .stack- work/dist/x86_64-linux/Cabal-1.24.0.0/build/Import.o ) [6 of 9] Compiling Handler.Common ( Handler/Common.hs, .stack- work/dist/x86_64-linux/Cabal-1.24.0.0/build/Handler/Common.o ) [7 of 9] Compiling Handler.Home ( Handler/Home.hs, .stack- work/dist/x86_64-linux/Cabal-1.24.0.0/build/Handler/Home.o ) ghc: panic! (the 'impossible' happened) (GHC version 8.0.1 for x86_64-unknown-linux): find_tycon Block [] Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug Completed 179 action(s). -- While building package yt-0.0.0 using: /home/jeiea/.stack/setup-exe-cache/x86_64-linux/setup-Simple- Cabal-1.24.0.0-ghc-8.0.1 --builddir=.stack- work/dist/x86_64-linux/Cabal-1.24.0.0 build lib:yt exe:yt --ghc-options " -ddump-hi -ddump-to-file" Process exited with code: ExitFailure 1 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12130> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12130: ghc: panic! (the 'impossible' happened): find_tycon Block [] -------------------------------------+------------------------------------- Reporter: jeiea | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by jeiea): * Attachment "yesod-simple.zip" added. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12130> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12130: ghc: panic! (the 'impossible' happened): find_tycon Block [] -------------------------------------+------------------------------------- Reporter: jeiea | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Template Haskell | Version: 8.0.1 Resolution: | Keywords: | DisambiguateRecordFields Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: #11228 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * priority: normal => high * cc: adamgundry (added) * related: => #11228 * keywords: => DisambiguateRecordFields Comment: Regression from 7.10. Here is a reproducer: A.hs: {{{#!hs {-# Language TemplateHaskell #-} {-# Language DisambiguateRecordFields #-} -- DisambiguateRecordFields (or RecordWildCards) is necessary -- to trigger the bug. module A where import B hiding (Block) -- Hiding "Block" is necessary to trigger the bug. b = $(block) {- ghc: panic! (the 'impossible' happened) (GHC version 8.0.1 for x86_64-unknown-linux): find_tycon Block [] -} }}} B.hs: {{{#!hs {-# LANGUAGE TemplateHaskell #-} module B where import Language.Haskell.TH data Block = Block { blockSelector :: () } block :: Q Exp block = [| Block { -- Using record syntax is neccesary to trigger the bug. blockSelector = () } |] }}} CC adamgundry, as he was the last to touch `find_tycon`. The discussion in ticket:11228#comment:4 seems relevant. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12130#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12130: ghc: panic! (the 'impossible' happened): find_tycon Block [] -------------------------------------+------------------------------------- Reporter: jeiea | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Template Haskell | Version: 8.0.1 Resolution: | Keywords: | DisambiguateRecordFields Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: #11228 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * milestone: => 8.0.2 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12130#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12130: ghc: panic! (the 'impossible' happened): find_tycon Block [] -------------------------------------+------------------------------------- Reporter: jeiea | Owner: Type: bug | Status: patch Priority: high | Milestone: 8.0.2 Component: Template Haskell | Version: 8.0.1 Resolution: | Keywords: | DisambiguateRecordFields Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T12130 Blocked By: | Blocking: Related Tickets: #11228 | Differential Rev(s): Phab:D2321 Wiki Page: | -------------------------------------+------------------------------------- Changes (by adamgundry): * status: new => patch * testcase: => th/T12130 * differential: => Phab:D2321 Comment: Thanks for the great test case! It turns out this bug was lingering already in 7.10, but laziness meant we didn't hit the panic by sheer luck. Simple fix: replace the panic with `Nothing`, which is reasonable in this context: if the datacon isn't in scope, don't use it for disambiguating record fields. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12130#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12130: ghc: panic! (the 'impossible' happened): find_tycon Block [] -------------------------------------+------------------------------------- Reporter: jeiea | Owner: adamgundry Type: bug | Status: patch Priority: high | Milestone: 8.0.2 Component: Template Haskell | Version: 8.0.1 Resolution: | Keywords: | DisambiguateRecordFields Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T12130 Blocked By: | Blocking: Related Tickets: #11228 | Differential Rev(s): Phab:D2321 Wiki Page: | -------------------------------------+------------------------------------- Changes (by adamgundry): * owner: => adamgundry -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12130#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12130: ghc: panic! (the 'impossible' happened): find_tycon Block [] -------------------------------------+------------------------------------- Reporter: jeiea | Owner: adamgundry Type: bug | Status: patch Priority: high | Milestone: 8.0.2 Component: Template Haskell | Version: 8.0.1 Resolution: | Keywords: | DisambiguateRecordFields Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T12130 Blocked By: | Blocking: Related Tickets: #11228 | Differential Rev(s): Phab:D2321 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"4d71cc89b4e9648f3fbb29c8fcd25d725616e265/ghc" 4d71cc89/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="4d71cc89b4e9648f3fbb29c8fcd25d725616e265" Avoid find_tycon panic if datacon is not in scope When using TH to splice expressions involving record field construction, the parent datacon may not be in scope. We shouldn't panic about this, because we will be renaming Exact RdrNames which don't require any disambiguation. Test Plan: new test th/T12130 Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2321 GHC Trac Issues: #12130 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12130#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12130: ghc: panic! (the 'impossible' happened): find_tycon Block [] -------------------------------------+------------------------------------- Reporter: jeiea | Owner: adamgundry Type: bug | Status: merge Priority: high | Milestone: 8.0.2 Component: Template Haskell | Version: 8.0.1 Resolution: | Keywords: | DisambiguateRecordFields Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T12130 Blocked By: | Blocking: Related Tickets: #11228 | Differential Rev(s): Phab:D2321 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => merge Comment: Seems like a good candidate for 8.0.2. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12130#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12130: ghc: panic! (the 'impossible' happened): find_tycon Block [] -------------------------------------+------------------------------------- Reporter: jeiea | Owner: adamgundry Type: bug | Status: merge Priority: high | Milestone: 8.0.2 Component: Template Haskell | Version: 8.0.1 Resolution: | Keywords: | DisambiguateRecordFields Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T12130 Blocked By: | Blocking: Related Tickets: #11228 | Differential Rev(s): Phab:D2321 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Simon Peyton Jones <simonpj@…>): In [changeset:"2f8cd14fe909a377b3e084a4f2ded83a0e6d44dd/ghc" 2f8cd14/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="2f8cd14fe909a377b3e084a4f2ded83a0e6d44dd" Narrow the use of record wildcards slightly In reviewing the fix to Trac #12130 I found the wild-card fill-in code for ".." notation in record constructions hard to understand. It went to great contortions (including the find_tycon code) to allow data T = C { x, y :: Int } f x = C { .. } to expand to f x = C { x = x, y = y } where 'y' is an /imported function/! That seems way over the top for what record wildcards are supposed to do. So I have narrowed the record-wildcard expansion to include only /locally-bound/ variables; i.e. not top level, and certainly not imported. I don't think anyone is using record wildcards in this bizarre way, so I don't expect any fallout. Even if there is, you can easily initialise fields with eponymous but imported values by hand. An intermediate position would be to allow /local/ top-level definitions. But I doubt anyone is doing that either. Let's see if there's any fallout. It's a local change, easy to revert, so I've just gone ahead to save everyone's time. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12130#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12130: ghc: panic! (the 'impossible' happened): find_tycon Block [] -------------------------------------+------------------------------------- Reporter: jeiea | Owner: adamgundry Type: bug | Status: closed Priority: high | Milestone: 8.0.2 Component: Template Haskell | Version: 8.0.1 Resolution: fixed | Keywords: | DisambiguateRecordFields Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T12130 Blocked By: | Blocking: Related Tickets: #11228 | Differential Rev(s): Phab:D2321 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged to `ghc-8.0` as 206ac693372d00b59eb98c34b801906c5e7bedfc. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12130#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12130: ghc: panic! (the 'impossible' happened): find_tycon Block [] -------------------------------------+------------------------------------- Reporter: jeiea | Owner: adamgundry Type: bug | Status: closed Priority: high | Milestone: 8.0.2 Component: Template Haskell | Version: 8.0.1 Resolution: fixed | Keywords: | DisambiguateRecordFields Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T12130 Blocked By: | Blocking: Related Tickets: #11228 | Differential Rev(s): Phab:D2321 Wiki Page: | -------------------------------------+------------------------------------- Comment (by spl): For others who happen upon this problem with GHC 8.0.1, I've used the following workaround. In each module where the error occurs, add ```{-# LANGUAGE NoDisambiguateRecordFields NoRecordWildCards #-}``` and remove all uses of disambiguated fields and record wildcards from that module. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12130#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC