-
Notifications
You must be signed in to change notification settings - Fork 722
Consistently error on full circle of circular import aliases #1904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Can some of these be unskipped, then?
|
There was a problem hiding this 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. |
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.