Opened 10 months ago

Closed 9 months ago

#13132 closed bug (fixed)

Compilation fails with a panic: get_op runContT

Reported by: PoroCYon Owned by: adamgundry
Priority: normal Milestone: 8.2.1
Component: Compiler Version: 8.0.1
Keywords: ORF Cc: adamgundry
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash or panic Test Case: rename/should_compile/T13132, overloadedrecflds/should_fail/T13132_duplicaterecflds
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D2985, Phab:D3126
Wiki Page:

Description

Compiling 'tersmu' from Hackage fails with the following:

[13 of 16] Compiling ParseM           ( ParseM.hs, ParseM.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 8.0.1 for x86_64-unknown-linux):
	get_op runContT

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

The code can be found here.

Change History (17)

comment:1 Changed 10 months ago by mpickering

Have you tried with 8.0.2? It might be #10618

comment:2 Changed 10 months ago by mpickering

I tried with 8.0.2 (cabal install tersmu) and the same panic exists.

comment:3 Changed 10 months ago by RyanGlScott

Here's a minimal test case:

module Bug where

newtype ContT r m a = ContT { runContT :: (a -> m r) -> m r }

foo = (`runContT` bar.baz)
$ ghc Bug.hs 
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 8.0.2 for x86_64-unknown-linux):
        get_op runContT

Also reproducible on GHC HEAD.

comment:4 Changed 10 months ago by RyanGlScott

Cc: adamgundry added

The culprit is commit b1884b0e62f62e3c0859515c4137124ab0c9560e (Implement DuplicateRecordFields). Thoughts, Adam?

comment:5 Changed 10 months ago by adamgundry

Thanks for tracking this down. It looks like get_op is missing a case for HsRecFld. The unambiguous case is easy, something like:

get_op (L _ (HsRecFld (Unambiguous _ n))) = n

That should fix the bug when DuplicateRecordFields is disabled, at least.

Unfortunately the case for Ambiguous (which may arise when when DuplicateRecordFields is enabled) is harder, because we don't know which Name is meant. I'll try to take a look at this, but it may not be very soon.

comment:6 Changed 10 months ago by adamgundry

Keywords: ORF added

comment:7 Changed 10 months ago by simonpj

Ben/David/Reid: could you fix the unambiguous case as above, add a test; and add another expect_broken test for the ambiguous case. And then assign to Adam?

comment:8 Changed 10 months ago by rwbarton

Owner: set to rwbarton

comment:9 Changed 10 months ago by rwbarton

Differential Rev(s): Phab:D2985
Test Case: rename/should_compile/T13132

I posted a diff fixing the unambiguous case as described above. I don't understand these extensions well enough to know whether it is actually possible for an ambiguous record selector to pass the renamer to this point, so I didn't add a failing test case for the ambiguous record field case.

comment:10 Changed 10 months ago by rwbarton

Owner: rwbarton deleted

comment:11 Changed 10 months ago by rwbarton

Owner: set to adamgundry

comment:12 Changed 10 months ago by Ben Gamari <ben@…>

In 38374caa/ghc:

Fix get_op in the case of an unambiguous record selector (#13132)

Test Plan: validate

Reviewers: simonpj, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2985

GHC Trac Issues: #13132

comment:13 Changed 10 months ago by bgamari

Milestone: 8.2.1

Leaving this open until we also fix the ambiguous case described above. Adam, do you suppose you could have a look at this?

comment:14 Changed 10 months ago by adamgundry

Yes, will do.

comment:15 Changed 9 months ago by adamgundry

Differential Rev(s): Phab:D2985Phab:D2985, Phab:D3126
Status: newpatch
Test Case: rename/should_compile/T13132rename/should_compile/T13132, overloadedrecflds/should_fail/T13132_duplicaterecflds

comment:16 Changed 9 months ago by Ben Gamari <ben@…>

In 2484d4d/ghc:

Refactor renaming of operators/sections to fix DuplicateRecordFields bugs

A variety of panics were possible because the get_op function in
RnTypes didn't handle the possibility that its argument might be an
ambiguous record field. I've made its return type more informative to
correctly handle occurrences of record fields.  Fixes Trac #13132.

Test Plan: new test
overloadedrecflds/should_fail/T13132_duplicaterecflds

Reviewers: bgamari, simonpj, austin

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D3126

comment:17 Changed 9 months ago by adamgundry

Resolution: fixed
Status: patchclosed
Note: See TracTickets for help on using tickets.