Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,251
    • Issues 5,251
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 583
    • Merge requests 583
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #20066
Closed
Open
Issue created Jul 01, 2021 by Sylvain Henry@hsyl20Developer

Rule "fromIntegral/Int->Natural" is inconsistent

As noticed by @trac-vdukhovni in #20062 (comment 362750):

import GHC.Natural

i :: Int
i = -10

main :: IO ()
main = let n :: Natural
           n = fromIntegral i
        in print n
  • with -O2: prints 18446744073709551606
  • with -O0: throw "arithmetic underflow"

While it should always throw an exception (I guess? "fromIntegral" isn't precisely defined in the report).

GHC versions: 9.0, 9.2, HEAD

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking