diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 1225aec0a..6af512c04 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -3920,7 +3920,8 @@ bool check_unpack_arguments(CheckerContext *ctx, Entity **lhs, isize lhs_count, Operand ok = o; val.mode = Addressing_Value; ok.mode = Addressing_Value; - ok.type = t_bool; + // ok.type = t_bool; + ok.type = t_untyped_bool; array_add(operands, val); array_add(operands, ok); diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 1c6181e77..722c73d0a 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -1211,23 +1211,25 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) { Type *proc_type = ctx->curr_proc_sig; GB_ASSERT(proc_type != nullptr); GB_ASSERT(proc_type->kind == Type_Proc); - // Type *proc_type = c->proc_stack[c->proc_stack.count-1]; + TypeProc *pt = &proc_type->Proc; if (pt->diverging) { error(rs->token, "Diverging procedures may not return"); break; } + Entity **result_entities = nullptr; isize result_count = 0; bool has_named_results = pt->has_named_results; if (pt->results) { + result_entities = proc_type->Proc.results->Tuple.variables.data; result_count = proc_type->Proc.results->Tuple.variables.count; } auto operands = array_make(heap_allocator(), 0, 2*rs->results.count); defer (array_free(&operands)); - check_unpack_arguments(ctx, nullptr, -1, &operands, rs->results, false); + check_unpack_arguments(ctx, result_entities, result_count, &operands, rs->results, true); if (result_count == 0 && rs->results.count > 0) { error(rs->results[0], "No return values expected"); diff --git a/src/parser.cpp b/src/parser.cpp index cfdd9ad01..a162a4ee3 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1593,6 +1593,28 @@ Ast *convert_stmt_to_body(AstFile *f, Ast *stmt) { } +void check_polymorphic_params_for_type(AstFile *f, Ast *polymorphic_params, Token token) { + if (polymorphic_params == nullptr) { + return; + } + if (polymorphic_params->kind != Ast_FieldList) { + return; + } + ast_node(fl, FieldList, polymorphic_params); + for_array(fi, fl->list) { + Ast *field = fl->list[fi]; + if (field->kind != Ast_Field) { + continue; + } + for_array(i, field->Field.names) { + Ast *name = field->Field.names[i]; + if (name->kind == Ast_PolyType) { + error(name, "Polymorphic names are not needed for %.*s parameters", LIT(token.string)); + return; // TODO(bill): Err multiple times or just the once? + } + } + } +} Ast *parse_operand(AstFile *f, bool lhs) { @@ -1855,6 +1877,7 @@ Ast *parse_operand(AstFile *f, bool lhs) { polymorphic_params = nullptr; } expect_token_after(f, Token_CloseParen, "parameter list"); + check_polymorphic_params_for_type(f, polymorphic_params, token); } isize prev_level = f->expr_level; @@ -1921,6 +1944,7 @@ Ast *parse_operand(AstFile *f, bool lhs) { polymorphic_params = nullptr; } expect_token_after(f, Token_CloseParen, "parameter list"); + check_polymorphic_params_for_type(f, polymorphic_params, token); } while (allow_token(f, Token_Hash)) {