Repository navigation
Reject _ as a rename target for a binding that is used - #20599
xperiandri wants to merge 11 commits into
Conversation
✅ Release notes checked
Warning No PR link found in some release notes, please consider adding it.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
T-Gro
left a comment
There was a problem hiding this comment.
🤖 🕵️ AI review — verify independently.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
🔍 Tooling Safety Check — Affects-Build-Infra, Affects-Design-Time, Affects-Restore
|
595873d to
142b96c
Compare
142b96c to
e1c69ea
Compare
e1c69ea to
9ee4e3c
Compare
T-Gro
left a comment
There was a problem hiding this comment.
The diff is still way too big - apply the NoBloat instructions and CodeCompaction skill.
Especially the massive code comments would benefit not just with drastic reduction, but ideally with well named functions/arguments/bindings/types making the intention clear.
If a well named piece of code just tells what the comment says - delete the comment.
- Rename the test helper to
renameUnderCaretand delete its XML walkthrough. - Delete the 9 non-license implementation/test comment lines and use predicates such as
isUnescapedWildcardRenameOfUsedSymbol,hasDeclarationCoveringTriggerSpan, andisUserDeclaredThisVal. - Merge the single-case Fact into the rename theory and make the declaration/use caret cases named theory rows.
- Compact both release-note entries to observable Rename behavior. Remove auto-property desugaring, synthetic-range, and
_.M()mechanism prose.
|
Compacted as requested in d015c35. It includes the compaction of #20598 (32b7ec0), on top of current main (
The diff is +122/-12 (it was +164/-8). |
The compacted notes of dotnet#20598, dotnet#20599 and dotnet#20637 replace the lines they rewrote; the union merge had kept both. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
`MakeAndPublishVal` skipped the sink for any `MemberThisVal` literally named `__`. The target was the self identifier that the auto-property desugaring synthesizes, which sits on the *property name's* range and would therefore shadow the property's own symbol -- a range collision, not a name problem. Filtering by name also hid every `member __.M()` a user writes. Declarations go through `MakeAndPublishVal` and were suppressed, while uses in the body resolve normally and were not, so FCS reported the uses of `__` without its declaration. Editor rename then rewrote the body and left `member __.` behind, silently producing code that no longer compiles. Mark the synthesized ident's range synthetic instead, as the adjacent backing field already does. `TcResultsSinkImpl.allowedRange` drops synthetic ranges for every sink notification, so the auto-property self identifier stays invisible and the name check becomes dead code. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… tests The two comment lines about the range of `base` become the name `shadowsCtorParams`, which also makes the `MemberInfo` match redundant: only `MakeAndPublishBaseVal` builds a base val and it has none. The tests reuse `chooseMemberOrFunctionOrValue`, `getRangeCoords` and `shouldEqual`, and the release note states the observable fix only. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The ranges are an array now, and the tests use Assert.Equal and Assert.Empty instead of FSharp.Test.Assert.shouldEqual. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
`_` is not a referenceable name in F#: in expression position `_.M()` is the shorthand lambda, not a reference. Renaming a self identifier (or any local) that the body actually uses therefore produced a file that no longer compiles. Accept `_` only when the rename rewrites nothing but the declaration. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
FCS reports both the declaration and the uses of a healthy symbol, so a declaration that sits in the file being renamed yet is absent from that file's uses means the rename would rewrite the uses and leave the declaration behind -- the failure mode `member __.M()` just exhibited. Refuse to start the rename instead of corrupting the file. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Nothing covered InlineRenameService before. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`__.TestMethod()` also matched the declaration one line above, whose own self identifier has no uses, so the test placed the caret there and found one location instead of two. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Two review findings on the rename guards. The `_` rule read the replacement after normalization, which strips the backticks of an escaped ``_``. That name is referenceable, so it must stay valid; the rule now looks at the text as typed. The declaration guard compared the symbol's declaration with the ranges of its uses for equality. Seen from a use, the declaration of an active pattern case is the whole `(|A|B|)`, while the definition use is the case itself, so equality never held and renaming `Even` was refused. The guard now asks whether the declaration contains one of the uses; on a file with 166 symbol uses this blocks none, where equality blocked the five active pattern cases. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…e service tests `isUnescapedWildcardRenameOfUsedSymbol` and `hasDeclarationAmongUses` carry what the six comment lines said. The self identifier tests become one theory with labelled rows, the active pattern theory gets labelled rows, and the test file is a root module that calls `FindRenameLocationsAsync(false, false, ...)` like `InlineRenameTests`. The release note states the observable behaviour only. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
d015c35 to
cba9f41
Compare
Fixes #20597
Stacked on #20598
_is not a referenceable name in F# — in expression position_.M()is the shorthand lambda — so renaming a self identifier (or any local) that its body uses produced a file that no longer compiles. Rename now accepts_only when nothing but the declaration would be rewritten.Rename also refuses outright when the symbol's declaration sits in the file being renamed but is missing from the locations to rewrite, rather than rewriting the uses and leaving the declaration behind.
🤖 Generated with Claude Code