Skip to content

Improve error reporting: do-keyword missing in a query #2799

@Thorium

Description

@Thorium

What

The following code results in an error message which could be improved upon: -

let x =
    query {
        for i in [|1;2;3|]
        where (i<2)
        select i
    }

The error is: -
error FS0010: Unexpected identifier in expression. Expected '->' or other token.

Why

The for-in-do-syntax (for i in [|1;2;3|] do) differs from other languages, and do is kind of non-intuitive here, so it is easy to forget. Also the error message is very cryptic and underlines the next statement (here where) so the developer tries to seek the problem from wrong place.

How

A better error might be something that would mention what is the actual problem here, that you need the do-keyword.

Related to #1103

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Diagnosticsmistakes and possible improvements to diagnosticsFeature ImprovementTheme-Simple-F#A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language.

    Type

    No type

    Projects

    Status

    In Progress

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions