Opened 4 years ago

Closed 4 years ago

#10934 closed bug (fixed)

Iface type variable out of scope

Reported by: mjmrotek Owned by:
Priority: high Milestone: 7.10.3
Component: Compiler Version: 7.10.2
Keywords: interface Cc:
Operating System: Linux Architecture: Unknown/Multiple
Type of failure: Compile-time crash Test Case: polykinds/T10934
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

I'm sorry for spamming code and not providing a distilled example, but honestly I have no idea how to even begin pinpointing this.

I'm writing a library and hosting it on Github: https://github.com/marcinmrotek/pipes-key-value-csv which compiles fine, but when I try to compile the test suite, GHC crashes with this error message:

/home/marcin/haskell/pipes-key-value-csv/.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/Pipes/KeyValueCsv/Internal/KeyValue.hi
Declaration for $fFromKeyValuesf:3:
  Iface type variable out of scope:  k
Cannot continue after interface file error

when I uncomment the

. KV.foldHeader

line in https://github.com/marcinmrotek/pipes-key-value-csv/blob/master/test/Test/KeyValue.hs

The thing is, this function does not even use the "FromKeyValues" type class mentioned - https://github.com/marcinmrotek/pipes-key-value-csv/blob/master/src/Pipes/KeyValueCsv/Internal/KeyValue.hs

KV.parseLine, which does, compiles fine (the test suite runs and fails with "Prelude: undefined". They're both defined here: https://github.com/marcinmrotek/pipes-key-value-csv/blob/master/src/Pipes/KeyValueCsv/KeyValue.hs

I've tried "stack clean", reinstalling both GHC and stack, installing my package globally with cabal-install (although I had to fix the validation-0.5.1 package by removing the Safe pragma; I've tried to use stack again, pointing it to the exact same code for validation-0.5.1, to no avail), the result is always the same - the library compiles, the test suite doesn't.

Attachments (4)

keyvalue.cabal (226 bytes) - added by thomie 4 years ago.
KeyValue.hs (621 bytes) - added by thomie 4 years ago.
Vinyl.hs (453 bytes) - added by thomie 4 years ago.
T10934.hs (631 bytes) - added by thomie 4 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 4 years ago by thomie

Similar bugs were closed because of lack of reproducability (#9584, #7958), but I can reproduce your problem.

I used the following tools:

Changed 4 years ago by thomie

Attachment: keyvalue.cabal added

Changed 4 years ago by thomie

Attachment: KeyValue.hs added

Changed 4 years ago by thomie

Attachment: Vinyl.hs added

Changed 4 years ago by thomie

Attachment: T10934.hs added

comment:2 Changed 4 years ago by thomie

Priority: normalhigh

Reproducible with HEAD (ghc-7.11.20151002), see attachments. The cabal file doesn't pull in any dependencies.

$ cabal configure
...

$ cabal build
Building keyvalue-0.0.0.0...
Preprocessing library keyvalue-0.0.0.0...
[1 of 2] Compiling Vinyl            ( Vinyl.hs, dist/build/Vinyl.o )
[2 of 2] Compiling KeyValue         ( KeyValue.hs, dist/build/KeyValue.o )
In-place registering keyvalue-0.0.0.0...

$ ghc -package-db dist/package.conf.inplace -O -fforce-recomp -c T10934.hs
/home/thomas/T10934/dist/build/KeyValue.hi
Declaration for missing1:
  Iface type variable out of scope:  k
Cannot continue after interface file error

Note that the cabal build step is needed to trigger the bug. Running ghc --make -O -outputdir=/tmp -fforce-recomp T10934.hs works fine.

Compiling KeyValue.hs with -dcore-lint results in Core Lint errors:

$ ghc -O -outputdir=/tmp -dcore-lint -fforce-recomp KeyValue.hs
[1 of 2] Compiling Vinyl            ( Vinyl.hs, /tmp/Vinyl.o )
[2 of 2] Compiling KeyValue         ( KeyValue.hs, /tmp/KeyValue.o )
*** Core Lint errors : in result of Simplifier ***
KeyValue.hs:20:19: Warning:
    [in body of lambda with binder f_aBJ :: k_aBI -> *]
    @ (k_aBI :: BOX) is out of scope

Commenting out the PolyKinds extension in KeyValue.hs makes the bug go away.

comment:3 Changed 4 years ago by simonpj

Very good! Patch coming.

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

In 0e169a8b/ghc:

Fix kind-var abstraction in SimplUtils.abstractFloats

A missing 'closeOverKinds' triggered Trac #10934.
Happily the fix is simple.

Merge to 7.10.3

comment:5 Changed 4 years ago by simonpj

Milestone: 7.10.3
Status: newmerge
Test Case: polykinds/T10934

comment:6 Changed 4 years ago by mjmrotek

Thanks! Just for the record, in case someone runs into a similar problem: a "workaround" for this bug in the particular case I've posted was just to remove the offending type class, as its method can be implemented by just having a regular function pattern match on Rec.

comment:7 Changed 4 years ago by bgamari

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