From a9e1cf81273da1046f178c18953a30c7eb7ecb95 Mon Sep 17 00:00:00 2001 From: Petr Date: Tue, 22 Nov 2022 15:21:07 +0100 Subject: [PATCH 1/2] Tests --- src/Compiler/Service/ServiceParseTreeWalk.fs | 6 +-- .../Hints/InlineTypeHintTests.fs | 38 +++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/Compiler/Service/ServiceParseTreeWalk.fs b/src/Compiler/Service/ServiceParseTreeWalk.fs index 2c61c20036c..2a335d274e9 100644 --- a/src/Compiler/Service/ServiceParseTreeWalk.fs +++ b/src/Compiler/Service/ServiceParseTreeWalk.fs @@ -260,12 +260,10 @@ module SyntaxTraversal = | [ x ] -> x () | _ -> #if DEBUG - assert false - failwithf "multiple disjoint AST node ranges claimed to contain (%A) from %+A" pos debugObj -#else + printf "multiple disjoint AST node ranges claimed to contain (%A) from %+A" pos debugObj +#endif ignore debugObj None -#endif /// traverse an implementation file walking all the way down to SynExpr or TypeAbbrev at a particular location /// diff --git a/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineTypeHintTests.fs b/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineTypeHintTests.fs index f2818954ee2..a8445ede5e4 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineTypeHintTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineTypeHintTests.fs @@ -145,3 +145,41 @@ type Song() as x = let result = getTypeHints document Assert.IsEmpty(result) + + [] + let ``Hints are shown for lambdas`` () = + let code = + """ +let iamboring() = + fun x -> x +""" + + let document = getFsDocument code + let expected = [ { Content = ": 'a"; Location = (2, 10) } ] + + let actual = getTypeHints document + + Assert.AreEqual(expected, actual) + + [] + let ``Hints are shown for lambdas with tuples`` () = + let code = + """ +let zip4 (l1: 'a list) (l2: 'b list) (l3: 'c list) (l4: 'd list) = + List.zip l1 (List.zip3 l2 l3 l4) + |> List.map (fun (x1, (x2, x3, x4)) -> (x1, x2, x3, x4)) +""" + + let document = getFsDocument code + + let expected = + [ + { Content = ": 'a"; Location = (3, 25) } + { Content = ": 'b"; Location = (3, 30) } + { Content = ": 'c"; Location = (3, 34) } + { Content = ": 'd"; Location = (3, 38) } + ] + + let actual = getTypeHints document + + CollectionAssert.AreEquivalent(expected, actual) From 22f97b28d9ad2e45f9e3e258b2d5cf3ca31bb6ea Mon Sep 17 00:00:00 2001 From: Petr Date: Tue, 22 Nov 2022 15:22:48 +0100 Subject: [PATCH 2/2] Update InlineParameterNameHints.fs --- .../src/FSharp.Editor/Hints/InlineParameterNameHints.fs | 3 --- 1 file changed, 3 deletions(-) diff --git a/vsintegration/src/FSharp.Editor/Hints/InlineParameterNameHints.fs b/vsintegration/src/FSharp.Editor/Hints/InlineParameterNameHints.fs index d28df0c53ef..8fb16d16d04 100644 --- a/vsintegration/src/FSharp.Editor/Hints/InlineParameterNameHints.fs +++ b/vsintegration/src/FSharp.Editor/Hints/InlineParameterNameHints.fs @@ -31,9 +31,7 @@ module InlineParameterNameHints = not field.IsNameGenerated let isMemberOrFunctionOrValueValidForHint (symbol: FSharpMemberOrFunctionOrValue) (symbolUse: FSharpSymbolUse) = - // make sure we're looking at a call site and not the definition if symbolUse.IsFromUse then - // is there a better way? let isNotBuiltInOperator = symbol.DeclaringEntity |> Option.exists (fun entity -> entity.CompiledName <> "Operators") @@ -45,7 +43,6 @@ module InlineParameterNameHints = false let isUnionCaseValidForHint (symbol: FSharpUnionCase) (symbolUse: FSharpSymbolUse) = - // is the union case being used as a constructor and is it not Cons symbolUse.IsFromUse && symbol.DisplayName <> "(::)"