Skip to content

Code completion doesn't work inside Or pattern #16055

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

Open
auduchinok opened this issue Sep 27, 2023 · 6 comments
Open

Code completion doesn't work inside Or pattern #16055

auduchinok opened this issue Sep 27, 2023 · 6 comments
Labels
Area-LangService-AutoComplete autocomplete/intellisense Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. Regression
Milestone

Comments

@auduchinok
Copy link
Member

Consider code completion is triggered after | in this code:

module Module

match () with
| (_ | )

Expected: types, union cases, literals, and active patterns are provided
Actual: the items are not provided

This may be related to either changes in the parser or to completion filtering.

@0101
Copy link
Contributor

0101 commented Oct 2, 2023

Can we have a more meaningful example? I'm a bit confused by the example expression here.

@vzarytovskii
Copy link
Member

Can we have a more meaningful example? I'm a bit confused by the example expression here.

I presume this:

module Module

match () with
| (_ | <here should be an autocomplete, but there's none> )

@0101
Copy link
Contributor

0101 commented Oct 3, 2023

I didn't know you could put parentheses around some cases. Is there even any point to that?

Also in this example, you already gave a _ which will match anything, so there are no meaningful completions because that branch will never be matched. And even if it was, you're matching () so there are no really meaningful completions for that.

I don't know if in the code we are looking at any of that, but still, a better example would be something where some completions would make sense. In this particular case nothing being suggested looks like a feature 😄

@auduchinok
Copy link
Member Author

I didn't know you could put parentheses around some cases. Is there even any point to that?
Also in this example, you already gave a _ which will match anything, so there are no meaningful completions because that branch will never be matched.

In test cases like this it doesn't matter if _ is matched, or if there's _ at all. It's just a minimized version of a particular language construction used in a code completion test. The example could be longer and with more identifiers:

type U =
    | A
    | B
    | C

let f (u: U) =
    match u with
    | (A | {caret}) -> ()

Here, at the {caret} position, code completion is expected to work. The minimized example shows exactly this without the noise added by additional definitions.

@kerams
Copy link
Contributor

kerams commented Oct 3, 2023

There's a SynPat.Wild with non-zero-length range in that exact position for some reason. It is interpreted as a real wildcard, hence no completions. Representation of incomplete constructs could do with an overhaul in the syntax tree.

You get completions as soon as you type another letter, so while this is a regression, it's nothing tragic.

@auduchinok
Copy link
Member Author

@kerams Thanks for investigation!

Representation of incomplete constructs could do with an overhaul in the syntax tree.

I agree, we should make the pattern errors look similar to the expression ones.

@0101 0101 added Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. Area-LangService-AutoComplete autocomplete/intellisense and removed Needs-Triage labels Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-LangService-AutoComplete autocomplete/intellisense Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. Regression
Projects
None yet
Development

No branches or pull requests

4 participants