Skip to content

Fix spurious circular-base-type diagnostics after invalid model is usage#10692

Merged
timotheeguerin merged 4 commits into
mainfrom
copilot/fix-check-model-is-errors
May 15, 2026
Merged

Fix spurious circular-base-type diagnostics after invalid model is usage#10692
timotheeguerin merged 4 commits into
mainfrom
copilot/fix-check-model-is-errors

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 14, 2026

checkModelIs started a base-type pending resolution but did not always finish it on early error returns. This could leak pending state and cause unrelated later model is references to report a false circular-base-type diagnostic.

  • Checker: close pending resolution on all error exits

    • Updated checkModelIs in packages/compiler/src/core/checker.ts to call:
      • pendingResolutions.finish(modelSymId, ResolutionKind.BaseType)
    • Added this before each early return undefined path:
      • is with a model expression
      • circular reference short-circuit in TypeReference path
      • non-model/non-array invalid is expression path
  • Regression coverage: prevent duplicate/spurious diagnostics

    • Added focused tests in packages/compiler/test/checker/model.test.ts to verify invalid model is does not leave resolver state behind.
    • New cases assert only the expected is-model error is emitted when another model later references the invalid model.
model A is { x: int32 };
model B is A;
// Expect: only `is-model` (no spurious `circular-base-type`)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • telemetry.astro.build
    • Triggering command: /home/REDACTED/.n/bin/node node /home/REDACTED/work/typespec/typespec/website/node_modules/.bin/../astro/bin/astro.mjs build sh -c ebsite/src/content/docs/docs/emitters/openapi3/reference node bin/node ld.json && pnpm node bash /.bin/node sh /nod�� tspd --enable-experimental gen-extern-signature . node 2/dist/node-gyp-bin/sh r --no-emit l/reference /.bin/node node (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@microsoft-github-policy-service microsoft-github-policy-service Bot added the compiler:core Issues for @typespec/compiler label May 14, 2026
Copilot AI changed the title [WIP] Fix early-return errors in checkModelIs function Fix spurious circular-base-type diagnostics after invalid model is usage May 14, 2026
Copilot AI requested a review from timotheeguerin May 14, 2026 17:27
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 14, 2026

Open in StackBlitz

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

commit: 089693e

@timotheeguerin
Copy link
Copy Markdown
Member

@copilot add changelog

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 14, 2026

@copilot add changelog

Added the changelog entry in .chronus/changes/copilot-fix-check-model-is-errors-2026-4-14-18-52-27.md in commit 8680bbb.

@azure-sdk-automation
Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Comment thread .chronus/changes/copilot-fix-check-model-is-errors-2026-4-14-18-52-27.md Outdated
…8-52-27.md

Co-authored-by: Mark Cowlishaw <1054056+markcowl@users.noreply.github.com>
@timotheeguerin timotheeguerin enabled auto-merge May 14, 2026 20:38
@github-actions
Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/compiler
Show changes

@typespec/compiler - fix ✏️

Fix spurious circular-base-type diagnostics after invalid 'model is' declarations.

@timotheeguerin timotheeguerin added this pull request to the merge queue May 14, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 15, 2026
@timotheeguerin timotheeguerin added this pull request to the merge queue May 15, 2026
Merged via the queue into main with commit 6ca21ce May 15, 2026
26 checks passed
@timotheeguerin timotheeguerin deleted the copilot/fix-check-model-is-errors branch May 15, 2026 00:34
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extra errors when using invalid things with model is

3 participants