@@ -273,7 +273,7 @@ buildArgs : {auto c : Ref Ctxt Defs} ->
273273 -- (because a previous case matches)
274274 List ClosedTerm -> -- ^ arguments, with explicit names
275275 CaseTree vars -> Core (List (List ClosedTerm ))
276- buildArgs fc defs known not ps cs@(Case {name = var} idx el ty altsIn)
276+ buildArgs fc defs known not ps cs@(Case idx el ty altsIn)
277277 -- If we've already matched on 'el' in this branch, restrict the alternatives
278278 -- to the tag we already know. Otherwise, add missing cases and filter out
279279 -- the ones it can't possibly be (the 'not') because a previous case
@@ -293,20 +293,21 @@ buildArgs fc defs known not ps cs@(Case {name = var} idx el ty altsIn)
293293 buildArgAlt not ' (ConCase n t args sc)
294294 = do let l = mkSizeOf args
295295 let con = Ref fc (DataCon t (size l)) n
296- let ps' = map (substName var
296+ let ps' = map (substName (nameAt el)
297297 (apply fc
298298 con (map (Ref fc Bound ) args))) ps
299299 buildArgs fc defs (weakenNs l ((MkVar el, t) :: known))
300300 (weakenNs l not ') ps' sc
301301 buildArgAlt not ' (DelayCase t a sc)
302302 = let l = mkSizeOf [t, a]
303- ps' = map (substName var (TDelay fc LUnknown
303+ ps' = map (substName (nameAt el)
304+ (TDelay fc LUnknown
304305 (Ref fc Bound t)
305306 (Ref fc Bound a))) ps in
306307 buildArgs fc defs (weakenNs l known) (weakenNs l not ')
307308 ps' sc
308309 buildArgAlt not ' (ConstCase c sc)
309- = do let ps' = map (substName var (PrimVal fc c)) ps
310+ = do let ps' = map (substName (nameAt el) (PrimVal fc c)) ps
310311 buildArgs fc defs known not ' ps' sc
311312 buildArgAlt not ' (DefaultCase sc)
312313 = buildArgs fc defs known not ' ps sc
0 commit comments