diff options
author | simonpj@microsoft.com <unknown> | 2006-09-29 13:35:12 +0000 |
---|---|---|
committer | simonpj@microsoft.com <unknown> | 2006-09-29 13:35:12 +0000 |
commit | 35d3bb34cef41053d0cb2bd03df927885b1b7d2e (patch) | |
tree | 316c14ffc6977b0e4818af67cb02a7a77148a2e0 /compiler/coreSyn | |
parent | 5bb47f66607f169cf4a03ad9450cad9025f0629e (diff) | |
download | haskell-35d3bb34cef41053d0cb2bd03df927885b1b7d2e.tar.gz |
Another correction to the (subtle) exprIsConApp_maybe
Diffstat (limited to 'compiler/coreSyn')
-rw-r--r-- | compiler/coreSyn/CoreUtils.lhs | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/compiler/coreSyn/CoreUtils.lhs b/compiler/coreSyn/CoreUtils.lhs index 27813a2320..637f66a17e 100644 --- a/compiler/coreSyn/CoreUtils.lhs +++ b/compiler/coreSyn/CoreUtils.lhs @@ -762,16 +762,21 @@ exprIsConApp_maybe (Cast expr co) -- The left-hand one must be a T, because exprIsConApp returned True -- but the right-hand one might not be. (Though it usually will.) - let (from_ty, to_ty) = coercionKind co - (from_tc, _from_tc_arg_tys) = splitTyConApp from_ty + let (from_ty, to_ty) = coercionKind co + (from_tc, from_tc_arg_tys) = splitTyConApp from_ty -- The inner one must be a TyConApp in - ASSERT( from_tc == dataConTyCon dc ) - case splitTyConApp_maybe to_ty of { Nothing -> Nothing ; - Just (to_tc, _to_tc_arg_tys) | from_tc /= to_tc -> Nothing - | otherwise -> + Just (to_tc, to_tc_arg_tys) + | from_tc /= to_tc -> Nothing + -- These two Nothing cases are possible; we might see + -- (C x y) `cast` (g :: T a ~ S [a]), + -- where S is a type function. In fact, exprIsConApp + -- will probably not be called in such circumstances, + -- but there't nothing wrong with it + + | otherwise -> let tc_arity = tyConArity from_tc @@ -804,10 +809,12 @@ exprIsConApp_maybe (Cast expr co) in ASSERT( length univ_args == tc_arity ) + ASSERT( from_tc == dataConTyCon dc ) + ASSERT( and (zipWith coreEqType [t | Type t <- univ_args] from_tc_arg_tys) ) ASSERT( all isTypeArg (univ_args ++ ex_args) ) ASSERT2( equalLength val_args arg_tys, ppr dc $$ ppr dc_tyvars $$ ppr dc_ex_tyvars $$ ppr arg_tys $$ ppr dc_args $$ ppr univ_args $$ ppr ex_args $$ ppr val_args $$ ppr arg_tys ) - Just (dc, univ_args ++ ex_args ++ new_co_args ++ new_val_args) + Just (dc, map Type to_tc_arg_tys ++ ex_args ++ new_co_args ++ new_val_args) }} exprIsConApp_maybe (Note _ expr) |