Skip to content

Commit

Permalink
The Hashable instance for Name should only depend on the unique (#5714)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpj authored Jan 12, 2024
1 parent 09aa41a commit 607c501
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion plutus-core/plutus-core/src/PlutusCore/Name.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ data Name = Name
-- ^ A 'Unique' assigned to the name, allowing for cheap comparisons in the compiler.
}
deriving stock (Show, Generic, Lift)
deriving anyclass (NFData, Hashable)
deriving anyclass (NFData)

-- | Allowed characters in the starting position of a non-quoted identifier.
isIdentifierStartingChar :: Char -> Bool
Expand Down Expand Up @@ -118,6 +118,10 @@ instance Eq Name where
instance Ord Name where
(<=) = (<=) `on` _nameUnique

-- Hashable follows Eq and Ord in only depending on the unique
instance Hashable Name where
hashWithSalt s = hashWithSalt s . _nameUnique

-- | A unique identifier
newtype Unique = Unique {unUnique :: Int}
deriving stock (Eq, Show, Ord, Lift)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ program
(addInteger cse))
(addInteger cse))
(addInteger cse))
(case cse [(\x y z w -> z)]))
(case cse [(\x y z w -> x)]))
(case cse [(\x y z w -> w)]))
(case cse [(\x y z w -> y)]))
(case cse [(\x y z w -> w)]))
(case cse [(\x y z w -> y)]))
(case cse [(\x y z w -> z)]))
(case cse [(\x y z w -> x)]))
(\x y -> addInteger x y))
(\x y ->
force ifThenElse
Expand Down

0 comments on commit 607c501

Please sign in to comment.