Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,321
    • Issues 4,321
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 359
    • Merge Requests 359
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #18619

Closed
Open
Opened Aug 29, 2020 by Sergei Trofimovich@trofiReporter

Data.Bits.shiftL should generate overflow exception for Integer operand

Summary

Data.Bits.shiftL doc says shiftL should never be called with negative value. Int instance returns an overflow exception, but Integer returns something reasonable. It's confusing to see behaviour change by slightly changing the type of a program:

GHCi, version 8.8.4: https://www.haskell.org/ghc/  :? for help
Prelude> Data.Bits.shiftL (1 :: Integer) ((-1) :: Int)
0
Prelude> Data.Bits.shiftL (1 :: Int) ((-1) :: Int)
*** Exception: arithmetic overflow

Should Integer instance also throw an exception?

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#18619