Bad interaction between Pattern Synonyms and Text
Compiling this file causes the impossible to happen. It is necessary to enable optimizations. The bug did not occur if the Text parameter was replaced with ByteString or String.
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE OverloadedStrings #-}
module Bug where
{-
- Must compile with optimizations
-
- text-1.1.1.3
- ghc-7.8.2
- Both Darwin and Linux platforms
-
-}
import Data.Text(Text)
data T = C Text Bool
f :: a -> b
f _ = undefined
{-# NOINLINE f #-} -- important
pattern P1 a = C "sh" a -- at least two characters
pattern P2 = C "x" True -- this pattern has to come last
g :: Text -> T
g x = case x of
"" -> f (P1 undefined) -- this has to be a pattern synonym
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghc: panic! (the 'impossible' happened)
(GHC version 7.8.2 for x86_64-apple-darwin):
StgCmmEnv: variable not found
lvl_s2Jr{v} [lid]
local binds for:
main:Bug.f{v rBS} [gid]
main:Bug.rewriteRule{v rBV} [gid]
main:Bug.$mP2{v r17q} [gid]
main:Bug.$WP2{v r17A} [gid]
main:Bug.$mP1{v r17E} [gid]
main:Bug.$WP1{v r17R} [gid]
main:Bug.$WP3{v r3bq} [gid]
main:Bug.$WP4{v r3ua} [gid]
main:Bug.$WP5{v r3ub} [gid]
main:Bug.$WP2_dt{v r3uc} [gid]
main:Bug.$WP6{v r3ud} [gid]
main:Bug.$WP7{v r3ue} [gid]
main:Bug.$WP8{v r3uf} [gid]
main:Bug.$w$mP1{v r3ug} [gid]
main:Bug.$w$mP2{v r3uh} [gid]
main:Bug.$mP3{v r3ui} [gid]
main:Bug.$mP4{v r3uj} [gid]
main:Bug.$mP5{v r3uk} [gid]
main:Bug.$wrewriteRule{v r3ul} [gid]
main:Bug.rewriteRule1{v r3um} [gid]
main:Bug.rewriteRule2{v r3un} [gid]
main:Bug.rewriteRule3{v r3uo} [gid]
main:Bug.rewriteRule4{v r3up} [gid]
main:Bug.rewriteRule5{v r3uq} [gid]
lvl{v r3ur} [gid]
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
Trac metadata
Trac field | Value |
---|---|
Version | 7.8.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | bos@serpentine.com, diatchki@gmail.com |
Operating system | |
Architecture |