Opened 7 months ago

Closed 7 months ago

#13740 closed bug (duplicate)

GHC panic with operator constructor of newtype

Reported by: codebje Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 8.0.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash or panic Test Case:
Blocked By: Blocking:
Related Tickets: #13741, #13132 Differential Rev(s):
Wiki Page:

Description

The following code causes a GHC panic:

newtype Cont r a = Cont { (>>-) :: (a -> r) -> r }
x = \a b c -> c >>- a . b

This slight modification, however, is fine:

newtype Cont r a = Cont { (>>-) :: (a -> r) -> r }
x = \a b c -> c >>- (a . b)

The presence or absence of a type signature for x makes no difference. Compiling with "-v" suggests the panic occurs during type checking:

Glasgow Haskell Compiler, Version 8.0.2, stage 2 booted by GHC version 7.10.3
Using binary package database: /Users/bje/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d/package.cache
Using binary package database: /Users/bje/.stack/snapshots/x86_64-osx/lts-8.8/8.0.2/pkgdb/package.cache
Using binary package database: /Users/bje/.stack/global/.stack-work/install/x86_64-osx/lts-8.8/8.0.2/pkgdb/package.cache
loading package database /Users/bje/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d
loading package database /Users/bje/.stack/snapshots/x86_64-osx/lts-8.8/8.0.2/pkgdb
loading package database /Users/bje/.stack/global/.stack-work/install/x86_64-osx/lts-8.8/8.0.2/pkgdb
wired-in package ghc-prim mapped to ghc-prim-0.5.0.0
wired-in package integer-gmp mapped to integer-gmp-1.0.0.1
wired-in package base mapped to base-4.9.1.0
wired-in package rts mapped to rts
wired-in package template-haskell mapped to template-haskell-2.11.1.0
wired-in package ghc mapped to ghc-8.0.2
wired-in package dph-seq not found.
wired-in package dph-par not found.
Hsc static flags:
loading package database /Users/bje/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d
loading package database /Users/bje/.stack/snapshots/x86_64-osx/lts-8.8/8.0.2/pkgdb
loading package database /Users/bje/.stack/global/.stack-work/install/x86_64-osx/lts-8.8/8.0.2/pkgdb
wired-in package ghc-prim mapped to ghc-prim-0.5.0.0
wired-in package integer-gmp mapped to integer-gmp-1.0.0.1
wired-in package base mapped to base-4.9.1.0
wired-in package rts mapped to rts-1.0
wired-in package template-haskell mapped to template-haskell-2.11.1.0
wired-in package ghc mapped to ghc-8.0.2
wired-in package dph-seq not found.
wired-in package dph-par not found.
*** Chasing dependencies:
Chasing modules from: *panic.hs
!!! Chasing dependencies: finished in 0.57 milliseconds, allocated 0.224 megabytes
Stable obj: []
Stable BCO: []
Ready for upsweep
  [NONREC
      ModSummary {
         ms_hs_date = 2017-05-22 07:07:41 UTC
         ms_mod = Main,
         ms_textual_imps = [(Nothing, Prelude)]
         ms_srcimps = []
      }]
*** Deleting temp files:
Deleting:
compile: input file panic.hs
*** Checking old interface for Main:
[1 of 1] Compiling Main             ( panic.hs, panic.o )
*** Parser [Main]:
!!! Parser [Main]: finished in 0.38 milliseconds, allocated 0.209 megabytes
*** Renamer/typechecker [Main]:
*** Deleting temp files:
Deleting:
*** Deleting temp dirs:
Deleting:
ghc: panic! (the 'impossible' happened)
  (GHC version 8.0.2 for x86_64-apple-darwin):
	get_op >>-

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

Change History (2)

comment:1 Changed 7 months ago by codebje

Duplicated in https://ghc.haskell.org/trac/ghc/ticket/13741#ticket.

The issue is not triggered if precedence and fixity are assigned:

infixl 5 >>-    -- any precedence and fixity works
newtype Cont r a = Cont { (>>-) :: (a -> r) -> r }
x = \a b c -> c >>- a . b

Other infix operators in place of . don't seem to cause the same problem, but that's not an exhaustive check!

comment:2 Changed 7 months ago by mpickering

Resolution: duplicate
Status: newclosed

I tried this and it is fixed in 8.2.1.

Note: See TracTickets for help on using tickets.