Skip to content

Fix issue 20411 - Don't suggest a variable as spelling fix while resolving its own initializer - #23760

Draft
usefahmed07 wants to merge 1 commit into
dlang:masterfrom
usefahmed07:fix/20411-var-self-suggestion
Draft

Fix issue 20411 - Don't suggest a variable as spelling fix while resolving its own initializer#23760
usefahmed07 wants to merge 1 commit into
dlang:masterfrom
usefahmed07:fix/20411-var-self-suggestion

Conversation

@usefahmed07

Copy link
Copy Markdown
Contributor

Fixes #20411

@usefahmed07

Copy link
Copy Markdown
Contributor Author

@thewilsonator The CI failures seem unrelated to this PR. I get the same errors on a clean master checkout on all platforms.

I tested the fix and the new regression test (fail_compilation/fix20411.d) locally with a freshly built compiler, and they work fine.

@thewilsonator

Copy link
Copy Markdown
Contributor

If you think the CI is unrelated, rebase or force-push to retrigger it.

The previous check (decl.isVarDeclaration() && decl.inuse) was too
broad: dsym.inuse is also set while resolving a variable's explicit
type (e.g. 'Foo foo;'), not just while resolving its own initializer.
That caused fail_compilation/dip22b.d to lose its expected suggestion.

Use sc.varDecl instead (already used for issue 24051), which is only
set while the variable's own initializer expression is being
resolved, and mark it during initializer-type inference too so the
original issue (const almostSimilar = AlmostSimilar;) stays fixed
without affecting explicit-type resolution.

Fixes dlang#20411
@usefahmed07
usefahmed07 force-pushed the fix/20411-var-self-suggestion branch from 5d6482a to f5d340b Compare September 2, 2026 05:43
@usefahmed07

Copy link
Copy Markdown
Contributor Author

@thewilsonator Rebased and pushed. CI still fails with the same unrelated druntime
error not from this PR.

@usefahmed07

Copy link
Copy Markdown
Contributor Author

@thewilsonator i think #23102 it has a connection about this PR take a look

@usefahmed07
usefahmed07 marked this pull request as draft September 8, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spellchecker in the initializer matches the declaration

2 participants