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

match expressions missing inside task ce confusing error #15748

Open
jkone27 opened this issue Aug 4, 2023 · 2 comments
Open

match expressions missing inside task ce confusing error #15748

jkone27 opened this issue Aug 4, 2023 · 2 comments
Labels
Area-Diagnostics mistakes and possible improvements to diagnostics Feature Improvement
Milestone

Comments

@jkone27
Copy link
Contributor

jkone27 commented Aug 4, 2023

is this related to the same? this is annoying with match expressions inside task ce...
image

in my case the reason was just the missing _ in:
| _ ->
for all cases, so I think the error is misleading, should suggest missing match case instead.

i didn't see it right away because the compiler error was not useful...

Originally posted by @jkone27 in #4653 (comment)

@github-actions github-actions bot added this to the Backlog milestone Aug 4, 2023
@Happypig375 Happypig375 added Area-ComputationExpressions End-to-end experience for computation expressions (except async and state machine compilation) Area-Compiler-PatternMatching pattern compilation, active patterns, performance, codegen labels Aug 8, 2023
@nojaf
Copy link
Contributor

nojaf commented Aug 16, 2023

Interestingly enough, I believe this only happens when there is no space between | and ->.

AST without space

AST with space

Without the space, the |-> is considered to be an operator.
Perhaps this is more something an IDE could point out, that you probably meant | _ ->.
I'm not sure though.

@jkone27
Copy link
Contributor Author

jkone27 commented Aug 30, 2023

here is a small test fsx to give it a go

type SomeUnion =
    | First
    | Second
    | Third


let testMatch su =
    match su with
    | First -> "hey"
    |-> "hello"  // should maybe hint | _ -> or match case is given (?) 


let testMatchTwo su =
    task { 
        let z = Some(1)

        match z with
        |Some(n) -> 
            return ""
        |->    // should maybe hint | _ -> or match case is given (?) error disappears here
            let! x = Task.Delay(200)
            return "hello"  // construct may only be used inside a CE (?) no mention of |->
    }

@0101 0101 added Area-Diagnostics mistakes and possible improvements to diagnostics Feature Improvement and removed Area-Compiler-PatternMatching pattern compilation, active patterns, performance, codegen Area-ComputationExpressions End-to-end experience for computation expressions (except async and state machine compilation) Needs-Triage labels Sep 18, 2023
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
Projects
Status: New
Development

No branches or pull requests

4 participants