Skip to content

Rename accepts _ as a new name for a value that is used #20597

Description

@xperiandri
type RenameTest() =
    member this.TestMethod() = "Hello, World!"
    member this.TestMethodThis() = this.TestMethod()

Renaming this to _ in TestMethodThis is accepted and produces member _.TestMethodThis() = _.TestMethod(), which does not compile — in expression position _.TestMethod() is the shorthand-lambda syntax, not a reference to the self identifier.

_ is only a legal name for a binding that is never referenced, so Rename should reject it whenever the rename would rewrite more than the declaration itself. This is not specific to self identifiers — renaming any used local to _ breaks the same way.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions