Zubin pushed to branch wip/9.12.3-backports at Glasgow Haskell Compiler / GHC

Commits:

6 changed files:

Changes:

  • libraries/base/changelog.md
    1 1
     # Changelog for [`base` package](http://hackage.haskell.org/package/base)
    
    2 2
     
    
    3
    +## 4.21.2.0 *Sept 2024*
    
    4
    +  * Fix bug where `naturalAndNot` was incorrectly truncating results ([CLC proposal #350](github.com/haskell/core-libraries-committee/issues/350))
    
    5
    +
    
    3 6
     ## 4.21.1.0 *Sept 2024*
    
    4 7
       * Fix incorrect results of `integerPowMod` when the base is 0 and the exponent is negative, and `integerRecipMod` when the modulus is zero ([#26017](https://gitlab.haskell.org/ghc/ghc/-/issues/26017)).
    
    5 8
     
    

  • libraries/ghc-bignum/changelog.md
    ... ... @@ -4,6 +4,7 @@
    4 4
     
    
    5 5
     - Expose backendName
    
    6 6
     - Add `naturalSetBit[#]` (#21173), `naturalClearBit[#]` (#21175), `naturalComplementBit[#]` (#21181)
    
    7
    +- Fix bug where `naturalAndNot` was incorrectly truncating results (#26230)
    
    7 8
     
    
    8 9
     ## 1.2
    
    9 10
     
    

  • libraries/ghc-bignum/src/GHC/Num/Natural.hs
    ... ... @@ -488,7 +488,7 @@ naturalAndNot :: Natural -> Natural -> Natural
    488 488
     {-# NOINLINE naturalAndNot #-}
    
    489 489
     naturalAndNot (NS n) (NS m) = NS (n `and#` not# m)
    
    490 490
     naturalAndNot (NS n) (NB m) = NS (n `and#` not# (bigNatToWord# m))
    
    491
    -naturalAndNot (NB n) (NS m) = NS (bigNatToWord# n `and#` not# m)
    
    491
    +naturalAndNot (NB n) (NS m) = NB (bigNatAndNotWord# n m)
    
    492 492
     naturalAndNot (NB n) (NB m) = naturalFromBigNat# (bigNatAndNot n m)
    
    493 493
     
    
    494 494
     naturalOr :: Natural -> Natural -> Natural
    

  • testsuite/tests/numeric/should_run/T26230.hs
    1
    +import Data.Bits
    
    2
    +import GHC.Num.Natural
    
    3
    +
    
    4
    +main = do
    
    5
    +  print $ naturalAndNot ((2 ^ 4) .|. (2 ^ 3)) (2 ^ 3)
    
    6
    +  print $ naturalAndNot ((2 ^ 129) .|. (2 ^ 65)) (2 ^ 65)
    
    7
    +  print $ naturalAndNot ((2 ^ 4) .|. (2 ^ 3)) ((2 ^ 65) .|. (2 ^ 3))
    
    8
    +  print $ naturalAndNot ((2 ^ 65) .|. (2 ^ 3)) (2 ^ 3)

  • testsuite/tests/numeric/should_run/T26230.stdout
    1
    +16
    
    2
    +680564733841876926926749214863536422912
    
    3
    +16
    
    4
    +36893488147419103232

  • testsuite/tests/numeric/should_run/all.T
    ... ... @@ -87,3 +87,4 @@ test('T24066', normal, compile_and_run, [''])
    87 87
     test('div01', normal, compile_and_run, [''])
    
    88 88
     test('T24245', normal, compile_and_run, [''])
    
    89 89
     test('T25653', normal, compile_and_run, [''])
    
    90
    +test('T26230', normal, compile_and_run, [''])