Skip to content

Commit

Permalink
Prevent erasing same variable multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinborner committed Jan 11, 2025
1 parent cdea340 commit 7131edc
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ object Transformer {

case machine.Switch(value, clauses, default) =>
emit(Comment(s"switch ${value.name}, ${clauses.length} clauses"))
val freeInClauses = clauses.flatMap(freeVariables) ++ default.map(freeVariables).getOrElse(Set.empty)
shareValues(List(value), freeInClauses.toSet)
val freeInClauses = clauses.flatMap(freeVariables).toSet ++ default.map(freeVariables).getOrElse(Set.empty)
shareValues(List(value), freeInClauses)

val tagName = freshName("tag")
val objectName = freshName("fields")
Expand All @@ -124,7 +124,7 @@ object Transformer {
BC.stack = stack

consumeObject(LocalReference(objectType, objectName), clause.parameters, freeVariables(clause.body));
eraseValues(freeInClauses, freeVariables(clause));
eraseValues(freeInClauses.toList, freeVariables(clause));

val terminator = transform(clause.body);

Expand Down

0 comments on commit 7131edc

Please sign in to comment.