Repository navigation
Description
Summary
Close the remaining named-argument rule gaps after the core named-call implementation. The compiler must reject implicit parameters that also have defaults and reject named arguments mixed with placeholder partial application.
Spec
§9.1a says call resolution order is positional, named, implicit, then defaults; extern fn values, closure values, and placeholder-based partial application calls do not support named arguments; and an implicit parameter may not also have a default (docs/with-specification.md:3097-3102). §9.4 separately says placeholder calls use positional arguments only and named arguments are not permitted in the same call (docs/with-specification.md:3362-3372).
Current state
Parser supports named arguments and placeholders in the same parse_call path (src/Parser.w:4009-4102). It stores named-argument metadata before returning a generated closure when placeholders are present, but there is no parser diagnostic for the combination (src/Parser.w:4087-4102). Sema rejects named arguments on callable values (src/SemaCheck.w:7835-7839) and resolves named/default/implicit calls for named calls (src/SemaCheck.w:7855-7929), but no declaration-time check rejects ctx: implicit T = default.
The root causes are split: invalid parameter declarations are not checked when function metadata is collected, and invalid placeholder+named calls are constructed as ordinary partial-application closures before sema has a dedicated rule for them.
Implementation plan
- In parser or declaration sema where parameter flags/defaults are finalized (
Parser.parse_param_list, aroundsrc/Parser.w:6837-6947), reject any parameter whose flags include implicit and whose default node is nonzero. Preferred diagnostic:implicit parameter cannot have a default value. - In
Parser.parse_call, ifplaceholder_count > 0andhas_named != 0, emitplaceholder partial application does not support named argumentsand return a poisoned expression or a call node that sema will not lower. Parser-time is best because both facts are local atsrc/Parser.w:4063-4102. - Add a sema defense in
Sema.check_closureorSema.check_callso malformed ASTs from older pools or generated code cannot silently pass. - Keep ordinary named calls and ordinary partial application behavior unchanged.
Test plan
Add test/compile_errors/err_implicit_param_default.w:
fn f(ctx: implicit Ctx = Ctx.default()):
...
expect implicit parameter cannot have a default value.
Add test/compile_errors/err_partial_app_named_arg.w:
fn add(a: i32, b: i32) -> i32: a + b
let f = add(a: _, b: 2)
expect the placeholder/named diagnostic.
Extend test/behavior/behav_named_args.w and test/behavior/behav_partial_app.w to prove ordinary named calls and ordinary placeholder calls still pass.
Acceptance criteria
implicitplus default is rejected at declaration time.- Placeholder partial application with any named argument is rejected.
- Existing named-argument behavior remains green.
- Existing partial-application behavior remains green.
with build && with build :fixpoint && with build :testpass.
Dependencies
#397 for stale base implementation cleanup; #508 and #517 for broader coverage.
Traceability
From the requirements campaign (docs/requirements.md, spec v7.1). Affected requirement IDs: 9.1.2.11, 9.4.1.9.
Activity
ehartford commentedon Jun 14, 2026
Implemented in the latest main commit. The parser now rejects implicit parameters with defaults and named arguments mixed with placeholder partial application; sema also defensively rejects malformed placeholder closures carrying named-call metadata. Added negative coverage and reran ordinary named-call/partial-application regressions. Verification passed: build, fixpoint, full :test, and explicit :test-green.