exprIsConApp_maybe should deal better with strings
Consider
x :: Addr#
x = "foo"#
y = case unpackCString# x of
[] -> ...
(x:xs) -> ...
exprIsConApp_maybe has a special case for literal strings; see Note [exprIsConApp_maybe on literal strings] in CoreSubst. But it only works if unpackCString# is applied to a literal, not to a variable bound to a literal (like x).
The fix is easy. Instead of this code
, [Lit (MachStr str)] <- args
= dealWithStringLiteral fun str co
we want to use exprIsLiteral_maybe, thus
, Just (MachStr str) <- exprIsLiteral_maybe ... arg
= dealWithStringLiteral fun str co
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |