[GHC] #14532: Missing constant folding for Numeric.Natural

#14532: Missing constant folding for Numeric.Natural -------------------------------------+------------------------------------- Reporter: reinerp | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.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: -------------------------------------+------------------------------------- The following Haskell code {{{#!hs module Zero where import Numeric.Natural zero :: Natural zero = 0 }}} generates this Core: {{{#!hs -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} zero1 zero1 = 0 -- RHS size: {terms: 39, types: 12, coercions: 0, joins: 0/0} zero zero = case zero1 of { S# i#_a2c6 -> case tagToEnum# (>=# i#_a2c6 0#) of { False -> underflowError; True -> NatS# (int2Word# i#_a2c6) }; Jp# dt_a2cg -> case uncheckedIShiftRL# (sizeofByteArray# dt_a2cg) 3# of { __DEFAULT -> case sizeofByteArray# dt_a2cg of { __DEFAULT -> NatJ# dt_a2cg; 0# -> underflowError }; 1# -> case indexWordArray# dt_a2cg 0# of wild2_a2ck { __DEFAULT -> NatS# wild2_a2ck } }; Jn# ipv_a2cn -> underflowError } }}} It should instead generate this: {{{#!hs zero = NatS# 0## }}} This kind of code is generated whenever one uses `GHC.TypeLits.natVal`, even at a constant `Nat`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14532 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14532: Missing constant folding for Numeric.Natural -------------------------------------+------------------------------------- Reporter: reinerp | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #14170 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => closed * resolution: => duplicate * related: => #14170 Comment: Thanks for the bug report. This is a duplicate of #14170, so I'll close this ticket in favor of that one. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14532#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC