aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2025-09-29 10:41:35 +0100
committergingerBill <gingerBill@users.noreply.github.com>2025-09-29 10:41:35 +0100
commit0d946268ee38d007791e3158eed07b856817fab9 (patch)
tree1bac43b7d296c6e631e8995558cc644f72770c38 /src/check_expr.cpp
parent10ba956d6a57cb5b334b4311cda96c6c7f8737db (diff)
Disallow constant access `x.y` on `struct #raw_union`
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 02cd66136..a59f145c7 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -5120,7 +5120,11 @@ gb_internal ExactValue get_constant_field_single(CheckerContext *c, ExactValue v
}
if (cl->elems[0]->kind == Ast_FieldValue) {
- if (is_type_struct(node->tav.type)) {
+ if (is_type_raw_union(node->tav.type)) {
+ if (success_) *success_ = false;
+ if (finish_) *finish_ = true;
+ return empty_exact_value;
+ } else if (is_type_struct(node->tav.type)) {
bool found = false;
for (Ast *elem : cl->elems) {
if (elem->kind != Ast_FieldValue) {
@@ -5834,7 +5838,7 @@ gb_internal Entity *check_selector(CheckerContext *c, Operand *operand, Ast *nod
switch (entity->kind) {
case Entity_Constant:
- operand->value = entity->Constant.value;
+ operand->value = entity->Constant.value;
operand->mode = Addressing_Constant;
if (operand->value.kind == ExactValue_Procedure) {
Entity *proc = strip_entity_wrapping(operand->value.value_procedure);