Commit 786d528e authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari
Browse files

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
parent b20a65d5
......@@ -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)
......
......@@ -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 ):
......
......@@ -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
......
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##
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