Skip to content

Strengthen type-mismatch test to pin Money diagnostic wording - #455

Closed
onatozmenn with Copilot wants to merge 1 commit into
mainfrom
copilot/strengthen-known-sides-test
Closed

Strengthen type-mismatch test to pin Money diagnostic wording#455
onatozmenn with Copilot wants to merge 1 commit into
mainfrom
copilot/strengthen-known-sides-test

Conversation

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

What this changes

The existing test only asserted that a TYPE_MISMATCH diagnostic code existed, which allowed regressions in rendered diagnostic wording. This updates that single test to also require that the rendered message mentions Money.

  • Scope

    • Touches only crates/deed-typeck/tests/checking.rs
    • Modifies only an_operator_with_two_known_sides_is_checked
  • Test assertion strengthening

    • Keeps the existing code-level assertion:
      • codes_of(&checked.diagnostics).contains(&codes::TYPE_MISMATCH)
    • Adds rendered-text pinning for the operand type:
      • message must contain either found \Money`or ``Money` ``
  • Snippet

    let text = rendered(&sources, &checked.diagnostics);
    assert!(text.contains("found `Money`") || text.contains("`Money`"), "{text}");

Why this way

Code-only checks verify classification, not user-facing clarity. Pinning Money in rendered output makes the test guard both type-check behavior and diagnostic usefulness while staying tolerant to minor phrasing variation.

What it still does not do

It does not fully pin the complete diagnostic sentence; it only requires inclusion of the relevant type name (Money) to avoid over-coupling to exact formatting.

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: Used to draft and implement the test update.

Original prompt

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

It currently only checks that TYPE_MISMATCH is among the codes. Pin rendered wording.

Change it to:

#[test]
fn an_operator_with_two_known_sides_is_checked() {
    let (sources, checked) = check_source(
        "module a\n\nrecord Money { units: Int }\n\nfn f(m: Money, n: Money) -> Int { m + n }\n",
    );
    assert!(
        codes_of(&checked.diagnostics).contains(&codes::TYPE_MISMATCH),
        "{}",
        rendered(&sources, &checked.diagnostics)
    );
    let text = rendered(&sources, &checked.diagnostics);
    assert!(text.contains("found `Money`") || text.contains("`Money`"), "{text}");
}

Only edit that one test. No production code.

Copilot AI changed the title [WIP] Update test to strengthen known sides check Strengthen type-mismatch test to pin Money diagnostic wording Jul 29, 2026
Copilot AI requested a review from onatozmenn July 29, 2026 20:47
@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/strengthen-known-sides-test branch from 3b65d45 to b02a6f9 Compare July 29, 2026 20:55
@onatozmenn
onatozmenn force-pushed the copilot/strengthen-known-sides-test branch from b02a6f9 to 78d7fcf Compare July 29, 2026 20:57
@onatozmenn onatozmenn closed this Jul 29, 2026
@onatozmenn
onatozmenn deleted the copilot/strengthen-known-sides-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