[project @ 2000-12-19 14:19:24 by simonmar]
authorsimonmar <unknown>
Tue, 19 Dec 2000 14:19:24 +0000 (14:19 +0000)
committersimonmar <unknown>
Tue, 19 Dec 2000 14:19:24 +0000 (14:19 +0000)
The CafInfo on a record selector may in fact need to be
MayHaveCafRefs, if the record selector in question has a default
failure case that calls recSelError.

Thanks to the ASSERT in SRT.lhs, this was caught before it could do
any real damage.

ghc/compiler/basicTypes/MkId.lhs

index 45f4f00..0676935 100644 (file)
@@ -429,7 +429,7 @@ mkRecordSelId tycon field_label unpack_id unpackUtf8_id
                   mkFunTy data_ty field_tau
       
     arity = 1 + n_dict_tys + n_field_dict_tys
-    info = mkIdInfo (RecordSelId field_label) NoCafRefs
+    info = mkIdInfo (RecordSelId field_label) caf_info
           `setArityInfo`       exactArity arity
           `setUnfoldingInfo`   unfolding       
            `setTyGenInfo`      TyGenNever
@@ -445,8 +445,14 @@ mkRecordSelId tycon field_label unpack_id unpackUtf8_id
 
     alts      = map mk_maybe_alt data_cons
     the_alts  = catMaybes alts
-    default_alt | all isJust alts = [] -- No default needed
-               | otherwise       = [(DEFAULT, [], error_expr)]
+
+    no_default = all isJust alts       -- No default needed
+    default_alt | no_default = []
+               | otherwise  = [(DEFAULT, [], error_expr)]
+
+       -- the default branch may have CAF refs, because it calls recSelError etc.
+    caf_info    | no_default = NoCafRefs
+               | otherwise  = MayHaveCafRefs
 
     sel_rhs = mkLams tyvars   $ mkLams field_tyvars $ 
              mkLams dict_ids $ mkLams field_dict_ids $