Skip to content

Commit 68bb2b6

Browse files
hsutterzaucy
authored andcommitted
Don't move from a non-last use in a branch condition, closes hsutter#311
1 parent 47d9ebd commit 68bb2b6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

source/sema.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,9 +604,16 @@ class sema
604604
assert (sym.identifier);
605605

606606
// If we find a use of this identifier
607-
if (*sym.identifier == *id) {
608-
definite_last_uses.emplace_back( sym.identifier, is_forward );
609-
found = true;
607+
if (*sym.identifier == *id)
608+
{
609+
if (
610+
!found
611+
|| symbols[i].depth > selections.back()+1
612+
)
613+
{
614+
definite_last_uses.emplace_back( sym.identifier, is_forward );
615+
found = true;
616+
}
610617

611618
// Pop any of the last branches that we're outside of
612619
while (symbols[i].depth <= selections.back()) {

0 commit comments

Comments
 (0)