[GHC] #13257: out-of-range warnings for negative literals, without -XNegativeLiterals

#13257: out-of-range warnings for negative literals, without -XNegativeLiterals -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: feature | Status: new request | Priority: normal | Milestone: Component: Compiler | Version: 8.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- 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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13257 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13257: out-of-range warnings for negative literals, without -XNegativeLiterals -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by rwbarton): * keywords: => newcomer -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13257#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13257: out-of-range warnings for negative literals, without -XNegativeLiterals -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: ruperthorlick Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | deSugar/should_compile/T13257 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3281 Wiki Page: | -------------------------------------+------------------------------------- Changes (by ruperthorlick): * owner: (none) => ruperthorlick * testcase: => deSugar/should_compile/T13257 * differential: => Phab:D3281 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13257#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13257: out-of-range warnings for negative literals, without -XNegativeLiterals -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: ruperthorlick Type: feature request | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | deSugar/should_compile/T13257 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3281 Wiki Page: | -------------------------------------+------------------------------------- Changes (by ruperthorlick): * status: new => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13257#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13257: out-of-range warnings for negative literals, without -XNegativeLiterals
-------------------------------------+-------------------------------------
Reporter: rwbarton | Owner: ruperthorlick
Type: feature request | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version: 8.1
Resolution: | Keywords: newcomer
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
| deSugar/should_compile/T13257
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D3281
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#13257: out-of-range warnings for negative literals, without -XNegativeLiterals -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: ruperthorlick Type: feature request | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | deSugar/should_compile/T13257 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3281 Wiki Page: | -------------------------------------+------------------------------------- Comment (by monoidal): Is it correct not to warn about `-128 :: Int8` when `-XNegativeLiterals` is off? After all, without -XNegativeLiterals this means creating the overflowed integer `128 :: Int8` and only then negating it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13257#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC