Skip to content

Warn on duplicate #suppress directives on the same node#11113

Open
timotheeguerin with Copilot wants to merge 5 commits into
mainfrom
copilot/add-warning-on-double-suppression
Open

Warn on duplicate #suppress directives on the same node#11113
timotheeguerin with Copilot wants to merge 5 commits into
mainfrom
copilot/add-warning-on-double-suppression

Conversation

Copilot AI commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Duplicate #suppress directives for the same diagnostic on a single node were silently accepted. This change adds a compiler warning so redundant suppressions are surfaced whether or not they include a message.

  • Compiler behavior

    • detect repeated #suppress "<code>" directives attached to the same node
    • emit a new duplicate-suppression warning on the later directive
    • preserve existing suppression behavior for the first matching directive
  • Diagnostic definition

    • add a dedicated warning message for duplicate suppressions:
      • Diagnostic "<code>" is already suppressed on this node.
  • Coverage

    • add focused tests for duplicate suppressions:
      • with a suppression message
      • without a suppression message
model Test {
  #suppress "deprecated" "Msg"
  #suppress "deprecated" "Msg"
  prop: Dep;
}

This now reports a duplicate-suppression warning on the second directive.

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the compiler:core Issues for @typespec/compiler label Jun 30, 2026
Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Copilot AI changed the title [WIP] Add warning for double suppression in code Warn on duplicate #suppress directives on the same node Jun 30, 2026
Copilot AI requested a review from timotheeguerin June 30, 2026 12:48
@pkg-pr-new

pkg-pr-new Bot commented Jun 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/compiler@11113

commit: 5f683b3

@timotheeguerin

Copy link
Copy Markdown
Member

@copilto add changelog

@timotheeguerin timotheeguerin added the int:azure-specs Run integration tests against azure-rest-api-specs label Jun 30, 2026
@timotheeguerin

Copy link
Copy Markdown
Member

@copilot add changelog

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>

Copilot AI commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

@copilot add changelog

Addressed in c34f798.

@azure-sdk-automation

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@markcowl markcowl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, need a PR to remove all the duplicate suppressions, which we should be able to do without this update

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/compiler
Show changes

@typespec/compiler - fix ✏️

Warn on duplicate #suppress directives on the same node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler:core Issues for @typespec/compiler int:azure-specs Run integration tests against azure-rest-api-specs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add warning on double suppression

3 participants