Skip to content

Implement named arguments (§9.1a) #397

Closed

Description

@ehartford

Summary

The original "implement named arguments" premise is stale: parser, sema, and behavior coverage now exist for core named calls. The remaining work is to remove stale blocked notes, add spec-shaped coverage, and leave the rule-gap issues (#456 and #508) as the active follow-ups.

Spec

§9.1a allows parameters to be passed positionally or by name, with positional arguments before named arguments, exact parameter-name matching, arbitrary order among named arguments, defaults filled at the call site, and call resolution order of positional, named, implicit, then defaults (docs/with-specification.md:3063-3102). It also excludes named arguments for extern fn values, closure values, and placeholder-based partial application calls (docs/with-specification.md:3097-3100).

Current state

Parser.parse_call recognizes name: value, tracks positional-after-named as a parse error, stores per-argument names in AstPool.call_named_args, and wraps placeholder calls after preserving that metadata (src/Parser.w:4009-4102, src/Ast.w:1170-1180). Sema.check_call rejects named args on closures/function pointers (src/SemaCheck.w:7835-7839) and reorders named arguments, checks unknown/duplicate names, fills implicit parameters, then fills defaults (src/SemaCheck.w:7855-7929). test/behavior/behav_named_args.w:15-44 already covers ordered, reordered, mixed, and defaulted named calls.

The stale part is documentation/test inventory: test/spec/spec_ss09_1a_named_arguments_and_implicit_context.w:1-21 still says named arguments and implicit context are not implemented and leaves the spec examples commented. Separate real gaps remain in #456 (implicit+default and placeholder+named rejection) and #508 (missing negative and evaluation-order coverage).

Implementation plan

  1. Treat this issue as verify-and-close, not a new implementation project.
  2. Update the stale spec test in the eventual implementation PR: uncomment the named-argument examples in test/spec/spec_ss09_1a_named_arguments_and_implicit_context.w, add the implicit-context form, and keep expected stdout/check-only directives aligned with current harness style.
  3. Ensure the call-resolution tests cover the exact §9.1a order: positional, named, implicit, defaults. Named and implicit behavior should not rely solely on test/behavior/behav_named_args.w.
  4. Leave semantic rule gaps to Named-args rule gaps: implicit+default rejection, placeholder+named rejection (§9.1a, §9.4) #456 and test-only coverage to Tests: named args coverage (§9) #508 so this issue can close once the existing implementation is verified against spec examples.

Test plan

Promote test/spec/spec_ss09_1a_named_arguments_and_implicit_context.w from a default-only test into a full §9.1a spec test:

  • label("db", port: 5432) uses default timeout.
  • label(port: 5432, host: "db", timeout: 5) proves named reordering.
  • an implicit parameter filled by with context(ctx): is overridden by an explicit named argument.

Run existing test/behavior/behav_named_args.w to guard the current behavior test.

Acceptance criteria

Dependencies

#456 and #508.

Activity

  1. ehartford commented on Jun 10, 2026

    @ehartford
    ContributorAuthor

    Scope correction from the requirements campaign (2026-06-10): named arguments are IMPLEMENTED — verified empirically (reordering, mixing, defaults-by-name) with behav_named_args.w + negative tests; the 'blocked' comments in spec_ss09_1a_*.w are stale. Remaining before close: the rule gaps tracked in #455 (implicit+default rejection, placeholder+named rejection) and test additions in #500. This issue can likely close after verifying the §9.1a resolution-order conformance.

  2. ehartford commented on Jun 10, 2026

    @ehartford
    ContributorAuthor

    Correction to the previous comment: the rule-gap issue is #456 and the test issue is #508 (not #455/#500).

  3. ehartford commented on Jun 14, 2026

    @ehartford
    ContributorAuthor

    Implemented in the latest main commit. The stale §9.1a spec test now executes named arguments, default parameters, implicit parameter resolution, and explicit named override of an implicit parameter. Existing behavior coverage was also verified. Rule gaps remain tracked by #456/#508 as intended. 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