|
@@ -117,8 +117,6 @@ gb_internal void check_or_return_split_types(CheckerContext *c, Operand *x, Stri
|
|
|
|
|
|
gb_internal bool is_diverging_expr(Ast *expr);
|
|
gb_internal bool is_diverging_expr(Ast *expr);
|
|
|
|
|
|
-gb_internal CallArgumentError check_order_of_call_arguments(CheckerContext *c, Type *proc_type, Ast *call, bool show_error);
|
|
|
|
-
|
|
|
|
gb_internal isize get_procedure_param_count_excluding_defaults(Type *pt, isize *param_count_);
|
|
gb_internal isize get_procedure_param_count_excluding_defaults(Type *pt, isize *param_count_);
|
|
|
|
|
|
enum LoadDirectiveResult {
|
|
enum LoadDirectiveResult {
|
|
@@ -5413,10 +5411,6 @@ gb_internal CallArgumentError check_call_arguments_internal(CheckerContext *c, A
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- if (check_order_of_call_arguments(c, proc_type, call, show_error)) {
|
|
|
|
- return CallArgumentError_OutOfOrderParameters;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
isize positional_operand_count = positional_operands.count;
|
|
isize positional_operand_count = positional_operands.count;
|
|
if (variadic) {
|
|
if (variadic) {
|
|
positional_operand_count = gb_min(positional_operands.count, pt->variadic_index);
|
|
positional_operand_count = gb_min(positional_operands.count, pt->variadic_index);
|
|
@@ -5839,99 +5833,6 @@ gb_internal bool evaluate_where_clauses(CheckerContext *ctx, Ast *call_expr, Sco
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
-gb_internal CallArgumentError check_order_of_call_arguments(CheckerContext *c, Type *proc_type, Ast *call, bool show_error) {
|
|
|
|
- CallArgumentError err = CallArgumentError_None;
|
|
|
|
-
|
|
|
|
- if (proc_type == nullptr || !is_type_proc(proc_type)) {
|
|
|
|
- // ignore for the time being
|
|
|
|
- return err;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ast_node(ce, CallExpr, call);
|
|
|
|
- if (!is_call_expr_field_value(ce)) {
|
|
|
|
- return err;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- TypeProc *pt = &base_type(proc_type)->Proc;
|
|
|
|
- isize param_count = pt->param_count;
|
|
|
|
-
|
|
|
|
- TEMPORARY_ALLOCATOR_GUARD();
|
|
|
|
-
|
|
|
|
- auto arg_order_indices = slice_make<isize>(temporary_allocator(), ce->args.count);
|
|
|
|
- auto visited = slice_make<bool>(temporary_allocator(), param_count);
|
|
|
|
-
|
|
|
|
- for_array(i, ce->args) {
|
|
|
|
- Ast *arg = ce->args[i];
|
|
|
|
- ast_node(fv, FieldValue, arg);
|
|
|
|
-
|
|
|
|
- Ast *field = fv->field;
|
|
|
|
- String name = {};
|
|
|
|
- if (field != nullptr && field->kind == Ast_Ident) {
|
|
|
|
- name = field->Ident.token.string;
|
|
|
|
- } else {
|
|
|
|
- err = CallArgumentError_InvalidFieldValue;
|
|
|
|
- if (show_error) {
|
|
|
|
- gbString s = expr_to_string(arg);
|
|
|
|
- error(arg, "Invalid parameter name '%s' in procedure call", s);
|
|
|
|
- gb_string_free(s);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- isize index = lookup_procedure_parameter(pt, name);
|
|
|
|
- if (index < 0) {
|
|
|
|
- err = CallArgumentError_InvalidFieldValue;
|
|
|
|
- if (show_error) {
|
|
|
|
- error(arg, "No parameter named '%.*s' for this procedure type", LIT(name));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (visited[index]) {
|
|
|
|
- err = CallArgumentError_DuplicateParameter;
|
|
|
|
- if (show_error) {
|
|
|
|
- error(arg, "Duplicate parameter '%.*s' in procedure call", LIT(name));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- arg_order_indices[i] = index;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (err) {
|
|
|
|
- return err;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (isize i = 0; i < arg_order_indices.count-1; i++) {
|
|
|
|
- isize a = arg_order_indices[i+0];
|
|
|
|
- isize b = arg_order_indices[i+1];
|
|
|
|
- GB_ASSERT(a != b);
|
|
|
|
- if (a > b) {
|
|
|
|
- err = CallArgumentError_OutOfOrderParameters;
|
|
|
|
- if (show_error) {
|
|
|
|
- Ast *arg_a = ce->args[i+0];
|
|
|
|
- Ast *arg_b = ce->args[i+1];
|
|
|
|
-
|
|
|
|
- isize curr_a_order = a;
|
|
|
|
- for (isize j = i; j >= 0; j--) {
|
|
|
|
- isize j_order = arg_order_indices[j];
|
|
|
|
- if (b < j_order && j_order < curr_a_order) {
|
|
|
|
- curr_a_order = j_order;
|
|
|
|
- arg_a = ce->args[j];
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- ast_node(fv_a, FieldValue, arg_a);
|
|
|
|
- ast_node(fv_b, FieldValue, arg_b);
|
|
|
|
-
|
|
|
|
- gbString s_a = expr_to_string(fv_a->field);
|
|
|
|
- gbString s_b = expr_to_string(fv_b->field);
|
|
|
|
- error(arg_b, "Parameter names out of order, expected '%s' to be called before '%s'", s_b, s_a);
|
|
|
|
- gb_string_free(s_b);
|
|
|
|
- gb_string_free(s_a);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return err;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
gb_internal bool check_named_arguments(CheckerContext *c, Type *type, Slice<Ast *> const &named_args, Array<Operand> *named_operands, bool show_error) {
|
|
gb_internal bool check_named_arguments(CheckerContext *c, Type *type, Slice<Ast *> const &named_args, Array<Operand> *named_operands, bool show_error) {
|
|
bool success = true;
|
|
bool success = true;
|
|
|
|
|
|
@@ -5974,12 +5875,6 @@ gb_internal bool check_named_arguments(CheckerContext *c, Type *type, Slice<Ast
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- // bool prev_visited = visited[param_index];
|
|
|
|
- // if (prev_visited) {
|
|
|
|
- // error(value, "Duplicate parameter named '%.*s' in procedure call", LIT(key));
|
|
|
|
- // success = false;
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
Entity *e = pt->params->Tuple.variables[param_index];
|
|
Entity *e = pt->params->Tuple.variables[param_index];
|
|
if (!is_type_polymorphic(e->type)) {
|
|
if (!is_type_polymorphic(e->type)) {
|
|
type_hint = e->type;
|
|
type_hint = e->type;
|
|
@@ -6498,8 +6393,6 @@ gb_internal CallArgumentData check_call_arguments_new_and_improved(CheckerContex
|
|
|
|
|
|
bool any_failure = false;
|
|
bool any_failure = false;
|
|
|
|
|
|
- // bool vari_expand = (ce->ellipsis.pos.line != 0);
|
|
|
|
-
|
|
|
|
// Split positional and named args into separate arrays/slices
|
|
// Split positional and named args into separate arrays/slices
|
|
Slice<Ast *> positional_args = {};
|
|
Slice<Ast *> positional_args = {};
|
|
Slice<Ast *> named_args = {};
|
|
Slice<Ast *> named_args = {};
|