Skip to content

Commit

Permalink
Resolve type fully before checking casts, addressing #1013. Correctly…
Browse files Browse the repository at this point in the history
… show the error location when a method is missing its single argument #1012.
  • Loading branch information
lerno committed Sep 24, 2023
1 parent 709fe1c commit 30d7946
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
2 changes: 0 additions & 2 deletions src/compiler/abi/c_abi.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ ABIArgInfo *abi_arg_ignore(void)
return &info;
}



bool abi_type_is_integer(AbiType type)
{
return !abi_type_is_type(type) || type_is_integer(type.type);
Expand Down
1 change: 1 addition & 0 deletions src/compiler/sema_casts.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ static bool cast_if_valid(SemaContext *context, Expr *expr, Type *to_type, bool
.expr = expr,
.context = context
};
if (!sema_resolve_type_decl(context, to)) return false;
if (!cast_is_allowed(&cc, is_explicit, false))
{
return false;
Expand Down
18 changes: 7 additions & 11 deletions src/compiler/sema_expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1332,21 +1332,17 @@ INLINE bool sema_call_expand_arguments(SemaContext *context, CalledDecl *callee,
sema_error_at_after(args[num_args - 1]->span, "Expected '.%s = ...' after this argument.", param->name);
return false;
}
if (num_args)
if (num_args > (callee->struct_var ? 1 : 0))
{
unsigned needed = func_param_count - num_args;
SEMA_ERROR(args[num_args - 1],
"Expected %d more %s after this one, did you forget %s?",
needed, needed == 1 ? "argument" : "arguments", needed == 1 ? "it" : "them");
RETURN_SEMA_ERROR(args[num_args - 1],
"Expected %d more %s after this one, did you forget %s?",
needed, needed == 1 ? "argument" : "arguments", needed == 1 ? "it" : "them");
}
else
{
SEMA_ERROR(call, "'%s' expects %d parameters, but none was provided.", callee->name, func_param_count);
}
return false;
RETURN_SEMA_ERROR(call, "'%s' expects %d parameter(s), but none was provided.",
callee->name, callee->struct_var ? func_param_count - 1 : func_param_count);
}
SEMA_ERROR(call, "The parameter '%s' must be set, did you forget it?", param->name);
return false;
RETURN_SEMA_ERROR(call, "The parameter '%s' must be set, did you forget it?", param->name);
}
call->call_expr.arguments = actual_args;
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define COMPILER_VERSION "0.4.659"
#define COMPILER_VERSION "0.4.660"

0 comments on commit 30d7946

Please sign in to comment.