Skip to content

Conversation

@kerams
Copy link
Contributor

@kerams kerams commented Apr 2, 2022

Given

try
    match box 5 with
    | :? str as x -> printfn "%s" x
    | _ -> raise (ArgumentException ())
with :? Arg ->
    ()

pressing Ctrl-space on str or Arg will now only show type-like completions. Currently the list also contains keywords and functions.

| SynExpr.Match (expr=synExpr; clauses=synMatchClauseList) ->
[yield dive synExpr synExpr.Range traverseSynExpr
yield! synMatchClauseList |> List.map (fun x -> dive x x.RangeOfGuardAndRhs (traverseSynMatchClause path))]
yield! synMatchClauseList |> List.map (fun x -> dive x x.Range (traverseSynMatchClause path))]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why RangeOfGuardAndRhs was used here. MatchLambda and TryWith traversals use Range, so this change seemed appropriate. Without it VisitPat is never fired in a match clause pattern, and so we don't get a chance to create the right completion context.

match p with
| SynPat.Paren (p, _) -> traversePat path p
| SynPat.Or (p1, p2, _, _) -> [ p1; p2] |> List.tryPick (traversePat path)
| SynPat.As (p1, p2, _)
Copy link
Contributor Author

@kerams kerams Apr 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looked like an omission. I don't see why we wouldn't want to dive into both subpatterns here. Without it VisitPat is not fired for IsInst when the type test is paired with an as (which it very often is).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

completely agree with this logic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants