Skip to content

Improve error reporting: usage of '<-' operator on non mutable bindings #1110

@smoothdeveloper

Description

@smoothdeveloper

What

Sometimes assignment operator is used on immutable values, currently, for all cases the compilers gives This value is not mutable :

let x = 10
x <- 20

Why

In cases where it is straightforward to devise a fix (changing simple value to mutable), giving help to developers unfamiliar with F# on how to change their code smooths the learning curve.

How

The message could read value 'x' is not mutable, please check that it is declared as mutable: 'let mutable x = 10' if you intend to mutate it.

If it is not easily possible from AST to quote the RHS expression, we can still show the LHS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions