Skip to content

Warn on out-of-range literals in pattern matches too

We have these nice warnings for numeric literal expressions that are out of range of their type:

Prelude> 100000000000000000000000000000000 :: Int

<interactive>:1:1: warning: [-Woverflowed-literals]
    Literal 100000000000000000000000000000000 is out of the Int range -9223372036854775808..9223372036854775807

but nothing for numeric patterns:

Prelude> (\x -> case (x :: Int) of 100000000000000000000000000000000 -> 0) 8 :: Int

<interactive>:3:8: warning: [-Wincomplete-patterns]
    Pattern match(es) are non-exhaustive
    In a case alternative:
        Patterns not matched:
            p where p is not one of {100000000000000000000000000000000}
*** Exception: <interactive>:3:8-64: Non-exhaustive patterns in case
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
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information