Skip to content

Improve error reporting: Let as last line in block #1162

@isaacabraham

Description

@isaacabraham

What

(From @tpetricek). The following code snippet leads to the resulting error message: -

let sum = 0
for x in 0 .. 10 do
    let sum = sum + x

error FS0588: Block following this 'let' is unfinished. Expect an expression.

Why

The above error message, whilst factually correct, does not explain to the beginner what this is and why it occurs. There are of course two errors here - one that the user is trying to mutate a value (which should be ignored from this issue as it is covered elsewhere) and the second which is that there is no result from the block.

How

Suggest: Every code block is an expression and must have a result. 'let' is not an expression and cannot be the final code element in a block. Consider returning something explicit from this block.

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