Skip to content

fix: suppress secondary switch diagnostics - W-24797835 - #831

Open
peternhale wants to merge 1 commit into
ph/W-24797836-switch-pattern-variable-scopefrom
ph/W-24797835-suppress-secondary-switch-diagnostics
Open

peternhale wants to merge 1 commit into
ph/W-24797836-switch-pattern-variable-scopefrom
ph/W-24797835-suppress-secondary-switch-diagnostics

Conversation

@peternhale

@peternhale peternhale commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Aligns switch diagnostics with Jorje when the switch expression has a known unsupported type.

  • Emits the primary ILLEGAL_SWITCH_EXPRESSION_TYPE diagnostic as soon as the switch expression is classified as unsupported.
  • Stops clause-level semantic validation for that switch, preventing derivative diagnostics whose validity depends on a supported expression type.
  • Prevents cascading diagnostics for type-variable clauses, literal compatibility, duplicate clauses, constant validation, and enum clause matching.
  • Does not suppress parser syntax diagnostics or independent semantic diagnostics from other validators.

What issues does this PR fix or reference?

@W-24797835@

Test Plan

  • Added unsupported-switch regressions asserting exactly one ILLEGAL_SWITCH_EXPRESSION_TYPE for:
    • multiple when Type variable clauses
    • literal when clauses
    • duplicate literal when clauses
  • pnpm --filter @salesforce/apex-lsp-parser-ast run lint
  • pnpm exec vitest run packages/apex-parser-ast/test/semantics/validation/validators/SwitchStatementValidator.test.ts --reporter=default
    • 23 passed
  • pnpm --filter @salesforce/apex-lsp-parser-ast run test
    • 2,816 passed, 446 skipped

Stack created with GitHub Stacks CLI • Give Feedback 💬

@peternhale
peternhale requested a review from a team as a code owner November 13, 2026 15:02
@peternhale
peternhale added this pull request to stack #818 November 13, 2026 15:02
@github-actions

Copy link
Copy Markdown
Contributor

E2E Test Results Summary

Run: 2196

No test results found

Searched for **/junit.xml and **/results.json under downloaded test-results/ artifacts.

Specs With No Results

The following specs did not produce test results. This usually means the job crashed before tests ran (e.g. build failure, infra error, dependency download timeout).

  • apex-capability-gating.spec.ts: Did not run — check the job logs
  • apex-extension-core.spec.ts: Did not run — check the job logs
  • apex-extract-constant.spec.ts: Did not run — check the job logs
  • apex-extract-variable.spec.ts: Did not run — check the job logs
  • apex-goto-definition.spec.ts: Did not run — check the job logs
  • apex-goto-definition-advanced.spec.ts: Did not run — check the job logs
  • apex-hover.spec.ts: Did not run — check the job logs
  • apex-hover-stdlib.spec.ts: Did not run — check the job logs
  • apex-lsp-integration.spec.ts: Did not run — check the job logs
  • apex-outline.spec.ts: Did not run — check the job logs
  • apex-rename-symbol.spec.ts: Did not run — check the job logs

Artifacts

View detailed test reports in the Artifacts section.

@peternhale
peternhale requested review from jonnyhork and removed request for mingxuanzhangsfdx November 13, 2026 15:05
@peternhale peternhale changed the title fix: suppress secondary swithc diagnostics - W-24797835 fix: suppress secondary switch diagnostics - W-24797835 Nov 13, 2026
@peternhale
peternhale force-pushed the ph/W-24797835-suppress-secondary-switch-diagnostics branch from 86695ca to 3c68365 Compare November 13, 2026 17:07
@jonnyhork

Copy link
Copy Markdown

@peternhale The error suppression looks right in these QA checks:

  • Unsupported switches with type patterns or duplicate literals settle to one illegal.switch.expression.type error.
  • An invalid nested Integer switch still reports its own type error.
  • An unrelated undefined variable still gets reported.
  • The valid Integer-switch example stays clear.

The screenshot shows the duplicate-literal case after analysis finishes. I briefly saw the duplicate-branch diagnostic before type resolution completed, then it changed to the primary unsupported-expression error. The two things that may need another look are on #830.

Unsupported switch reports only the primary error despite duplicate literals

@peternhale
peternhale force-pushed the ph/W-24797835-suppress-secondary-switch-diagnostics branch from 3c68365 to 4097ad4 Compare November 13, 2026 20:45
@github-actions

Copy link
Copy Markdown
Contributor

E2E Test Results Summary

Run: 2209

Test Results

  • Passed: 71
  • Failed: 1
  • Errors: 0
  • Total: 72

Passing Rate by File

  • apex-extension-core.spec.ts/junit.xml: 100.0% (8/8 passed)
  • apex-extract-constant.spec.ts/junit.xml: 100.0% (1/1 passed)
  • apex-hover.spec.ts/junit.xml: 0.0% (0/1 passed)
  • apex-extract-variable.spec.ts/junit.xml: 100.0% (1/1 passed)
  • apex-goto-definition.spec.ts/junit.xml: 100.0% (20/20 passed)
  • apex-hover-stdlib.spec.ts/junit.xml: 100.0% (1/1 passed)
  • apex-outline.spec.ts/junit.xml: 100.0% (11/11 passed)
  • apex-goto-definition-advanced.spec.ts/junit.xml: 100.0% (3/3 passed)
  • apex-lsp-integration.spec.ts/junit.xml: 100.0% (16/16 passed)
  • apex-rename-symbol.spec.ts/junit.xml: 100.0% (7/7 passed)
  • apex-capability-gating.spec.ts/junit.xml: 100.0% (3/3 passed)

Artifacts

View detailed test reports in the Artifacts section.

Some tests failed

@peternhale
peternhale force-pushed the ph/W-24797835-suppress-secondary-switch-diagnostics branch 2 times, most recently from cc86118 to bf1805d Compare November 16, 2026 18:25
@peternhale
peternhale force-pushed the ph/W-24797835-suppress-secondary-switch-diagnostics branch from bf1805d to ec9ddb0 Compare November 17, 2026 15:44
@peternhale
peternhale force-pushed the ph/W-24797835-suppress-secondary-switch-diagnostics branch from ec9ddb0 to 1739cec Compare November 18, 2026 13:35

This branch has not been deployed

No deployments
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