Repository navigation
Description
Summary
Add missing negative and edge-case tests for named arguments. Core named calls already work, but the test suite does not fully lock down parser rejection, call-site default evaluation, and named-arg exclusions.
Spec
§9.1a requires positional arguments before named arguments, default expressions evaluated at the call site on every omitted call, and no named arguments for extern fn values, closure values, or placeholder partial application (docs/with-specification.md:3083-3102). §9.4 also forbids named arguments in placeholder calls (docs/with-specification.md:3362-3372).
Current state
Parser emits positional argument cannot follow named argument (src/Parser.w:4039-4040). Sema rejects named args on closures/function pointers (src/SemaCheck.w:7835-7839) and fills named/default arguments (src/SemaCheck.w:7855-7929). test/behavior/behav_named_args.w:15-44 covers positive named calls, mixed calls, defaults, and reordering. The requirements campaign still records missing coverage for parser rejection, per-call default evaluation, and closure rejection (out/req-campaign/g04.tsv:43, out/req-campaign/g04.tsv:48, out/req-campaign/g04.tsv:50).
Implementation plan
- Add compile-error coverage for positional-after-named syntax using the parser diagnostic.
- Add behavior coverage proving default expressions are evaluated on every call, not once at declaration or first use. Use a global or local counter only if Enforce the §9.1c global data-race rule (conservative single-thread proof) #387's global rule has landed; otherwise use a helper returning different values through existing safe local state.
- Add compile-error coverage for named args on closure values and
extern "C" fnvalues using the current sema diagnostic. - Add placeholder+named coverage after Named-args rule gaps: implicit+default rejection, placeholder+named rejection (§9.1a, §9.4) #456 implements the rule; until then, reference Named-args rule gaps: implicit+default rejection, placeholder+named rejection (§9.1a, §9.4) #456 from this test issue.
- Update the stale spec test comments in
test/spec/spec_ss09_1a_named_arguments_and_implicit_context.w.
Test plan
Add test/compile_errors/err_named_arg_positional_after_named.w with add(a: 1, 2) and //! expect-error: positional argument cannot follow named argument.
Add test/behavior/behav_named_arg_default_eval_each_call.w:
- default expression increments or reads changing state.
- two calls omitting the default observe two evaluations.
Add test/compile_errors/err_named_arg_closure_value.w:
let f = x => x + 1; f(x: 1)expectsnamed arguments are not supported for closures or function pointers.
Add test/compile_errors/err_named_arg_extern_fn_value.w if extern function pointer syntax allows a direct value call.
After #456, add test/compile_errors/err_named_arg_partial_placeholder.w.
Acceptance criteria
- Parser rejection for positional-after-named has a regression test.
- Default expression call-site evaluation has a behavior test.
- Closure/function-pointer named-arg rejection has a regression test.
- Placeholder+named rejection is tested when Named-args rule gaps: implicit+default rejection, placeholder+named rejection (§9.1a, §9.4) #456 lands.
with build && with build :fixpoint && with build :testpass.
Dependencies
#456 for placeholder+named rejection. #397 for stale spec-test cleanup. #387 if the default-evaluation test uses mutable globals.
Traceability
From the requirements campaign (docs/requirements.md, spec v7.1). Affected requirement IDs: 9.1.2.10, 9.1.2.3, 9.1.2.8.
Activity
ehartford commentedon Jul 3, 2026
Closing — named args: positional-after-named rejection (err_named_arg_positional_after_named), closure named-arg rejection (err_named_arg_closure_value), and per-call default-expr evaluation (behav_named_arg_default_eval_each_call) pinned (bfe7865); placeholder+named already covered by err_partial_app_named_arg. §9.
Fix #530 tailrec verifier + coverage-sweep batch 3 (#498 #508 #517 #523