mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-13 01:21:38 -07:00
Correct @(require_results) on parapoly procedures
This commit is contained in:
+6
-4
@@ -1014,10 +1014,12 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
|
||||
}
|
||||
}
|
||||
|
||||
if (pt->result_count == 0 && ac.require_results) {
|
||||
error(pl->type, "'require_results' is not needed on a procedure with no results");
|
||||
} else {
|
||||
pt->require_results = ac.require_results;
|
||||
if (ac.require_results) {
|
||||
if (pt->result_count == 0) {
|
||||
error(pl->type, "'require_results' is not needed on a procedure with no results");
|
||||
} else {
|
||||
pt->require_results = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (ac.link_name.len > 0) {
|
||||
|
||||
@@ -442,6 +442,14 @@ bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, Entity *base_
|
||||
final_proc_type->Proc.is_poly_specialized = true;
|
||||
final_proc_type->Proc.is_polymorphic = true;
|
||||
|
||||
final_proc_type->Proc.variadic = src->Proc.variadic;
|
||||
final_proc_type->Proc.require_results = src->Proc.require_results;
|
||||
final_proc_type->Proc.c_vararg = src->Proc.c_vararg;
|
||||
final_proc_type->Proc.has_named_results = src->Proc.has_named_results;
|
||||
final_proc_type->Proc.diverging = src->Proc.diverging;
|
||||
final_proc_type->Proc.return_by_pointer = src->Proc.return_by_pointer;
|
||||
final_proc_type->Proc.optional_ok = src->Proc.optional_ok;
|
||||
|
||||
|
||||
for (isize i = 0; i < operands.count; i++) {
|
||||
Operand o = operands[i];
|
||||
|
||||
+5
-5
@@ -1405,12 +1405,12 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) {
|
||||
if (kind == Expr_Stmt) {
|
||||
return;
|
||||
}
|
||||
Ast *expr = strip_or_return_expr(operand.expr);
|
||||
|
||||
Ast *expr = strip_or_return_expr(operand.expr);
|
||||
if (expr->kind == Ast_CallExpr) {
|
||||
AstCallExpr *ce = &expr->CallExpr;
|
||||
Type *t = type_of_expr(ce->proc);
|
||||
if (is_type_proc(t)) {
|
||||
Type *t = base_type(type_of_expr(ce->proc));
|
||||
if (t->kind == Type_Proc) {
|
||||
if (t->Proc.require_results) {
|
||||
gbString expr_str = expr_to_string(ce->proc);
|
||||
error(node, "'%s' requires that its results must be handled", expr_str);
|
||||
@@ -1421,8 +1421,8 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) {
|
||||
} else if (expr->kind == Ast_SelectorCallExpr) {
|
||||
AstSelectorCallExpr *se = &expr->SelectorCallExpr;
|
||||
ast_node(ce, CallExpr, se->call);
|
||||
Type *t = type_of_expr(ce->proc);
|
||||
if (is_type_proc(t)) {
|
||||
Type *t = base_type(type_of_expr(ce->proc));
|
||||
if (t->kind == Type_Proc) {
|
||||
if (t->Proc.require_results) {
|
||||
gbString expr_str = expr_to_string(ce->proc);
|
||||
error(node, "'%s' requires that its results must be handled", expr_str);
|
||||
|
||||
Reference in New Issue
Block a user