Skip to content

Commit e087036

Browse files
christiaanbmartijnbastiaan
authored andcommitted
Use context inScopeSet in CaseCon
Otherwise one of the substitutions will substitute free variables that were shadowed by the pattern (bad!)
1 parent c557e66 commit e087036

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

clash-lib/src/Clash/Normalize/Transformations.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,10 @@ caseCon (TransformContext is0 _) (Case scrut ty alts)
459459
in case Maybe.catMaybes binds2 of
460460
[] -> body
461461
binds3 -> Letrec binds3 body
462-
let subst = extendTvSubstList (mkSubst is1)
462+
-- Use the original inScopeSet 'is0' here, not the extended inScopeSet
463+
-- 'is1', otherwise we'd make the "caseCon1" substitution substitute
464+
-- free variables that were shadowed by the pattern!
465+
let subst = extendTvSubstList (mkSubst is0)
463466
$ zip tvs (drop (length (dcUnivTyVars dc)) (Either.rights args))
464467
changed (substTm "caseCon1" subst e')
465468
_ -> case alts of

0 commit comments

Comments
 (0)