mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-15 18:32:22 -07:00
Fix #514
This commit is contained in:
+5
-2
@@ -4295,10 +4295,13 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32
|
||||
tuple->Tuple.variables[i] = alloc_entity_array_elem(nullptr, blank_token, type->Array.elem, cast(i32)i);
|
||||
}
|
||||
}
|
||||
|
||||
operand->type = tuple;
|
||||
operand->mode = Addressing_Value;
|
||||
|
||||
if (tuple->Tuple.variables.count == 1) {
|
||||
operand->type = tuple->Tuple.variables[0]->type;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -8360,10 +8363,10 @@ void check_not_tuple(CheckerContext *c, Operand *o) {
|
||||
// NOTE(bill): Tuples are not first class thus never named
|
||||
if (o->type->kind == Type_Tuple) {
|
||||
isize count = o->type->Tuple.variables.count;
|
||||
GB_ASSERT(count != 1);
|
||||
error(o->expr,
|
||||
"%td-valued tuple found where single value expected", count);
|
||||
o->mode = Addressing_Invalid;
|
||||
GB_ASSERT(count != 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -6697,6 +6697,19 @@ irValue *ir_build_builtin_proc(irProcedure *proc, Ast *expr, TypeAndValue tv, Bu
|
||||
irValue *val = ir_build_expr(proc, ce->args[0]);
|
||||
Type *t = base_type(ir_type(val));
|
||||
|
||||
if (!is_type_tuple(tv.type)) {
|
||||
if (t->kind == Type_Struct) {
|
||||
GB_ASSERT(t->Struct.fields.count == 1);
|
||||
return ir_emit_struct_ev(proc, val, 0);
|
||||
} else if (t->kind == Type_Array) {
|
||||
GB_ASSERT(t->Array.count == 1);
|
||||
return ir_emit_array_epi(proc, val, 0);
|
||||
} else {
|
||||
GB_PANIC("Unknown type of expand_to_tuple");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GB_ASSERT(is_type_tuple(tv.type));
|
||||
// NOTE(bill): Doesn't need to be zero because it will be initialized in the loops
|
||||
irValue *tuple = ir_add_local_generated(proc, tv.type, false);
|
||||
|
||||
Reference in New Issue
Block a user