aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-09-25 20:52:47 +0100
committergingerBill <bill@gingerbill.org>2019-09-25 20:52:47 +0100
commit48ab7f876c51dfb009f8ff53d345bb575ce4fb4c (patch)
tree62f211fe4f802614fb6c7f271f6cf96d98328158 /src
parent4cef160c87582c3a8d6000209a4154a9f585ba29 (diff)
Fix Implicit Selector Expressions do not work for parameteric struct parameters. #438
Diffstat (limited to 'src')
-rw-r--r--src/check_expr.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 5ef42a3fc..5535e6772 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -6078,6 +6078,19 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper
for_array(i, ce->args) {
Ast *arg = ce->args[i];
ast_node(fv, FieldValue, arg);
+
+ if (fv->field->kind == Ast_Ident) {
+ String name = fv->field->Ident.token.string;
+ isize index = lookup_polymorphic_record_parameter(original_type, name);
+ if (index >= 0) {
+ TypeTuple *params = get_record_polymorphic_params(original_type);
+ Entity *e = params->variables[i];
+ if (e->kind == Entity_Constant) {
+ check_expr_with_type_hint(c, &operands[i], fv->value, e->type);
+ }
+ }
+
+ }
check_expr_or_type(c, &operands[i], fv->value);
}
@@ -6088,7 +6101,17 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper
} else {
operands = array_make<Operand>(heap_allocator(), 0, 2*ce->args.count);
- check_unpack_arguments(c, nullptr, -1, &operands, ce->args, false, false);
+
+ Entity **lhs = nullptr;
+ isize lhs_count = -1;
+
+ TypeTuple *params = get_record_polymorphic_params(original_type);
+ if (params != nullptr) {
+ lhs = params->variables.data;
+ lhs_count = params->variables.count;
+ }
+
+ check_unpack_arguments(c, lhs, lhs_count, &operands, ce->args, false, false);
}
CallArgumentError err = CallArgumentError_None;
@@ -6217,6 +6240,9 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper
}
score += s;
}
+
+ // NOTE(bill): Add type info the parameters
+ add_type_info_type(c, o->type);
}
{