diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2015-12-16 21:09:54 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-12-17 12:11:03 +0100 |
commit | 786d528e8f949daeb62d34e0daa5e35f642065fc (patch) | |
tree | eb4c6fe1821c62a965a0f1dfc957d3a1fcea0645 | |
parent | b20a65d5bf0ebf656c67f57e9b2c1094b459b827 (diff) | |
download | haskell-786d528e8f949daeb62d34e0daa5e35f642065fc.tar.gz |
TcTypeable: Don't use bogus fingerprints when suppress-uniques is enabled
Previously the Typeable implementation would intentionally create TyCon
representations with bogus fingerprints to avoid fingerprints (which may
change often) from leaking into test output. As pointed out by Richard
in #10376 this is very bad as simply enabling a debug flag,
`-dsuppress-uniques`, completely breaks the soundness of `Typeable`!
This patch removes this behavior and replaces it with logic in the
testsuite driver to filter out spurious changes due to Typeable
representations.
Test Plan: Validate
Reviewers: austin, simonpj, goldfire
Reviewed By: goldfire
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1629
GHC Trac Issues: #10376
-rw-r--r-- | compiler/typecheck/TcTypeable.hs | 4 | ||||
-rw-r--r-- | testsuite/driver/testlib.py | 9 | ||||
-rw-r--r-- | testsuite/tests/simplCore/should_compile/Makefile | 3 | ||||
-rw-r--r-- | testsuite/tests/simplCore/should_compile/T8274.stdout | 8 |
4 files changed, 16 insertions, 8 deletions
diff --git a/compiler/typecheck/TcTypeable.hs b/compiler/typecheck/TcTypeable.hs index c951387861..032ff79cbf 100644 --- a/compiler/typecheck/TcTypeable.hs +++ b/compiler/typecheck/TcTypeable.hs @@ -194,9 +194,7 @@ mkTyConRepBinds (dflags, mod_expr, pkg_str, mod_str, tr_datacon, trn_datacon) ty hashThis :: String hashThis = unwords [pkg_str, mod_str, tycon_str] - Fingerprint high low - | gopt Opt_SuppressUniques dflags = Fingerprint 0 0 - | otherwise = fingerprintString hashThis + Fingerprint high low = fingerprintString hashThis word64 :: Word64 -> HsLit word64 | wORD_SIZE dflags == 4 = \n -> HsWord64Prim (show n) (toInteger n) diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py index c41bb8cb65..4e9a1fbfa4 100644 --- a/testsuite/driver/testlib.py +++ b/testsuite/driver/testlib.py @@ -1691,12 +1691,20 @@ def normalise_callstacks(str): # Ignore line number differences in call stacks (#10834). return re.sub(', called at (.+):[\\d]+:[\\d]+ in [\\w\-\.]+:', repl, str) +def normalise_type_reps(str): + """ Normalise out fingerprints from Typeable TyCon representations """ + return re.sub(r'TyCon\s*\d+\#\#\s*\d+\#\#\s*', + 'TyCon FINGERPRINT FINGERPRINT ', + str, + flags=re.MULTILINE) + def normalise_errmsg( str ): # remove " error:" and lower-case " Warning:" to make patch for # trac issue #10021 smaller str = modify_lines(str, lambda l: re.sub(' error:', '', l)) str = modify_lines(str, lambda l: re.sub(' Warning:', ' warning:', l)) str = normalise_callstacks(str) + str = normalise_type_reps(str) # If somefile ends in ".exe" or ".exe:", zap ".exe" (for Windows) # the colon is there because it appears in error messages; this @@ -1766,6 +1774,7 @@ def normalise_output( str ): # This can occur in error messages generated by the program. str = re.sub('([^\\s])\\.exe', '\\1', str) str = normalise_callstacks(str) + str = normalise_type_reps(str) return str def normalise_asm( str ): diff --git a/testsuite/tests/simplCore/should_compile/Makefile b/testsuite/tests/simplCore/should_compile/Makefile index a804768fa3..87b1d95c3d 100644 --- a/testsuite/tests/simplCore/should_compile/Makefile +++ b/testsuite/tests/simplCore/should_compile/Makefile @@ -14,7 +14,8 @@ T11155: T8274: $(RM) -f T8274.o T8274.hi - '$(TEST_HC)' $(TEST_HC_OPTS) -O -c -ddump-simpl -dsuppress-uniques T8274.hs | grep '#' + # Set -dppr-cols to ensure things don't wrap + '$(TEST_HC)' $(TEST_HC_OPTS) -O -c -ddump-simpl -dsuppress-uniques -dppr-cols=200 T8274.hs | grep '#' T7865: $(RM) -f T7865.o T7865.hi diff --git a/testsuite/tests/simplCore/should_compile/T8274.stdout b/testsuite/tests/simplCore/should_compile/T8274.stdout index 269f4e73f6..05a0069720 100644 --- a/testsuite/tests/simplCore/should_compile/T8274.stdout +++ b/testsuite/tests/simplCore/should_compile/T8274.stdout @@ -1,12 +1,12 @@ T8274.$trModule2 = GHC.Types.TrNameS "main"# T8274.$trModule1 = GHC.Types.TrNameS "T8274"# T8274.$tc'Positives1 = GHC.Types.TrNameS "'Positives"# - GHC.Types.TyCon 0## 0## T8274.$trModule T8274.$tc'Positives1 +T8274.$tc'Positives = GHC.Types.TyCon 14732531009298850569## 4925356269917933860## T8274.$trModule T8274.$tc'Positives1 T8274.$tcP1 = GHC.Types.TrNameS "P"# -T8274.$tcP = GHC.Types.TyCon 0## 0## T8274.$trModule T8274.$tcP1 +T8274.$tcP = GHC.Types.TyCon 11095028091707994303## 9476557054198009608## T8274.$trModule T8274.$tcP1 T8274.$tc'Negatives1 = GHC.Types.TrNameS "'Negatives"# - GHC.Types.TyCon 0## 0## T8274.$trModule T8274.$tc'Negatives1 +T8274.$tc'Negatives = GHC.Types.TyCon 15950179315687996644## 11481167534507418130## T8274.$trModule T8274.$tc'Negatives1 T8274.$tcN1 = GHC.Types.TrNameS "N"# -T8274.$tcN = GHC.Types.TyCon 0## 0## T8274.$trModule T8274.$tcN1 +T8274.$tcN = GHC.Types.TyCon 7479687563082171902## 17616649989360543185## T8274.$trModule T8274.$tcN1 p = T8274.Positives 42# 4.23# 4.23## '4'# 4## n = T8274.Negatives -4# -4.0# -4.0## |