From 92428681b382c173a3d29bff6322e81bc9a7e403 Mon Sep 17 00:00:00 2001 From: simonpj Date: Wed, 25 Jul 2001 13:29:07 +0000 Subject: [PATCH] [project @ 2001-07-25 13:29:07 by simonpj] --------------------------------- Fix a bug in the defn of "both" --------------------------------- This bug made the bootstrapped GHC enter an absent argument. The change is from both Lazy (Seq k Now ds) = Seq Keep Now ds to both Lazy (Seq k l ds) = Seq Keep l ds Simple, eh? (Comments with the code.) --- ghc/compiler/stranal/DmdAnal.lhs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/ghc/compiler/stranal/DmdAnal.lhs b/ghc/compiler/stranal/DmdAnal.lhs index 5f80ced..0aeea0d 100644 --- a/ghc/compiler/stranal/DmdAnal.lhs +++ b/ghc/compiler/stranal/DmdAnal.lhs @@ -693,11 +693,24 @@ both Err Bot = Err both Err Abs = Err both Err d = d -both Lazy Bot = Lazy -both Lazy Abs = Lazy -both Lazy Err = Lazy -both Lazy (Seq k Now ds) = Seq Keep Now ds -both Lazy d = d +both Lazy Bot = Lazy +both Lazy Abs = Lazy +both Lazy Err = Lazy +both Lazy (Seq k l ds) = Seq Keep l ds +both Lazy d = d + -- Notice that the Seq case ensures that we have the + -- boxed value. The equation originally said + -- both (Seq k Now ds) = Seq Keep Now ds + -- but it's important that the Keep is switched on even + -- for a deferred demand. Otherwise a (Seq Drop Now []) + -- might both'd with the result, and then we won't pass + -- the boxed value. Here's an example: + -- (x-1) `seq` (x+1, x) + -- From the (x+1, x) we get (U*(V) `both` L), which must give S*(V) + -- From (x-1) we get U(V). Combining, we must get S(V). + -- If we got U*(V) from the pair, we'd end up with U(V), and that + -- can be a disaster if a component of the data structure is absent. + -- [Disaster = enter an absent argument.] both Eval (Seq k l ds) = Seq Keep Now ds both Eval (Call d) = Call d -- 1.7.10.4