Skip to content

Commit 889cec0

Browse files
committed
fix: unions with local variables may have incorrect size.
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 889cec0

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)