Skip to content

Commit

Permalink
fix union common type inference
Browse files Browse the repository at this point in the history
  • Loading branch information
on-keyday committed Jan 1, 2025
1 parent aa7b6e6 commit 44338e5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/middle/typing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,12 @@ namespace brgen::middle {
continue;
}
if (!u->common_type) {
u->common_type = f->field_type;
if (auto is_union = ast::as<ast::UnionType>(f->field_type)) {
u->common_type = is_union->common_type;
}
else {
u->common_type = f->field_type;
}
}
else {
u->common_type = common_type(u->common_type, f->field_type);
Expand Down

0 comments on commit 44338e5

Please sign in to comment.