From: simonmar Date: Thu, 2 Aug 2001 16:05:06 +0000 (+0000) Subject: [project @ 2001-08-02 16:05:06 by simonmar] X-Git-Tag: Approximately_9120_patches~1375 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=89cb459ac5c7b1606f835f0170bd08decb1ef795;p=ghc-hetmet.git [project @ 2001-08-02 16:05:06 by simonmar] Fix something that looks wrong in an attempt to get HEAD back on the rails again, whilst trying to get the award for the highest size-of-commit-message-to-number-of-lines-actually-changed ratio. The problem is this: a constructor defined as data T = A !Int will cause a DataCon wrapper to be generated like this: A = \x -> case x of x' { DEFAULT -> $wA x' } but the strictness on $wA says that it is strict in its first field. This is where the story gets a little hazy, but it seems that the compiler (5.00.2) happily removes the extra case thinking that x is going to get evaluated anyway, leaving us with A = \x -> $wA x and the argument to A ends up not being evaluated at all. Certain other parts of the compiler make use of the evaluatedness of fields in order to remove unnecessary cases, with the end result that we end up trying to dataToTag# an unevaluated thing, and certain derived Eq instances can give wrong results. Phew. Now, here's the bit I *don't* understand: I can only see the bug with 5.00.2, and only when the data type has more than one constructor: data T = A !Int | B nevertheless, the HEAD compiler when bootstrapped displays symptoms of a broken Eq instance, so I'm trying this fix to see if it helps. The Attempted Fix: give the DataConId a fully-lazy strictness signature. --- diff --git a/ghc/compiler/basicTypes/MkId.lhs b/ghc/compiler/basicTypes/MkId.lhs index 761eef8..f3c8de5 100644 --- a/ghc/compiler/basicTypes/MkId.lhs +++ b/ghc/compiler/basicTypes/MkId.lhs @@ -148,7 +148,7 @@ mkDataConId work_name data_con `setNewStrictnessInfo` Just strict_sig arity = dataConRepArity data_con - strict_sig = mkStrictSig id arity (mkTopDmdType (dataConRepStrictness data_con) cpr_info) + strict_sig = mkStrictSig id arity (mkTopDmdType (replicate arity topDmd) cpr_info) tycon = dataConTyCon data_con cpr_info | isProductTyCon tycon &&