Skip to content

Strengthen all_arms_must_agree test to pin rendered diagnostic wording - #453

Closed
onatozmenn with Copilot wants to merge 1 commit into
mainfrom
copilot/update-all-arms-must-agree-test
Closed

Strengthen all_arms_must_agree test to pin rendered diagnostic wording#453
onatozmenn with Copilot wants to merge 1 commit into
mainfrom
copilot/update-all-arms-must-agree-test

Conversation

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

The test only verified the diagnostic code (TYPE_MISMATCH) but not the message text, leaving regressions in rendered output undetected.

What this changes

Pin the rendered wording of the all_arms_must_agree diagnostic by capturing sources from check_source and asserting the output contains "found \Bool`"or"expected `Int`"`:

#[test]
fn all_arms_must_agree() {
    let (sources, checked) = check_source(
        "module a\n\nchoice E { A, B }\n\nfn f(e: E) -> Int {\n  match e {\n    A => 1,\n    B => true,\n  }\n}\n",
    );
    assert_eq!(codes_of(&checked.diagnostics), vec![codes::TYPE_MISMATCH]);
    let text = rendered(&sources, &checked.diagnostics);
    assert!(text.contains("found `Bool`") || text.contains("expected `Int`"), "{text}");
}

Why this way

The || covers both "found unexpected type" and "expected type" phrasing conventions without over-constraining the exact message format, while still catching silent regressions in diagnostic rendering.

What it still does not do

Does not pin the full rendered message verbatim — intentional, to avoid brittleness from minor wording tweaks that don't affect diagnostic quality.

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 assisted.

Original prompt

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

Current test only asserts TYPE_MISMATCH. Pin the rendered wording.

Change it to:

#[test]
fn all_arms_must_agree() {
    let (sources, checked) = check_source(
        "module a\n\nchoice E { A, B }\n\nfn f(e: E) -> Int {\n  match e {\n    A => 1,\n    B => true,\n  }\n}\n",
    );
    assert_eq!(codes_of(&checked.diagnostics), vec![codes::TYPE_MISMATCH]);
    let text = rendered(&sources, &checked.diagnostics);
    assert!(text.contains("found `Bool`") || text.contains("expected `Int`"), "{text}");
}

Only edit that one test. No production code.

Copilot AI changed the title [WIP] Update all_arms_must_agree test to assert rendered wording Strengthen all_arms_must_agree test to pin rendered diagnostic wording Jul 29, 2026
Copilot AI requested a review from onatozmenn July 29, 2026 20:46
@onatozmenn
onatozmenn marked this pull request as ready for review July 29, 2026 20:49
onatozmenn added a commit that referenced this pull request Jul 29, 2026
@onatozmenn
onatozmenn force-pushed the copilot/update-all-arms-must-agree-test branch from 40f4c06 to 136d15f Compare July 29, 2026 20:55
@onatozmenn
onatozmenn force-pushed the copilot/update-all-arms-must-agree-test branch from 136d15f to cf14c77 Compare July 29, 2026 20:57
@onatozmenn onatozmenn closed this Jul 29, 2026
@onatozmenn
onatozmenn deleted the copilot/update-all-arms-must-agree-test 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