Skip to content

Commit acc3768

Browse files
authored
fix: unions with local variables may have incorrect size. (WerWolv#175)
If the biggest variable is local the size of the union is set to it even though local variables don't contribute to the pattern size. The fix is to check if the variable is local before using it size in the comparison.
1 parent 55b67de commit acc3768

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/source/pl/core/ast/ast_node_union.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ namespace pl::core::ast {
2727
ON_SCOPE_EXIT {
2828
size_t size = 0;
2929
for (auto &memberPattern : memberPatterns) {
30-
size = std::max(memberPattern->getSize(), size);
30+
if (!memberPattern->isLocal())
31+
size = std::max(memberPattern->getSize(), size);
3132
}
3233
pattern->setSize(size);
3334

0 commit comments

Comments
 (0)