diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 9f31d7f600e..a8bb8570206 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -9438,7 +9438,8 @@ and GetNewInferenceTypeForMethodArg (cenv: cenv) env tpenv x = GetNewInferenceTypeForMethodArg cenv env tpenv a | SynExpr.AddressOf (true, a, _, m) -> mkByrefTyWithInference g (GetNewInferenceTypeForMethodArg cenv env tpenv a) (NewByRefKindInferenceType g m) - | SynExpr.Lambda (body = a) -> + | SynExpr.Lambda (body = a) + | SynExpr.DotLambda (expr = a) -> mkFunTy g (NewInferenceType g) (GetNewInferenceTypeForMethodArg cenv env tpenv a) | SynExpr.Quote (_, raw, a, _, _) -> if raw then mkRawQuotedExprTy g diff --git a/src/Compiler/Checking/MethodCalls.fs b/src/Compiler/Checking/MethodCalls.fs index d7e09b86aeb..4878c66511c 100644 --- a/src/Compiler/Checking/MethodCalls.fs +++ b/src/Compiler/Checking/MethodCalls.fs @@ -841,7 +841,7 @@ let InferLambdaArgsForLambdaPropagation origRhsExpr = match e with | SynExpr.Lambda (body = rest) -> 1 + loop rest | SynExpr.MatchLambda _ -> 1 - | SynExpr.DotLambda _ -> 1 + | SynExpr.DotLambda (expr = body) -> 1 + loop body | _ -> 0 loop origRhsExpr diff --git a/tests/FSharp.Compiler.ComponentTests/Language/DotLambdaTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/DotLambdaTests.fs index f0e5c77e865..ad9b8fe7461 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/DotLambdaTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/DotLambdaTests.fs @@ -224,4 +224,20 @@ let c : string = let _ = "test" in "asd" |> _.ToString() |> withLangVersion80 |> typecheck |> shouldFail - |> withSingleDiagnostic (Warning 3570, Line 3, Col 43, Line 3, Col 44, "The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope.") \ No newline at end of file + |> withSingleDiagnostic (Warning 3570, Line 3, Col 43, Line 3, Col 44, "The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope.") + +[] +let ``DotLambda selector converted to Func when used in LINQ`` () = + FSharp """open System.Linq +let _ = [""; ""; ""].Select(fun x -> x.Length) +let _ = [""; ""; ""].Select(_.Length) +let _ = [""; ""; ""].Select _.Length + +let asQ = [""; ""; ""].AsQueryable() +let _ = asQ.Select(fun x -> x.Length) +let _ = asQ.Select(_.Length) +let _ = asQ.Select _.Length +""" + |> withLangVersion80 + |> typecheck + |> shouldSucceed \ No newline at end of file