diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/check_expr.cpp | 12 | ||||
| -rw-r--r-- | src/checker.cpp | 3 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 80ec4f78e..e005b0bd0 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -6473,7 +6473,14 @@ gb_internal CallArgumentError check_call_arguments_internal(CheckerContext *c, A } if (e && e->kind == Entity_Constant && is_type_proc(e->type)) { - if (o->mode != Addressing_Constant) { + bool ok = false; + if (o->mode == Addressing_Constant) { + ok = true; + } else if (o->value.kind == ExactValue_Procedure) { + ok = true; + } + + if (!ok) { if (show_error) { error(o->expr, "Expected a constant procedure value for the argument '%.*s'", LIT(e->token.string)); } @@ -7947,7 +7954,7 @@ gb_internal CallArgumentError check_polymorphic_record_type(CheckerContext *c, O s = gb_string_append_fmt(s, "$%.*s", LIT(name)); if (v->kind == Entity_TypeName) { - if (v->type->kind != Type_Generic) { + if (v->type != nullptr && v->type->kind != Type_Generic) { s = gb_string_append_fmt(s, "="); s = write_type_to_string(s, v->type, false); } @@ -11423,6 +11430,7 @@ gb_internal ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast o->mode = Addressing_Value; o->type = type; + o->value = exact_value_procedure(node); case_end; case_ast_node(te, TernaryIfExpr, node); diff --git a/src/checker.cpp b/src/checker.cpp index 8ea56a4ba..e5dda2aa7 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -1797,6 +1797,9 @@ gb_internal void add_type_and_value(CheckerContext *ctx, Ast *expr, AddressingMo } expr = unparen_expr(expr); + if (expr == nullptr) { + break; + }; } mutex_unlock(mutex); } |