# 034: myeq.hs, myeq2.hs で matchVarCon error: ([PWildcard,PWildcard],OtherExpression (Const ("Prim.False" :>: Forall [] ([] :=> TCon (Tycon "Bool" Star))))) [↑up](bunny_notes) - issued: 2020-04-16 - 分類: A サンプルコードが fail - status: Closed (2020-05-15) ## 調査ログ ## 2020-05-15 [035](bissue035) の対処によって、myeq.sh は通るようになった。 それに加え、パターンマッチコンパイラにかける前に、 パターンにある PWildcard をコンストラクタへの引数にあるものも含め、 PVar に置き換える対処を追加: $$
{
--- a/compiler/src/TrCore.hs
+++ b/compiler/src/TrCore.hs
@@ -247,14 +247,13 @@ dsgAlts n alts@((pats,_):_) ci =
let
k = length pats
us = [Pat.mkVar n i| i <- [1..k]]
+ alts' = map (\(pats, e) -> (map wild2Var pats, e)) alts
+
+ wild2Var :: Ty.Pat -> Ty.Pat
+ wild2Var Ty.PWildcard = Ty.PVar "_"
+ wild2Var (Ty.PCon as pats) = Ty.PCon as (map wild2Var pats)
+ wild2Var pat = pat
- alts' = rmWild alts [] -- for temporary fix (#t002), see the note p.212
- rmWild [] as = reverse as
- rmWild (([Ty.PWildcard], e'):als') as =
- rmWild als' (([Ty.PVar "_"], e'):as)
- rmWild (([Ty.PWildcard,Ty.PWildcard], e'):als') as =
- rmWild als' (([Ty.PVar "_", Ty.PVar "_"], e'):as)
- rmWild (alt:als') as = rmWild als' (alt:as)
e = Pat.reduceMatch ci n k us alts' Pat.Error
in
Pat.Lambda us e
$$}
これで、myeq2.hs も通るようになった。
それぞれ、samle209, 210 とした。