panic on unboxed string literal in pattern
I don't think this program is meaningful, but it shouldn't cause a panic.
{-# LANGUAGE MagicHash #-}
g y = case y of
"a"# -> True
_ -> False
[1 of 1] Compiling CaseOnString ( x/CaseOnString.hs, x/CaseOnString.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.0.1 for x86_64-unknown-linux):
litValue "a"#
The panic is also in at least 7.8, 7.10, and HEAD.
"a"#
has type Addr#
, and I suppose that if we allow case
on Addr#
then it ought to use pointer equality. But the literal "a"#
has no particular address, so matching against it in a case
doesn't make sense. So I think we should just disallow unboxed string literals as patterns.
Trac metadata
Trac field | Value |
---|---|
Version | 8.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |