Commit 218fdf92 authored by Bartosz Nitka's avatar Bartosz Nitka
Browse files

Make the order of fixities in the iface file deterministic

This normalizes the order of written fixities by sorting by
`OccName` making it independent of `Unique` order.

Test Plan: I've added a new testcase

Reviewers: austin, bgamari, simonmar

Reviewed By: simonmar

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1557

GHC Trac Issues: #4012
parent 1e041b73
......@@ -222,7 +222,11 @@ mkIface_ hsc_env maybe_old_fingerprint
nameIsLocalOrFrom this_mod name ]
-- Sigh: see Note [Root-main Id] in TcRnDriver
fixities = [(occ,fix) | FixItem occ fix <- nameEnvElts fix_env]
fixities = sortBy (comparing fst)
[(occ,fix) | FixItem occ fix <- nameEnvElts fix_env]
-- The order of fixities returned from nameEnvElts is not
-- deterministic, so we sort by OccName to canonicalize it.
-- See Note [Deterministic UniqFM] in UniqDFM for more details.
warns = src_warns
iface_rules = map coreRuleToIfaceRule rules
iface_insts = map instanceToIfaceInst $ fixSafeInstances safe_mode insts
......
{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
module ShouldCompile where
-- tests deterministic order of fixities in the interface file
infixl 1 `f`
infixr 2 \\\
infix 3 :==>
infix 4 `MkFoo`
data Foo = MkFoo Int | Float :==> Double
f :: a -> b -> a
x `f` y = x
(\\\) :: (Eq a) => [a] -> [a] -> [a]
(\\\) xs ys = xs
TOP=../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
TEST_HC_OPTS_NO_RECOMP = $(filter-out -fforce-recomp,$(TEST_HC_OPTS))
determ010:
$(RM) A.hi A.o
'$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -dinitial-unique=0 -dunique-increment=1 A.hs
$(CP) A.hi A.normal.hi
$(RM) A.hi A.o
'$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -dinitial-unique=16777215 -dunique-increment=-1 A.hs
diff A.hi A.normal.hi
test('determ010',
extra_clean(['A.o', 'A.hi', 'A.normal.hi']),
run_command,
['$MAKE -s --no-print-directory determ010'])
[1 of 1] Compiling ShouldCompile ( A.hs, A.o )
[1 of 1] Compiling ShouldCompile ( A.hs, A.o )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment