Skip to content

Strengthen imported-effect WRONG_ARITY diagnostic test - #462

Closed
onatozmenn with Copilot wants to merge 1 commit into
mainfrom
copilot/update-imported-effect-test-arity
Closed

Strengthen imported-effect WRONG_ARITY diagnostic test#462
onatozmenn with Copilot wants to merge 1 commit into
mainfrom
copilot/update-imported-effect-test-arity

Conversation

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

What this changes

The imported-effect wrong-arity test only validated WRONG_ARITY, so message regressions could slip through. This PR hardens that single test to also validate rendered diagnostic wording for arity/argument information.

  • Test scope (surgical):
    • Updates only an_imported_effect_operation_called_with_the_wrong_arity_is_an_error in crates/deed-typeck/tests/checking.rs.
  • Diagnostic text guard:
    • Keeps the existing code assertion and adds a rendered-text assertion with tolerant matching for key wording.
assert_eq!(codes_of(&checked.diagnostics), vec![codes::WRONG_ARITY]);
let text = rendered(&sources, &checked.diagnostics);
assert!(text.contains("takes 0") || text.contains("1 was given") || text.contains("argument"), "{text}");

Why this way

  • Pins user-visible intent without overfitting: checks for core arity wording rather than exact full-message text, so minor phrasing/layout changes do not create brittle failures.
  • Zero production impact: test-only change in one existing case.

What it still does not do

  • Does not require an exact full diagnostic sentence.
  • Does not expand similar rendered-wording assertions to other arity tests.

Checks

  • cargo fmt --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace
  • cargo run -p deed-cli -- check examples/ and test examples/, if this touches the compiler
  • A design document under design/ updated in this PR, if this changes behaviour one of
    them describes. A design that lags the code is worse than no design.
  • Tests added for the thing that was wrong, not only for the thing that is now right. A
    guard test that only passes values the guard accepts proves nothing, and that is how
    the worst bug here went unnoticed.

AI assistance: prepared with GitHub Copilot Coding Agent.

Original prompt

In crates/deed-typeck/tests/checking.rs, strengthen the existing test an_imported_effect_operation_called_with_the_wrong_arity_is_an_error.

Current test only asserts WRONG_ARITY. Pin the rendered wording.

Change it to:

#[test]
fn an_imported_effect_operation_called_with_the_wrong_arity_is_an_error() {
    let (sources, checked) = check_source_in(
        "module a\n\n\
         use other.{Sink}\n\n\
         fn f() -> Int\n\
         \x20 uses\n\
         \x20   Sink.count,\n\
         {\n\
         \x20 Sink.count(1)\n\
         }\n",
        &universe_of(&["module other\n\neffect Sink {\n    fn count() -> Int\n}\n"]),
    );
    assert_eq!(codes_of(&checked.diagnostics), vec![codes::WRONG_ARITY]);
    let text = rendered(&sources, &checked.diagnostics);
    assert!(text.contains("takes 0") || text.contains("1 was given") || text.contains("argument"), "{text}");
}

Only edit that one test. No production code.

Copilot AI changed the title [WIP] Update test for imported effect operation wrong arity Strengthen imported-effect WRONG_ARITY diagnostic test Jul 29, 2026
@onatozmenn
onatozmenn marked this pull request as ready for review July 29, 2026 20:50
Copilot AI requested a review from onatozmenn July 29, 2026 20:50
@onatozmenn
onatozmenn force-pushed the copilot/update-imported-effect-test-arity branch from c50ab22 to 8d35010 Compare July 29, 2026 20:58
@onatozmenn onatozmenn closed this Jul 29, 2026
@onatozmenn
onatozmenn deleted the copilot/update-imported-effect-test-arity branch July 29, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants