@@ -625,10 +625,15 @@ elabClause info tcgen (_, PWith fc fname lhs_in withs wval_in withblock)
625625 return $ PWith fc wname lhs ws wval withs'
626626
627627 updateLHS n wname mvars ns (PApp fc (PRef fc' n') args) w
628− = return $ substMatches mvars $
629− PApp fc (PRef fc' wname) (map (pexp . (PRef fc')) ns ++ [pexp w])
628+ = let ns' = map (keepMvar (map fst mvars) fc') ns in
629+ return $ substMatches mvars $
630+ PApp fc (PRef fc' wname)
631+ (map pexp ns' ++ [pexp w])
630632 updateLHS n wname mvars ns tm w = fail $ "Not implemented match " ++ show tm
631633
634+ keepMvar mvs fc v | v `elem` mvs = PRef fc v
635+ | otherwise = Placeholder
636+
632637 fullApp (PApp _ (PApp fc f args) xs) = fullApp (PApp fc f (args ++ xs))
633638 fullApp x = x
634639