Skip to content

Named-args rule gaps: implicit+default rejection, placeholder+named rejection (§9.1a, §9.4) #456

Closed

Description

@ehartford

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

  1. In parser or declaration sema where parameter flags/defaults are finalized (Parser.parse_param_list, around src/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.
  2. In Parser.parse_call, if placeholder_count > 0 and has_named != 0, emit placeholder partial application does not support named arguments and return a poisoned expression or a call node that sema will not lower. Parser-time is best because both facts are local at src/Parser.w:4063-4102.
  3. Add a sema defense in Sema.check_closure or Sema.check_call so malformed ASTs from older pools or generated code cannot silently pass.
  4. 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

  • implicit plus 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 :test pass.

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

  1. ehartford commented on Jun 14, 2026

    @ehartford
    ContributorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions