Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#10689 closed bug (fixed)

compiling singletons-1.1.2.1 as -O1 -fspec-constr fails as 'Template variable unbound in rewrite rule'

Reported by: slyfox Owned by:
Priority: high Milestone: 7.10.3
Component: Compiler Version: 7.10.2-rc2
Keywords: Cc: simonpj, goldfire
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: simplCore/should_compile/T10689, T10689a
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

First observed on singletons-1.1.2.1 package ghc-7.10.2.

I've tried to distill it down to a single file.

The file manages to crash both GHC and GHCi.

GHCi:

$ inplace/bin/ghc-stage2 -hide-all-packages -package=base --interactive List.hs
GHCi, version 7.11.20150723: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling List             ( List.hs, interpreted )
ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 7.11.20150723 for x86_64-unknown-linux):
        floatExpr tick break<2>()

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

GHC:

$ inplace/bin/ghc-stage2 -hide-all-packages -package=base --make List.hs -dsuppress-all -dsuppress-uniques
[1 of 1] Compiling List             ( List.hs, List.o )
ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 7.11.20150723 for x86_64-unknown-linux):
        Template variable unbound in rewrite rule
  m
  [a_afdP, x, m, ipv, ipv, sc, sc, sc, sg]
  [a_afdP, x, m, ipv, ipv, sc, sc, sc, sg]
  [TYPE a_afdP, TYPE x, TYPE Let1627448493XsSym4 x m ipv ipv, sc,
   (SCons @~ ... sc sc) `cast` ...]
  [TYPE a_afdP, TYPE x, TYPE Let1627448493XsSym4 x ipv ipv ipv, sc,
   (SCons @~ ... ipv ipv) `cast` ...]

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

The "minimal" single-file sample is attached.

If you need original selfcontained reproducer (79 modules, template haskell code) this is the version i've started with: http://code.haskell.org/~slyfox/unbound-template-var.tar.gz Adjusting path to GHC in ./trigger-a-bug.bash should be enough.

Attachments (1)

List.hs (4.0 KB) - added by slyfox 4 years ago.
a tiny part of singletons-1.1.2.1/src/Data/Singletons/Prelude/List.hs required to trigger a bug

Download all attachments as: .zip

Change History (9)

Changed 4 years ago by slyfox

Attachment: List.hs added

a tiny part of singletons-1.1.2.1/src/Data/Singletons/Prelude/List.hs required to trigger a bug

comment:1 Changed 4 years ago by goldfire

Milestone: 7.10.2
Priority: normalhigh

Bumping priority, as these sorts of bugs regularly get reported to me. But there's an easy workaround, so this certainly shouldn't be "highest".

comment:2 Changed 4 years ago by goldfire

Confirmed reproducible on the 7.10 tip, and in a recent HEAD.

comment:3 Changed 4 years ago by hvr

Milestone: 7.10.27.10.3

(milestone:7.10.2 is effectively closed; we're way past the RC-phase, we have all binary dists built and tested, the Git commit has been signed, ...)

comment:4 Changed 4 years ago by simonpj

I'm on this.

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

In 4e8d74d/ghc:

Deal with phantom type variables in rules

See Note [Unbound template type variables] in Rules.hs
This fixes Trac #10689.

The problem was a rule LHS that mentioned a type variable
in a phantom argument to a type synonym.  Then matching the
LHS didn't bind the type variable, and the rule matcher
complained.

This patch fixes the problem, as described by the Note.

I also went back to not-cloning the template varaibles during
rule matching.  I'm convinced that it's not necessary now
(if it ever was), and cloning makes the fix for #10689 much more
fiddly.

comment:6 Changed 4 years ago by simonpj

Status: newmerge
Test Case: simplCore/should_compile/T10689, T10689a

Fixed.

We could merge to 7.10.3 I guess, so I'll set it to 'merge'. It's not an entirely trivial fix, so I'm a bit inclined not to, though.

Simon

comment:7 Changed 4 years ago by bgamari

This has been merged to ghc-7.10.

Last edited 4 years ago by bgamari (previous) (diff)

comment:8 Changed 4 years ago by bgamari

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