Skip to content

Tests: partial app coverage (§9) #517

Closed

Description

@ehartford

Summary

Add missing negative coverage for partial application placeholders. Positive partial application exists, but errors for invalid placeholder positions and placeholder-only contexts need tests so the syntax remains explicit and predictable.

Spec

§9.4 says _ is a placeholder only inside a call argument list, placeholder calls produce closures in left-to-right placeholder order, _ in callee position is an error, and add(5) is a normal wrong-argument-count error rather than implicit currying (docs/with-specification.md:3343-3372).

Current state

Parser.parse_call counts _ identifiers in call arguments, replaces them with generated closure parameters, and wraps the call in NK_CLOSURE when placeholders are present (src/Parser.w:4063-4102). test/behavior/behav_partial_app.w covers basic positive cases. The requirements campaign notes missing negative tests for _ outside a call argument list and _ in callee position (out/req-campaign/g04.tsv:97, out/req-campaign/g04.tsv:100).

Implementation plan

  1. Add compile-error tests for _ as a standalone expression and _ in callee position.
  2. Add a wrong-argument-count test proving add(5) does not produce a partial application.
  3. Add a test for multiple placeholders preserving left-to-right order if not already explicit.
  4. Keep placeholder+named rejection in Named-args rule gaps: implicit+default rejection, placeholder+named rejection (§9.1a, §9.4) #456 because that is an implementation gap, not test-only coverage today.

Test plan

Add test/compile_errors/err_partial_placeholder_standalone.w:

let f = _

expect a placeholder/discard-context diagnostic.

Add test/compile_errors/err_partial_placeholder_callee.w:

_(1)

expect _ in callee position or the current equivalent diagnostic.

Add test/compile_errors/err_partial_missing_arg_not_currying.w:

fn add(a: i32, b: i32) -> i32: a + b
let f = add(5)

expect wrong argument count.

Extend test/behavior/behav_partial_app.w with make_pair(_, 10, _).

Acceptance criteria

  • Invalid placeholder positions have compile-error coverage.
  • Missing non-placeholder arguments still produce wrong-argument-count errors.
  • Positive partial application behavior remains covered.
  • with build && with build :fixpoint && with build :test pass.

Dependencies

#456 for placeholder+named rejection.

Traceability

From the requirements campaign (docs/requirements.md, spec v7.1). Affected requirement IDs: 9.4.1.4, 9.4.1.7.

Activity

  1. ehartford commented on Jul 3, 2026

    @ehartford
    ContributorAuthor

    Closing — partial application: missing-arg-is-not-currying rejection (err_partial_missing_arg_not_currying) + placeholder positional coverage pinned (bfe7865); placeholder+named already covered. Note: bare let f = _ / _(1) are rejected with the generic 'undefined variable' (correct rejection; a placeholder-specific message would be a nice-to-have, not a bug). §9.

  2. added a commit that references this issue on Jul 4, 2026
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