out-of-range warnings for negative literals, without -XNegativeLiterals
By default (without NegativeLiterals
) a negated literal -1
is desugared as negate (fromInteger 1)
. Hence the existing out-of-range literal warning doesn't trigger for -1 :: Word
. But we could also recognize the pattern negate (fromInteger lit)
, and give a warning when -lit
is out-of-range (for Word
, this is whenever lit
is positive).
Actually this could apply to signed integer types too: if we recognized negate (fromInteger lit)
in preference to fromInteger lit
, we could correctly not warn about -128 :: Int8
, even when NegativeLiterals
is not enabled.
Trac metadata
Trac field | Value |
---|---|
Version | 8.1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |