From b84e7c69ae52155c4902cf24b4f9bb86d65d5f9e Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 21 Sep 2025 18:46:28 -0400 Subject: Be more lenient with underscore fields and arguments. --- src/compile/structs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/compile/structs.c') 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)); } -- cgit v1.2.3