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,391
    • Issues 4,391
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 373
    • Merge Requests 373
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #19654

Closed
Open
Opened Apr 06, 2021 by Divam Narula@dfordivamDeveloper

Semigroup instance of UniqDFM is wrong (not associative)

Summary

This is a very minor issue in code which possibly only a GHC dev can hit.

plusUDFM is incorrect, as the behavior of replacing the values of duplicate keys is dependent on the size of UniqDFMs being merged.

instance Semi.Semigroup (UniqDFM key a) where (<>) = plusUDFM

plusUDFM :: UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
plusUDFM udfml@(UDFM _ i) udfmr@(UDFM _ j)
  -- we will use the upper bound on the tag as a proxy for the set size,
  -- to insert the smaller one into the bigger one
  | i > j = insertUDFMIntoLeft udfml udfmr
  | otherwise = insertUDFMIntoLeft udfmr udfml

A possible solution could be to use insertUDFMIntoLeft, but not sure if it would work correctly. Just documenting this as I hit it myself.

Steps to reproduce

Please provide a set of concrete steps to reproduce the issue.

Expected behavior

What do you expect the reproducer described above to do?

Environment

  • GHC version used:

Optional:

  • Operating System:
  • System Architecture:
Edited Apr 06, 2021 by Divam Narula
Assignee
Assign to
9.4.1
Milestone
9.4.1
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#19654