aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-12-15 09:48:05 +0000
committergingerBill <bill@gingerbill.org>2019-12-15 09:48:05 +0000
commite6f26b9931af0b05b93447639fba7569691ac0d0 (patch)
treea79ea09d102c9c79863b983b6c835726abeeb2f7 /src/check_expr.cpp
parentb8c534eba9b1b27d7c0d1db6eeda939ba56e8313 (diff)
Fix Unable to initialize a typeid field in a struct literal #501
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 81095db4a..fad3a4df0 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -7299,7 +7299,7 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
}
fields_visited[sel.index[0]] = true;
- check_expr_with_type_hint(c, o, fv->value, field->type);
+ check_expr_or_type(c, o, fv->value, field->type);
if (is_type_any(field->type) || is_type_union(field->type) || is_type_raw_union(field->type)) {
is_constant = false;
@@ -7308,7 +7308,6 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
is_constant = o->mode == Addressing_Constant;
}
-
check_assignment(c, o, field->type, str_lit("structure literal"));
}
} else {
@@ -7334,9 +7333,9 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
field = t->Struct.fields[index];
}
- check_expr_with_type_hint(c, o, elem, field->type);
+ check_expr_or_type(c, o, elem, field->type);
- if (is_type_any(field->type) || is_type_union(field->type) || is_type_raw_union(field->type)) {
+ if (is_type_any(field->type) || is_type_union(field->type) || is_type_raw_union(field->type) || is_type_typeid(field->type)) {
is_constant = false;
}
if (is_constant) {