Skip to content

Commit f16d2aa

Browse files
committed
refactor(sema): move heuristic to not change ending depths
1 parent c364687 commit f16d2aa

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

source/sema.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,23 +1929,25 @@ class sema
19291929

19301930
auto end(compound_statement_node const& n, int) -> void
19311931
{
1932+
symbols.emplace_back(
1933+
scope_depth,
1934+
compound_sym{ false, &n, kind_of(n) }
1935+
);
1936+
--scope_depth;
1937+
19321938
// Pop an implicit 'else' branch.
19331939
if (auto s = std::find_if(
19341940
symbols.rbegin(),
19351941
symbols.rend(),
19361942
[=](symbol s) {
1937-
return s.depth == scope_depth - 1;
1943+
return s.depth == scope_depth;
19381944
});
1939-
s == symbols.rend()
1940-
|| std::get_if<symbol::selection>(&s->sym)
1941-
) {
1945+
s != symbols.rend()
1946+
&& std::get_if<symbol::selection>(&s->sym)
1947+
)
1948+
{
19421949
--scope_depth;
19431950
}
1944-
symbols.emplace_back(
1945-
scope_depth,
1946-
compound_sym{ false, &n, kind_of(n) }
1947-
);
1948-
--scope_depth;
19491951
}
19501952

19511953
auto start(assignment_expression_node const& n, int)

0 commit comments

Comments
 (0)