Skip to content

Conversation

ahejlsberg
Copy link
Member

With this PR we consistently error on all nodes in the full circle of circular import alias declarations. This in particular means that our error reporting is unaffected by the number of checkers used to check a program.

Fixes #1851.

@ahejlsberg ahejlsberg requested review from andrewbranch, Copilot and jakebailey and removed request for Copilot October 18, 2025 21:57
@jakebailey
Copy link
Member

Can some of these be unskipped, then?

var concurrentSkippedErrorBaselines = map[string]string{

@Copilot Copilot AI review requested due to automatic review settings October 19, 2025 15:19
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures circular import alias errors are reported consistently on every node participating in the cycle, independent of checker partitioning.

  • Introduces alias-target cycle detection via the type resolution stack (new TypeSystemPropertyNameAliasTarget) and removes the prior resolvingSymbol sentinel approach.
  • Updates baselines to include additional circular alias diagnostics for all nodes in each cycle and removes skipped error baseline entries.
  • Removes the InternalSymbolNameResolving constant and associated field from Checker.

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/checker/checker.go Reworks alias resolution logic to use type resolution tracking for circular detection and adds AliasTarget property handling.
internal/ast/symbol.go Removes obsolete InternalSymbolNameResolving constant tied to old sentinel mechanism.
internal/testrunner/compiler_runner.go Drops prior skip entries now that circular alias errors are consistently reported.
testdata/baselines/reference/submodule/conformance/circular1.errors.txt.diff Baseline diff reflecting additional circular alias error reported (grammar issue introduced).
testdata/baselines/reference/submodule/conformance/circular1.errors.txt Updated baseline showing new error; contains a singular/plural grammar issue.
testdata/baselines/reference/submodule/conformance/circular3.errors*.txt* Baselines updated to show full set of circular alias errors across both files.
testdata/baselines/reference/submodule/compiler/exportAsNamespaceConflict.errors*.txt* Baselines updated to add circular alias diagnostic on export assignment.
testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport.errors*.txt* Baselines updated to include circular alias diagnostics at import and export points.
testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport2.errors*.txt* Baselines updated with additional circular alias diagnostics for malformed import/export.
testdata/baselines/reference/submodule/compiler/circularModuleImports.errors*.txt* Baselines updated to report circular alias errors for both aliases in module scope.

@ahejlsberg
Copy link
Member Author

Can some of these be unskipped, then?

Yes, all but two of them!

func (c *Checker) tryResolveAlias(symbol *ast.Symbol) *ast.Symbol {
links := c.aliasSymbolLinks.Get(symbol)
if links.aliasTarget != c.resolvingSymbol {
if links.aliasTarget != nil || c.findResolutionCycleStartIndex(symbol, TypeSystemPropertyNameAliasTarget) < 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Hopefully this extra find isn't too expensive, given how often we resolve aliases.

Copy link
Member Author

Choose a reason for hiding this comment

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

tryResolveAlias is only called when generating spelling correction suggestions, so not an issue at all. And anyway, every call to pushTypeResolution has a call to that find method with no issues.

@ahejlsberg ahejlsberg added this pull request to the merge queue Oct 20, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Oct 20, 2025
@jakebailey jakebailey added this pull request to the merge queue Oct 20, 2025
Merged via the queue into main with commit 7ee8b4e Oct 20, 2025
22 checks passed
@jakebailey jakebailey deleted the fix-1851 branch October 20, 2025 19:00
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.

Circular alias error locations differ based on number of checkers

3 participants