Opened 3 years ago

Closed 3 years ago

#13244 closed bug (fixed)

Error Dealing with Unboxed Types and Type Families

Reported by: sgschlesinger Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.0.1
Keywords: LevityPolymorphism Cc:
Operating System: Linux Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: indexed-types/should_compile/T13244
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Hello, I was playing with unboxed types and this happened:

[2 of 2] Compiling Data.Unbox ( Data/Unbox.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/Data/Unbox.o ) ghc: panic! (the 'impossible' happened)

(GHC version 8.0.1 for x86_64-unknown-linux):

pprIfaceCo

I will attach the relevant file.

Attachments (2)

Unbox.hs (624 bytes) - added by sgschlesinger 3 years ago.
The relevant code
lint-errors.txt (6.0 KB) - added by sgschlesinger 3 years ago.
lint errors from "stack build --ghc-options -dcore-lint

Download all attachments as: .zip

Change History (10)

Changed 3 years ago by sgschlesinger

Attachment: Unbox.hs added

The relevant code

comment:1 Changed 3 years ago by simonpj

Can you explain how to provoke the error? I tried

ghc -c T13244.hs

and all was well. (But I may not have used exactly the version that you did..)

Probably a dup of #12242

Changed 3 years ago by sgschlesinger

Attachment: lint-errors.txt added

lint errors from "stack build --ghc-options -dcore-lint

comment:2 Changed 3 years ago by sgschlesinger

I'm using stack with resolver lts-7.19 which uses ghc 8.0.1. I ran stack build --ghc-options -dcore-lint and got quite the atrocious output which I will attach to the issue. The error I got originally was from a dup of #12242 almost certainly, but could the -dcore-lint errors have been caused by that?

comment:3 Changed 3 years ago by simonpj

Could you provoke it with an invocation of GHC, not via stack? One less indirection.

comment:4 Changed 3 years ago by sgschlesinger

Yes, here is the relevant session:

samuel@computer:~/Documents/lower/Data$ ghc Unbox.hs -XMagicHash -XDataKinds -XTypeInType -XTypeFamilies
[1 of 1] Compiling Data.Unbox       ( Unbox.hs, Unbox.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 8.0.2 for x86_64-unknown-linux):
	kindPrimRep.go Rep Int

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

comment:5 Changed 3 years ago by sgschlesinger

Behaviors to note: if I set "box = undefined", the code will compile but still have type errors when run with -dcore-lint, whereas if I set "unbox = undefined" the message is still the same.

comment:6 Changed 3 years ago by simonpj

Keywords: LevityPolymorphism added; pprIfaceCo removed

OK I can reproduce this. It fails with a Lint error in the GHC 8.0 branch:

*** Core Lint errors : in result of Tidy Core ***
<no location info>: warning:
    In the type ‘Unboxed x_aws[sk] -> x_aws[sk]’
    Ill-kinded argument
      in type or kind ‘Unboxed x_aws[sk] -> x_aws[sk]’
    type or kind ‘Unboxed x_aws[sk] -> x_aws[sk]’ kind: TYPE
                                                          (Rep x_aws[sk])
<no location info>: warning:
    In the type ‘Unboxed x_aws[sk] -> x_aws[sk]’
    Ill-kinded argument
      in type or kind ‘Unboxed x_aws[sk] -> x_aws[sk]’
    type or kind ‘Unboxed x_aws[sk] -> x_aws[sk]’ kind: TYPE
                                                          (Rep x_aws[sk])
<no location info>: warning:
    In the type ‘Unboxed x_aws[sk] -> x_aws[sk]’
    Ill-kinded argument
      in type or kind ‘Unboxed x_aws[sk] -> x_aws[sk]’
    type or kind ‘Unboxed x_aws[sk] -> x_aws[sk]’ kind: TYPE
                                                          (Rep x_aws[sk])
<no location info>: warning:
    In the type ‘forall x_aws[sk].
                 Unbox x_aws[sk] =>
                 Unboxed x_aws[sk] -> x_aws[sk]’
    Ill-kinded argument
      in type or kind ‘Unboxed x_aws[sk] -> x_aws[sk]’
    type or kind ‘Unboxed x_aws[sk] -> x_aws[sk]’ kind: TYPE
                                                          (Rep x_aws[sk])
*** Offending Program ***

But the recent round of improvements to levity polymorphism make this OK in HEAD (and hence in 8.2). I'll add a regression test.

comment:7 Changed 3 years ago by Simon Peyton Jones <simonpj@…>

In fed7136/ghc:

Test Trac #13244

comment:8 Changed 3 years ago by simonpj

Resolution: fixed
Status: newclosed
Test Case: indexed-types/should_compile/T13244
Note: See TracTickets for help on using tickets.