Skip to content

Commit 72baf1e

Browse files
authored
Completion: fix completion in empty dot lambda prefix (#16829)
1 parent 2810bd7 commit 72baf1e

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

docs/release-notes/.FSharp.Compiler.Service/8.0.300.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* Enforce AttributeTargets on enums ([PR #16887](https://github.com/dotnet/fsharp/pull/16887))
2626
* Completion: fix for unfinished record field decl ([PR #16893](https://github.com/dotnet/fsharp/pull/16893))
2727
* Enforce AttributeTargets on delegates ([PR #16891](https://github.com/dotnet/fsharp/pull/16891))
28+
* Completion: fix completion in empty dot lambda prefix ([#16829](https://github.com/dotnet/fsharp/pull/16829))
2829
* Fix StackOverflow when checking non-recursive bindings in module or namespace in `fscAnyCpu`/`fsiAnyCpu`. ([PR #16908](https://github.com/dotnet/fsharp/pull/16908))
2930

3031
### Added

src/Compiler/SyntaxTree/SyntaxTreeOps.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ let rec pushUnaryArg expr arg =
100100
| SynExpr.TypeApp(innerExpr, mLess, tyargs, mCommas, mGreater, mTypars, m) ->
101101
let innerExpr = pushUnaryArg innerExpr arg
102102
SynExpr.TypeApp(innerExpr, mLess, tyargs, mCommas, mGreater, mTypars, m)
103+
| SynExpr.ArbitraryAfterError(_, m) when m.Start = m.End ->
104+
SynExpr.DiscardAfterMissingQualificationAfterDot(SynExpr.Ident arg, m.StartRange, unionRanges arg.idRange m)
103105
| _ ->
104106
errorR (Error(FSComp.SR.tcDotLambdaAtNotSupportedExpression (), expr.Range))
105107
expr

tests/service/CompletionTests.fs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ let myFancyFunc (x:string) =
8282
|> _.ToL"""
8383
assertHasItemWithNames ["ToLower"] info
8484

85+
[<Test>]
86+
let ``Underscore dot lambda - No prefix`` () =
87+
let info = getCompletionInfo "[s] |> List.map _. " (3, 18) """
88+
let s = ""
89+
[s] |> List.map _.
90+
"""
91+
assertHasItemWithNames ["Length"] info
92+
8593
[<Test>]
8694
let ``Type decl - Record - Field type 01`` () =
8795
let info = getCompletionInfo "type Record = { Field: }" (2, 23) """

0 commit comments

Comments
 (0)