mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Fix bug for foo().bar where foo() is a 0-value expression
This commit is contained in:
+7
-3
@@ -5394,9 +5394,10 @@ gb_internal Entity *check_selector(CheckerContext *c, Operand *operand, Ast *nod
|
|||||||
Type *t = type_deref(operand->type);
|
Type *t = type_deref(operand->type);
|
||||||
if (t == nullptr) {
|
if (t == nullptr) {
|
||||||
error(operand->expr, "Cannot use a selector expression on 0-value expression");
|
error(operand->expr, "Cannot use a selector expression on 0-value expression");
|
||||||
} else if (is_type_dynamic_array(t)) {
|
} else {
|
||||||
|
if (is_type_dynamic_array(t)) {
|
||||||
init_mem_allocator(c->checker);
|
init_mem_allocator(c->checker);
|
||||||
}
|
} else {
|
||||||
sel = lookup_field(operand->type, field_name, operand->mode == Addressing_Type);
|
sel = lookup_field(operand->type, field_name, operand->mode == Addressing_Type);
|
||||||
entity = sel.entity;
|
entity = sel.entity;
|
||||||
|
|
||||||
@@ -5408,8 +5409,11 @@ gb_internal Entity *check_selector(CheckerContext *c, Operand *operand, Ast *nod
|
|||||||
add_type_info_type(c, operand->type);
|
add_type_info_type(c, operand->type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (entity == nullptr && selector->kind == Ast_Ident && (is_type_array(type_deref(operand->type)) || is_type_simd_vector(type_deref(operand->type)))) {
|
if (entity == nullptr && selector->kind == Ast_Ident && operand->type != nullptr &&
|
||||||
|
(is_type_array(type_deref(operand->type)) || is_type_simd_vector(type_deref(operand->type)))) {
|
||||||
String field_name = selector->Ident.token.string;
|
String field_name = selector->Ident.token.string;
|
||||||
if (1 < field_name.len && field_name.len <= 4) {
|
if (1 < field_name.len && field_name.len <= 4) {
|
||||||
u8 swizzles_xyzw[4] = {'x', 'y', 'z', 'w'};
|
u8 swizzles_xyzw[4] = {'x', 'y', 'z', 'w'};
|
||||||
|
|||||||
Reference in New Issue
Block a user