dynamic map insertion and lookup

This commit is contained in:
Ginger Bill
2017-02-06 20:23:51 +00:00
parent 9f2d9b596d
commit c126339090
5 changed files with 55 additions and 45 deletions
+1 -7
View File
@@ -3829,12 +3829,6 @@ void check_unpack_arguments(Checker *c, ArrayOperand *operands, AstNodeArray arg
Operand o = {0};
check_multi_expr(c, &o, args.e[i]);
if (o.mode == Addressing_MapIndex) {
Type *tuple_type = make_map_tuple_type(c->allocator, o.type);
add_type_and_value(&c->info, o.expr, o.mode, tuple_type, (ExactValue){0});
o.type = tuple_type;
}
if (o.type == NULL || o.type->kind != Type_Tuple) {
array_add(operands, o);
} else {
@@ -4997,7 +4991,7 @@ ExprKind check__expr_base(Checker *c, Operand *o, AstNode *node, Type *type_hint
goto error;
}
o->mode = Addressing_MapIndex;
o->type = t->Map.value;
o->type = make_map_tuple_type(c->allocator, t->Map.value);
o->expr = node;
return Expr_Expr;
}