aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-12-14 18:36:06 +0000
committergingerBill <bill@gingerbill.org>2018-12-14 18:36:06 +0000
commitb7eebe5d004380dec34a185bca6e5e343589de69 (patch)
tree6e9b74c045c4c2d3880b25945291703a5f70eeac /src/check_expr.cpp
parent57d4333ed3a36778a034f144a6998587d61ed831 (diff)
Fix polymorphic record types with constant value parameters
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 6e4bf05e6..37a54854c 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -775,6 +775,7 @@ void check_assignment(CheckerContext *c, Operand *operand, Type *type, String co
}
}
+
bool is_polymorphic_type_assignable(CheckerContext *c, Type *poly, Type *source, bool compound, bool modify_type) {
Operand o = {Addressing_Value};
o.type = source;
@@ -985,6 +986,7 @@ Entity *check_ident(CheckerContext *c, Operand *o, Ast *n, Type *named_type, Typ
o->expr = n;
String name = n->Ident.token.string;
+
Entity *e = scope_lookup(c->scope, name);
if (e == nullptr) {
if (is_blank_ident(name)) {
@@ -5007,9 +5009,9 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper
}
} else {
i64 s = 0;
- if (is_type_generic(o->type)) {
+ if (o->type->kind == Type_Generic) {
// Polymorphic name!
- score += assign_score_function(0);
+ score += assign_score_function(1);
continue;
} else if (!check_is_assignable_to_with_score(c, o, e->type, &s)) {
if (show_error) {
@@ -5028,18 +5030,6 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper
}
}
- if (param_count < ordered_operands.count) {
- error(call, "Too many polymorphic type arguments, expected %td, got %td", param_count, ordered_operands.count);
- err = CallArgumentError_TooManyArguments;
- } else if (param_count > ordered_operands.count) {
- error(call, "Too few polymorphic type arguments, expected %td, got %td", param_count, ordered_operands.count);
- err = CallArgumentError_TooFewArguments;
- }
-
- if (err != 0) {
- return err;
- }
-
{
gbAllocator a = c->allocator;