Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Tracked by #1103
Thorium opened this issue Apr 5, 2017 · 2 comments
Open
Tracked by #1103

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

Thorium opened this issue Apr 5, 2017 · 2 comments
Labels
Area-Diagnostics mistakes and possible improvements to diagnostics Feature Improvement Theme-Simple-F# A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language.
Milestone

Comments

@Thorium
Copy link
Contributor

Thorium commented Apr 5, 2017

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

@dsyme
Copy link
Contributor

dsyme commented Apr 29, 2017

Linking master "error improvement" bug #1103

cc @isaacabraham

@cartermp cartermp added this to the vFuture milestone Apr 30, 2017
@cartermp cartermp modified the milestones: vFuture, 16.0 Jul 29, 2018
@cartermp cartermp modified the milestones: 16.0, Unknown Aug 25, 2018
@ajeckmans
Copy link

After being pushed a bit by and with some help from @smoothdeveloper I looked at this issue. I've successfully reproduced it with a smaller code sample in FSI

for i in [|1|]
i
;;

I put a breakpoint in CompilerDiagnostics:1282 and looked at the context that is available. I'm now stuck though. Any change I make has zero impact on this error message. Can anyone point me in the right direction?

I've now started looking at pars.fsy, but I'm unsure how to actually bring about a change in there or whether it is even needed. As far as I can tell this is caused by a weird combination of the parser where some of the rules surrounding FOR are "conflicting" (for a lack of a better word), and it actually does not raise the parsForDoExpected which is checked in some of the rules.
Or maybe it is raised, but not handled correctly? I can't even see how FSComp.SR.parsForDoExpected actually surfaces at all.

@dsyme dsyme added the Theme-Simple-F# A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language. label Sep 16, 2021
@dsyme dsyme added Area-Diagnostics mistakes and possible improvements to diagnostics and removed Area-Compiler labels Mar 31, 2022
@vzarytovskii vzarytovskii reopened this Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Diagnostics mistakes and possible improvements to diagnostics Feature Improvement Theme-Simple-F# A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language.
Projects
Archived in project
Development

No branches or pull requests

6 participants