diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-09-21 18:46:28 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-09-21 18:46:28 -0400 |
| commit | b84e7c69ae52155c4902cf24b4f9bb86d65d5f9e (patch) | |
| tree | a5b782209c29e6b2938b060d96596f47ec4f783a /src/compile | |
| parent | 0d489659597f9d3e6b69f92d2ca001a8dd5bf6cd (diff) | |
Be more lenient with underscore fields and arguments.
Diffstat (limited to 'src/compile')
| -rw-r--r-- | src/compile/functions.c | 3 | ||||
| -rw-r--r-- | src/compile/structs.c | 4 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/compile/functions.c b/src/compile/functions.c index abe0a588..e3dbc2e7 100644 --- a/src/compile/functions.c +++ b/src/compile/functions.c @@ -155,7 +155,8 @@ Text_t compile_function_call(env_t *env, ast_t *ast) { if (!is_valid_call(env, Match(fn_t, FunctionType)->args, call->args, (call_opts_t){.promotion = true})) { if (is_valid_call(env, Match(fn_t, FunctionType)->args, call->args, (call_opts_t){.promotion = true, .underscores = true})) { - code_err(ast, "You can't pass underscore arguments to this function (those are private)"); + code_err(ast, "You can't pass underscore arguments to this function as positional arguments. You must " + "use keyword arguments."); } else { arg_t *args = NULL; for (arg_ast_t *a = call->args; a; a = a->next) diff --git a/src/compile/structs.c b/src/compile/structs.c index aaebef22..2e7217f6 100644 --- a/src/compile/structs.c +++ b/src/compile/structs.c @@ -127,7 +127,9 @@ Text_t compile_struct_literal(env_t *env, ast_t *ast, type_t *t, arg_ast_t *args return Texts("((", compile_type(t), "){", compile_arguments(env, ast, struct_->fields, args), "})"); } else if (!constructor_opts.underscores && is_valid_call(env, struct_->fields, args, (call_opts_t){.promotion = true, .underscores = true})) { - code_err(ast, "This constructor uses private fields that are not exposed."); + code_err(ast, "This constructor is passing private fields (those starting with underscores) as positional " + "arguments, which is not allowed. \n" + " If you need to pass these fields, use a keyword argument."); } code_err(ast, "I could not find a constructor matching these arguments for the struct ", type_to_text(t)); } |
