diff --git a/NuGet.config b/NuGet.config index 944ae5b686..dd573e4a91 100644 --- a/NuGet.config +++ b/NuGet.config @@ -8,7 +8,7 @@ - + diff --git a/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md index 7f0be7cb37..0b1b492c67 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md @@ -24,6 +24,7 @@ * Reenable β-reduction and subsequent reoptimization of immediately-invoked F#-defined generic delegates. ([PR #18401](https://github.com/dotnet/fsharp/pull/18401)) * Fixed [#18433](https://github.com/dotnet/fsharp/issues/18433), a rare case of an internal error in xml comment processing. ([PR #18436](https://github.com/dotnet/fsharp/pull/18436)) * Fix missing `null` highlighting in tooltips ([PR #18457](https://github.com/dotnet/fsharp/pull/18457)) +* Make `[]` combination work([PR #18444](https://github.com/dotnet/fsharp/pull/18444/)) ### Added * Added missing type constraints in FCS. ([PR #18241](https://github.com/dotnet/fsharp/pull/18241)) @@ -31,6 +32,7 @@ * Add support for C# `Experimental` attribute. ([PR #18253](https://github.com/dotnet/fsharp/pull/18253)) * Nullness warnings are issued for signature<>implementation conformance ([PR #18186](https://github.com/dotnet/fsharp/pull/18186)) * Symbols: Add FSharpAssembly.IsFSharp ([PR #18290](https://github.com/dotnet/fsharp/pull/18290)) +* Type checker: don't suppress errors while checking expressions ([PR #18311](https://github.com/dotnet/fsharp/pull/18311)) * Type parameter constraint `null` in generic code will now automatically imply `not struct` ([Issue #18320](https://github.com/dotnet/fsharp/issues/18320), [PR #18323](https://github.com/dotnet/fsharp/pull/18323)) * Add a switch to determine whether to generate a default implementation body for overridden method when completing. [PR #18341](https://github.com/dotnet/fsharp/pull/18341) * Use a more accurate range for CE Combine methods. [PR #18394](https://github.com/dotnet/fsharp/pull/18394) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index da463444bc..0917752a5d 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -7,26 +7,26 @@ - + https://github.com/dotnet/msbuild - 0ca03f84b7848ce9d7d3e5d1f68c5e090efa4f30 + 8e42d4a440e0f85c1e8dce43767e7a50d86aa8ff - + https://github.com/dotnet/msbuild - 0ca03f84b7848ce9d7d3e5d1f68c5e090efa4f30 + 8e42d4a440e0f85c1e8dce43767e7a50d86aa8ff - + https://github.com/dotnet/msbuild - 0ca03f84b7848ce9d7d3e5d1f68c5e090efa4f30 + 8e42d4a440e0f85c1e8dce43767e7a50d86aa8ff - + https://github.com/dotnet/msbuild - 0ca03f84b7848ce9d7d3e5d1f68c5e090efa4f30 + 8e42d4a440e0f85c1e8dce43767e7a50d86aa8ff - + https://github.com/dotnet/msbuild - 0ca03f84b7848ce9d7d3e5d1f68c5e090efa4f30 + 8e42d4a440e0f85c1e8dce43767e7a50d86aa8ff https://github.com/dotnet/runtime @@ -42,14 +42,14 @@ - + https://github.com/dotnet/arcade - 97cbc7361ff28b2948c8182720c166a744049f55 + aa61e8c20a869bcc994f8b29eb07d927d2bec6f4 - + https://github.com/dotnet/arcade - 97cbc7361ff28b2948c8182720c166a744049f55 + aa61e8c20a869bcc994f8b29eb07d927d2bec6f4 diff --git a/eng/Versions.props b/eng/Versions.props index ba0596f729..bb09101651 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -102,7 +102,7 @@ 17.10.40152 17.10.526-pre-g1b474069f5 17.10.41 - 17.13.22 + 17.13.23 $(RoslynVersion) $(RoslynVersion) @@ -138,9 +138,9 @@ 15.0.25123-Dev15Preview - 17.13.22 - 17.13.22 - 17.13.22 + 17.13.23 + 17.13.23 + 17.13.23 $(VisualStudioEditorPackagesVersion) diff --git a/global.json b/global.json index 434c70939f..dad4b18b2f 100644 --- a/global.json +++ b/global.json @@ -17,7 +17,7 @@ "perl": "5.38.2.2" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.25204.5", + "Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.25208.6", "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2" } } diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index 7f1d22f0dd..5f390038e3 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -5960,7 +5960,7 @@ and TcExprUndelayed (cenv: cenv) (overallTy: OverallTy) env tpenv (synExpr: SynE | SynExpr.FromParseError (expr1, m) -> //SolveTypeAsError cenv env.DisplayEnv m overallTy - let _, tpenv = suppressErrorReporting (fun () -> TcExpr cenv overallTy env tpenv expr1) + let _, tpenv = TcExpr cenv overallTy env tpenv expr1 mkDefault(m, overallTy.Commit), tpenv | SynExpr.Sequential (sp, dir, synExpr1, synExpr2, m, _) -> @@ -6489,9 +6489,7 @@ and TcIteratedLambdas (cenv: cenv) isFirst (env: TcEnv) overallTy takenNames tpe | e -> let env = { env with eIsControlFlow = true } - // Dive into the expression to check for syntax errors and suppress them if they show. - conditionallySuppressErrorReporting (not isFirst && synExprContainsError e) (fun () -> - TcExpr cenv overallTy env tpenv e) + TcExpr cenv overallTy env tpenv e and TcTyparExprThen (cenv: cenv) overallTy env tpenv synTypar m delayed = match delayed with @@ -11103,39 +11101,33 @@ and TcNormalizedBinding declKind (cenv: cenv) env tpenv overallTy safeThisValOpt // At each module binding, dive into the expression to check for syntax errors and suppress them if they show. // Don't do this for lambdas, because we always check for suppression for all lambda bodies in TcIteratedLambdas let rhsExprChecked, tpenv = - let atTopNonLambdaDefn = - declKind.IsModuleOrMemberOrExtensionBinding && - (match rhsExpr with SynExpr.Lambda _ -> false | _ -> true) && - synExprContainsError rhsExpr - - conditionallySuppressErrorReporting atTopNonLambdaDefn (fun () -> - - // Save the arginfos away to match them up in the lambda - let (PrelimValReprInfo(argInfos, _)) = prelimValReprInfo - - // The right-hand-side is control flow (has an implicit debug point) in any situation where we - // haven't extended the debug point to include the 'let', that is, there is a debug point noted - // at the binding. - // - // This includes - // let _ = expr - // let () = expr - // which are transformed to sequential expressions in TcLetBinding - // - let rhsIsControlFlow = - match pat with - | SynPat.Wild _ - | SynPat.Const (SynConst.Unit, _) - | SynPat.Paren (SynPat.Const (SynConst.Unit, _), _) -> true - | _ -> - match debugPoint with - | DebugPointAtBinding.Yes _ -> false - | _ -> true + // Save the arginfos away to match them up in the lambda + let (PrelimValReprInfo(argInfos, _)) = prelimValReprInfo + + // The right-hand-side is control flow (has an implicit debug point) in any situation where we + // haven't extended the debug point to include the 'let', that is, there is a debug point noted + // at the binding. + // + // This includes + // let _ = expr + // let () = expr + // which are transformed to sequential expressions in TcLetBinding + // + let rhsIsControlFlow = + match pat with + | SynPat.Wild _ + | SynPat.Const (SynConst.Unit, _) + | SynPat.Paren (SynPat.Const (SynConst.Unit, _), _) -> true + | _ -> + + match debugPoint with + | DebugPointAtBinding.Yes _ -> false + | _ -> true - let envinner = { envinner with eLambdaArgInfos = argInfos; eIsControlFlow = rhsIsControlFlow } + let envinner = { envinner with eLambdaArgInfos = argInfos; eIsControlFlow = rhsIsControlFlow } - if isCtor then TcExprThatIsCtorBody (safeThisValOpt, safeInitInfo) cenv (MustEqual overallExprTy) envinner tpenv rhsExpr - else TcExprThatCantBeCtorBody cenv (MustConvertTo (false, overallExprTy)) envinner tpenv rhsExpr) + if isCtor then TcExprThatIsCtorBody (safeThisValOpt, safeInitInfo) cenv (MustEqual overallExprTy) envinner tpenv rhsExpr + else TcExprThatCantBeCtorBody cenv (MustConvertTo (false, overallExprTy)) envinner tpenv rhsExpr if kind = SynBindingKind.StandaloneExpression && not cenv.isScript then UnifyUnitType cenv env mBinding overallPatTy rhsExprChecked |> ignore diff --git a/src/Compiler/Checking/MethodCalls.fs b/src/Compiler/Checking/MethodCalls.fs index 41d731f007..19b91dcf0b 100644 --- a/src/Compiler/Checking/MethodCalls.fs +++ b/src/Compiler/Checking/MethodCalls.fs @@ -348,6 +348,12 @@ let inline mkOptionalNone (g: TcGlobals) ty calledArgTy mMethExpr = else mkNone g calledArgTy mMethExpr +let inline mkOptionalSome (g: TcGlobals) outerOptTy innerNonOptionalType expr mMethExpr = + if g.langVersion.SupportsFeature LanguageFeature.SupportValueOptionsAsOptionalParameters && isValueOptionTy g outerOptTy then + mkValueSome g innerNonOptionalType expr mMethExpr + else + mkSome g innerNonOptionalType expr mMethExpr + /// Adjust the called argument type to take into account whether the caller's argument is CSharpMethod(?arg=Some(3)) or CSharpMethod(arg=1) let AdjustCalledArgTypeForOptionals (infoReader: InfoReader) ad enforceNullableOptionalsKnownTypes (calledArg: CalledArg) calledArgTy (callerArg: CallerArg<_>) = @@ -1502,14 +1508,14 @@ let GetDefaultExpressionForCalleeSideOptionalArg g (calledArg: CalledArg) eCalle match calledArg.CallerInfo, eCallerMemberName with | CallerLineNumber, _ when typeEquiv g calledNonOptTy g.int_ty -> let lineExpr = Expr.Const(Const.Int32 mMethExpr.StartLine, mMethExpr, calledNonOptTy) - mkSome g calledNonOptTy lineExpr mMethExpr + mkOptionalSome g calledArgTy calledNonOptTy lineExpr mMethExpr | CallerFilePath, _ when typeEquiv g calledNonOptTy g.string_ty -> let fileName = mMethExpr.FileName |> FileSystem.GetFullPathShim |> PathMap.apply g.pathMap let filePathExpr = Expr.Const (Const.String(fileName), mMethExpr, calledNonOptTy) - mkSome g calledNonOptTy filePathExpr mMethExpr + mkOptionalSome g calledArgTy calledNonOptTy filePathExpr mMethExpr | CallerMemberName, Some(callerName) when typeEquiv g calledNonOptTy g.string_ty -> let memberNameExpr = Expr.Const (Const.String callerName, mMethExpr, calledNonOptTy) - mkSome g calledNonOptTy memberNameExpr mMethExpr + mkOptionalSome g calledArgTy calledNonOptTy memberNameExpr mMethExpr | _ -> mkOptionalNone g calledArgTy calledNonOptTy mMethExpr diff --git a/src/Compiler/Checking/PostInferenceChecks.fs b/src/Compiler/Checking/PostInferenceChecks.fs index d22f50cdc2..751112e391 100644 --- a/src/Compiler/Checking/PostInferenceChecks.fs +++ b/src/Compiler/Checking/PostInferenceChecks.fs @@ -2398,13 +2398,25 @@ let CheckEntityDefn cenv env (tycon: Entity) = errorR(Error(FSComp.SR.chkCurriedMethodsCantHaveOutParams(), m)) if numCurriedArgSets = 1 then - let errorIfNotStringTy m ty callerInfo = + + let inline tryDestOptionalTy g ty = + if isOptionTy g ty then + destOptionTy g ty |> ValueSome + elif g.langVersion.SupportsFeature LanguageFeature.SupportValueOptionsAsOptionalParameters && isValueOptionTy g ty then + destValueOptionTy g ty |> ValueSome + else + ValueNone + + let errorIfNotStringTy m ty callerInfo = if not (typeEquiv g g.string_ty ty) then errorR(Error(FSComp.SR.tcCallerInfoWrongType(callerInfo |> string, "string", NicePrint.minimalStringOfType cenv.denv ty), m)) + + let errorIfNotOptional tyToCompare desiredTyName m ty callerInfo = - let errorIfNotStringOptionTy m ty callerInfo = - if not ((isOptionTy g ty) && (typeEquiv g g.string_ty (destOptionTy g ty))) then - errorR(Error(FSComp.SR.tcCallerInfoWrongType(callerInfo |> string, "string", NicePrint.minimalStringOfType cenv.denv (destOptionTy g ty)), m)) + match tryDestOptionalTy g ty with + | ValueSome t when typeEquiv g tyToCompare t -> () + | ValueSome innerTy -> errorR(Error(FSComp.SR.tcCallerInfoWrongType(callerInfo |> string, desiredTyName, NicePrint.minimalStringOfType cenv.denv innerTy), m)) + | ValueNone -> errorR(Error(FSComp.SR.tcCallerInfoWrongType(callerInfo |> string, desiredTyName, NicePrint.minimalStringOfType cenv.denv ty), m)) minfo.GetParamDatas(cenv.amap, m, minfo.FormalMethodInst) |> List.iterSquared (fun (ParamData(_, isInArg, _, optArgInfo, callerInfo, nameOpt, _, ty)) -> @@ -2421,11 +2433,9 @@ let CheckEntityDefn cenv env (tycon: Entity) = | CallerSide _, CallerLineNumber -> if not (typeEquiv g g.int32_ty ty) then errorR(Error(FSComp.SR.tcCallerInfoWrongType(callerInfo |> string, "int", NicePrint.minimalStringOfType cenv.denv ty), m)) - | CalleeSide, CallerLineNumber -> - if not ((isOptionTy g ty) && (typeEquiv g g.int32_ty (destOptionTy g ty))) then - errorR(Error(FSComp.SR.tcCallerInfoWrongType(callerInfo |> string, "int", NicePrint.minimalStringOfType cenv.denv (destOptionTy g ty)), m)) + | CalleeSide, CallerLineNumber -> errorIfNotOptional g.int32_ty "int" m ty callerInfo | CallerSide _, (CallerFilePath | CallerMemberName) -> errorIfNotStringTy m ty callerInfo - | CalleeSide, (CallerFilePath | CallerMemberName) -> errorIfNotStringOptionTy m ty callerInfo + | CalleeSide, (CallerFilePath | CallerMemberName) -> errorIfNotOptional g.string_ty "string" m ty callerInfo ) for pinfo in immediateProps do diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MemberDefinitions/OptionalArguments/OptionalArguments.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MemberDefinitions/OptionalArguments/OptionalArguments.fs index c0604630d5..4d0843014e 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MemberDefinitions/OptionalArguments/OptionalArguments.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MemberDefinitions/OptionalArguments/OptionalArguments.fs @@ -609,4 +609,41 @@ but here has type ''T option' but here has type ''a voption' " - ] \ No newline at end of file + ] + + [] + let ``Struct optional args can have caller member name`` () = + + let source = """module TestLib +open System.Runtime.CompilerServices + +let printItOut x = + printf "%s" $"{x};" + +type Ab() = + + static member aa ([]?b: string) = + printItOut b + + static member bb ([]?i: int) = + printItOut i + +[] +let main _args = + Ab.aa() + Ab.bb() + Ab.aa("hello") + Ab.bb(42) + 0 +""" + + source + |> FSharp + |> withLangVersionPreview + |> withNoWarn 25 + |> asExe + |> compile + |> ILVerifierModule.verifyPEFileWithSystemDlls + |> run + |> verifyOutputContains [|"main;18;hello;42;"|] + \ No newline at end of file diff --git a/tests/FSharp.Compiler.Service.Tests/Common.fs b/tests/FSharp.Compiler.Service.Tests/Common.fs index 5ad61b29ef..dad4f48951 100644 --- a/tests/FSharp.Compiler.Service.Tests/Common.fs +++ b/tests/FSharp.Compiler.Service.Tests/Common.fs @@ -119,7 +119,6 @@ let mkProjectCommandLineArgsForScript (dllName, fileNames) = yield "--doc:test.xml" yield "--warn:3" yield "--fullpaths" - yield "--flaterrors" yield "--target:library" for x in fileNames do yield x @@ -370,11 +369,17 @@ let inline dumpDiagnostics (results: FSharpCheckFileResults) = |> Array.map (fun e -> let message = e.Message.Split('\n') - |> Array.map (fun s -> s.Trim()) + |> Array.map _.Trim() + |> Array.filter (fun s -> s.Length > 0) |> String.concat " " sprintf "%s: %s" (e.Range.ToString()) message) |> List.ofArray +let inline dumpDiagnosticNumbers (results: FSharpCheckFileResults) = + results.Diagnostics + |> Array.map (fun e -> e.Range.ToString(), e.ErrorNumber) + |> List.ofArray + let getSymbolUses (results: FSharpCheckFileResults) = results.GetAllUsesOfAllSymbolsInFile() diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index 1cf8d9c720..d9db689952 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -26,6 +26,7 @@ XunitSetup.fs + diff --git a/tests/FSharp.Compiler.Service.Tests/PatternMatchCompilationTests.fs b/tests/FSharp.Compiler.Service.Tests/PatternMatchCompilationTests.fs index 5bd733d531..1b6d54d357 100644 --- a/tests/FSharp.Compiler.Service.Tests/PatternMatchCompilationTests.fs +++ b/tests/FSharp.Compiler.Service.Tests/PatternMatchCompilationTests.fs @@ -16,7 +16,7 @@ match () with """ assertHasSymbolUsages ["x"; "y"] checkResults dumpDiagnostics checkResults |> shouldEqual [ - "(3,2--3,4): This expression was expected to have type\u001d 'unit' \u001dbut here has type\u001d 'string'" + "(3,2--3,4): This expression was expected to have type 'unit' but here has type 'string'" ] [] @@ -26,8 +26,8 @@ let ("": unit), (x: int) = let y = () in () """ assertHasSymbolUsages ["x"; "y"] checkResults dumpDiagnostics checkResults |> shouldEqual [ - "(2,5--2,7): This expression was expected to have type\u001d 'unit' \u001dbut here has type\u001d 'string'"; - "(2,41--2,43): This expression was expected to have type\u001d 'unit * int' \u001dbut here has type\u001d 'unit'"; + "(2,5--2,7): This expression was expected to have type 'unit' but here has type 'string'"; + "(2,41--2,43): This expression was expected to have type 'unit * int' but here has type 'unit'"; "(2,4--2,24): Incomplete pattern matches on this expression." ] @@ -81,7 +81,7 @@ match A with """ assertHasSymbolUsages ["x"; "y"] checkResults dumpDiagnostics checkResults |> shouldEqual [ - "(7,5--7,12): This expression was expected to have type\u001d 'int' \u001dbut here has type\u001d ''a * 'b * 'c'"; + "(7,5--7,12): This expression was expected to have type 'int' but here has type ''a * 'b * 'c'"; "(6,6--6,7): Incomplete pattern matches on this expression." ] @@ -169,7 +169,7 @@ match Some 1 with """ assertHasSymbolUsages ["a"] checkResults dumpDiagnostics checkResults |> shouldEqual [ - "(3,7--3,14): This expression was expected to have type\u001d 'int' \u001dbut here has type\u001d ''a option'" + "(3,7--3,14): This expression was expected to have type 'int' but here has type ''a option'" "(2,6--2,12): Incomplete pattern matches on this expression." ] @@ -181,7 +181,7 @@ match Some 1 with """ assertHasSymbolUsages ["a"; "i"] checkResults dumpDiagnostics checkResults |> shouldEqual [ - "(3,7--3,18): This expression was expected to have type\u001d 'int' \u001dbut here has type\u001d ''a option'"; + "(3,7--3,18): This expression was expected to have type 'int' but here has type ''a option'"; "(2,6--2,12): Incomplete pattern matches on this expression." ] @@ -281,7 +281,7 @@ match A with assertHasSymbolUsages ["x"; "y"; "z"] checkResults dumpDiagnostics checkResults |> shouldEqual [ "(7,2--7,21): The two sides of this 'or' pattern bind different sets of variables"; - "(7,19--7,20): This expression was expected to have type\u001d 'int' \u001dbut here has type\u001d 'string'"; + "(7,19--7,20): This expression was expected to have type 'int' but here has type 'string'"; "(6,6--6,7): Incomplete pattern matches on this expression. For example, the value 'A' may indicate a case not covered by the pattern(s)." ] @@ -335,7 +335,7 @@ match Unchecked.defaultof with """ assertHasSymbolUsages ["a"; "b"; "c"; "d"] checkResults dumpDiagnostics checkResults |> shouldEqual [ - "(5,21--5,27): Type constraint mismatch. The type \u001d 'int' \u001dis not compatible with type\u001d 'System.Enum'" + "(5,21--5,27): Type constraint mismatch. The type 'int' is not compatible with type 'System.Enum'" ] [] @@ -550,21 +550,21 @@ let z as "(14,6--14,8): Expecting pattern"; "(15,13--15,14): Unexpected symbol '=' in pattern. Expected ')' or other token."; "(15,9--15,10): Unmatched '('"; - "(16,0--16,3): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (15:1). Try indenting this further.\u001dTo continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; + "(16,0--16,3): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (15:1). Try indenting this further. To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; "(17,16--17,17): Unexpected identifier in pattern. Expected '(' or other token."; "(19,6--19,8): Expecting pattern"; "(20,0--20,0): Incomplete structured construct at or before this point in binding. Expected '=' or other token."; - "(3,13--3,17): This expression was expected to have type\u001d 'int' \u001dbut here has type\u001d 'bool'"; + "(3,13--3,17): This expression was expected to have type 'int' but here has type 'bool'"; "(3,4--3,10): Incomplete pattern matches on this expression. For example, the value '0' may indicate a case not covered by the pattern(s)."; - "(4,16--4,17): This expression was expected to have type\u001d 'bool' \u001dbut here has type\u001d 'int'"; + "(4,16--4,17): This expression was expected to have type 'bool' but here has type 'int'"; "(4,4--4,13): Incomplete pattern matches on this expression. For example, the value 'false' may indicate a case not covered by the pattern(s)."; - "(5,9--5,15): This runtime coercion or type test from type\u001d 'a \u001d to \u001d int \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; - "(6,9--6,15): This runtime coercion or type test from type\u001d 'a \u001d to \u001d int \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; - "(8,29--8,30): This expression was expected to have type\u001d 'unit' \u001dbut here has type\u001d 'int'"; - "(9,26--9,27): This expression was expected to have type\u001d 'unit' \u001dbut here has type\u001d 'int'"; - "(10,15--10,16): This expression was expected to have type\u001d ''a * 'b' \u001dbut here has type\u001d 'int'"; + "(5,9--5,15): This runtime coercion or type test from type 'a to int involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(6,9--6,15): This runtime coercion or type test from type 'a to int involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(8,29--8,30): This expression was expected to have type 'unit' but here has type 'int'"; + "(9,26--9,27): This expression was expected to have type 'unit' but here has type 'int'"; + "(10,15--10,16): This expression was expected to have type ''a * 'b' but here has type 'int'"; "(11,11--11,12): The type 'k' is not defined."; - "(12,16--12,18): This expression was expected to have type\u001d ''a list' \u001dbut here has type\u001d 'int'"; + "(12,16--12,18): This expression was expected to have type ''a list' but here has type 'int'"; "(12,4--12,13): Incomplete pattern matches on this expression. For example, the value '[]' may indicate a case not covered by the pattern(s)."; "(14,4--14,12): The two sides of this 'or' pattern bind different sets of variables"; "(18,14--18,15): The value or constructor 'y' is not defined." @@ -687,22 +687,22 @@ let z as = "(14,8--14,10): Unexpected keyword 'as' in binding"; "(15,8--15,10): Unexpected keyword 'as' in pattern. Expected ')' or other token."; "(15,6--15,7): Unmatched '('"; - "(16,0--16,3): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (15:1). Try indenting this further.\u001dTo continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; + "(16,0--16,3): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (15:1). Try indenting this further. To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; "(16,0--16,3): Unexpected keyword 'let' or 'use' in binding. Expected incomplete structured construct at or before this point or other token."; "(15,0--15,3): Incomplete value or function definition. If this is in an expression, the body of the expression must be indented to the same column as the 'let' keyword."; "(17,0--17,3): Incomplete structured construct at or before this point in implementation file"; - "(20,0--20,0): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (19:1). Try indenting this further.\u001dTo continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; - "(20,0--20,0): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (19:1). Try indenting this further.\u001dTo continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; - "(3,13--3,17): This expression was expected to have type\u001d 'int' \u001dbut here has type\u001d 'bool'"; + "(20,0--20,0): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (19:1). Try indenting this further. To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; + "(20,0--20,0): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (19:1). Try indenting this further. To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; + "(3,13--3,17): This expression was expected to have type 'int' but here has type 'bool'"; "(3,4--3,10): Incomplete pattern matches on this expression. For example, the value '0' may indicate a case not covered by the pattern(s)."; - "(4,16--4,17): This expression was expected to have type\u001d 'bool' \u001dbut here has type\u001d 'int'"; + "(4,16--4,17): This expression was expected to have type 'bool' but here has type 'int'"; "(4,4--4,13): Incomplete pattern matches on this expression. For example, the value 'false' may indicate a case not covered by the pattern(s)."; - "(5,4--5,10): This runtime coercion or type test from type\u001d 'a \u001d to \u001d int \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; - "(6,4--6,10): This runtime coercion or type test from type\u001d 'a \u001d to \u001d int \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; - "(8,29--8,30): This expression was expected to have type\u001d 'unit' \u001dbut here has type\u001d 'int'"; - "(9,26--9,27): This expression was expected to have type\u001d 'unit' \u001dbut here has type\u001d 'int'"; - "(10,14--10,15): This expression was expected to have type\u001d ''a * 'b' \u001dbut here has type\u001d 'int'"; - "(12,16--12,18): This expression was expected to have type\u001d ''a list' \u001dbut here has type\u001d 'int'"; + "(5,4--5,10): This runtime coercion or type test from type 'a to int involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(6,4--6,10): This runtime coercion or type test from type 'a to int involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(8,29--8,30): This expression was expected to have type 'unit' but here has type 'int'"; + "(9,26--9,27): This expression was expected to have type 'unit' but here has type 'int'"; + "(10,14--10,15): This expression was expected to have type ''a * 'b' but here has type 'int'"; + "(12,16--12,18): This expression was expected to have type ''a list' but here has type 'int'"; "(12,4--12,13): Incomplete pattern matches on this expression. For example, the value '[]' may indicate a case not covered by the pattern(s)."; "(15,4--15,5): The pattern discriminator 'r' is not defined."; "(15,4--15,12): Incomplete pattern matches on this expression." @@ -755,7 +755,7 @@ Some x |> eq """ assertHasSymbolUsages (List.map string ['a'..'z']) checkResults dumpDiagnostics checkResults |> shouldEqual [ - "(11,25--11,26): This expression was expected to have type\u001d 'int' \u001dbut here has type\u001d 'objnull'"; + "(11,25--11,26): This expression was expected to have type 'int' but here has type 'objnull'"; "(28,6--28,24): Incomplete pattern matches on this expression. For example, the value '``some-other-subtype``' may indicate a case not covered by the pattern(s)."; "(26,6--26,12): Incomplete pattern matches on this expression. For example, the value '``some-other-subtype``' may indicate a case not covered by the pattern(s)."; "(24,6--24,12): Incomplete pattern matches on this expression. For example, the value '``some-other-subtype``' may indicate a case not covered by the pattern(s)."; @@ -875,44 +875,44 @@ let :? z as "(14,9--14,11): Expecting pattern"; "(15,16--15,17): Unexpected symbol '=' in pattern. Expected ')' or other token."; "(15,12--15,13): Unmatched '('"; - "(16,0--16,3): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (15:1). Try indenting this further.\u001dTo continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; + "(16,0--16,3): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (15:1). Try indenting this further. To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; "(17,19--17,20): Unexpected identifier in pattern. Expected '(' or other token."; "(19,9--19,11): Expecting pattern"; "(20,0--20,0): Incomplete structured construct at or before this point in binding. Expected '=' or other token."; "(3,7--3,8): The type 'a' is not defined."; - "(3,4--3,8): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(3,4--3,8): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; "(4,7--4,8): The type 'b' is not defined."; - "(4,4--4,8): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(4,4--4,8): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; "(5,7--5,8): The type 'c' is not defined."; - "(5,4--5,8): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(5,4--5,8): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; "(6,7--6,8): The type 'd' is not defined."; - "(6,4--6,8): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(6,4--6,8): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; "(7,7--7,8): The type 'e' is not defined."; - "(7,4--7,8): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(7,4--7,8): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; "(8,7--8,8): The type 'f' is not defined."; - "(8,4--8,8): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(8,4--8,8): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; "(9,7--9,8): The type 'g' is not defined."; - "(9,4--9,8): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(9,4--9,8): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; "(10,7--10,8): The type 'h' is not defined."; - "(10,4--10,8): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(10,4--10,8): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; "(10,7--10,8): The type 'h' is not defined."; - "(10,4--10,8): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(10,4--10,8): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; "(11,7--11,8): The type 'j' is not defined."; - "(11,4--11,8): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(11,4--11,8): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; "(12,7--12,8): The type 'l' is not defined."; - "(12,4--12,8): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(12,4--12,8): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; "(13,7--13,8): The type 'n' is not defined."; - "(13,4--13,8): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(13,4--13,8): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; "(14,7--14,8): The type 'p' is not defined."; - "(14,4--14,8): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(14,4--14,8): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; "(15,7--15,8): The type 'r' is not defined."; - "(15,4--15,8): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(15,4--15,8): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; "(17,7--17,8): The type 'v' is not defined."; - "(17,4--17,8): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(17,4--17,8): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; "(18,7--18,8): The type 'x' is not defined."; - "(18,4--18,8): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(18,4--18,8): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; "(19,7--19,8): The type 'z' is not defined."; - "(19,4--19,8): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed." + "(19,4--19,8): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed." ] [] @@ -955,8 +955,8 @@ Some "" |> eq // No more type checks after the above line? """ assertHasSymbolUsages (Set.toList validSet) checkResults dumpDiagnostics checkResults |> shouldEqual [ - "(27,2--27,14): This expression was expected to have type\u001d 'objnull' \u001dbut here has type\u001d 'struct ('a * 'b)'"; - "(52,2--52,13): This expression was expected to have type\u001d 'objnull' \u001dbut here has type\u001d 'AAA'"; + "(27,2--27,14): This expression was expected to have type 'objnull' but here has type 'struct ('a * 'b)'"; + "(52,2--52,13): This expression was expected to have type 'objnull' but here has type 'AAA'"; "(26,6--26,24): Incomplete pattern matches on this expression. For example, the value '``some-other-subtype``' may indicate a case not covered by the pattern(s)."; "(24,6--24,12): Incomplete pattern matches on this expression. For example, the value '``some-other-subtype``' may indicate a case not covered by the pattern(s)."; "(22,6--22,12): Incomplete pattern matches on this expression. For example, the value '``some-other-subtype``' may indicate a case not covered by the pattern(s)."; @@ -1037,9 +1037,9 @@ Some "" |> eq """ assertHasSymbolUsages (set ['a'..'y'] - set [ 'm'..'r' ] |> Set.map string |> Set.toList) checkResults dumpDiagnostics checkResults |> shouldEqual [ - "(19,2--19,4): This expression was expected to have type\u001d 'objnull' \u001dbut here has type\u001d 'int'"; - "(21,2--21,7): This expression was expected to have type\u001d 'objnull' \u001dbut here has type\u001d 'bool'"; - "(23,2--23,6): This expression was expected to have type\u001d 'objnull' \u001dbut here has type\u001d 'bool'"; + "(19,2--19,4): This expression was expected to have type 'objnull' but here has type 'int'"; + "(21,2--21,7): This expression was expected to have type 'objnull' but here has type 'bool'"; + "(23,2--23,6): This expression was expected to have type 'objnull' but here has type 'bool'"; "(28,28--28,29): The type 'objnull' does not match the type 'int'"; "(41,5--41,6): The value or constructor 'm' is not defined."; "(42,5--42,6): The value or constructor 'n' is not defined."; @@ -1092,22 +1092,22 @@ let as :? z = "(15,13--15,15): Unexpected keyword 'as' in pattern. Expected '(' or other token."; "(16,8--16,10): Unexpected keyword 'as' in pattern. Expected ')' or other token."; "(16,6--16,7): Unmatched '('"; - "(17,0--17,3): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (16:1). Try indenting this further.\u001dTo continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; + "(17,0--17,3): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (16:1). Try indenting this further. To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; "(17,0--17,3): Unexpected keyword 'let' or 'use' in binding. Expected incomplete structured construct at or before this point or other token."; "(16,0--16,3): Incomplete value or function definition. If this is in an expression, the body of the expression must be indented to the same column as the 'let' keyword."; "(17,8--17,10): Unexpected keyword 'as' in pattern. Expected ']' or other token."; - "(18,0--18,3): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (17:1). Try indenting this further.\u001dTo continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; - "(19,0--19,3): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (18:1). Try indenting this further.\u001dTo continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; - "(20,0--20,0): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (19:1). Try indenting this further.\u001dTo continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; - "(20,0--20,0): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (19:1). Try indenting this further.\u001dTo continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; + "(18,0--18,3): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (17:1). Try indenting this further. To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; + "(19,0--19,3): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (18:1). Try indenting this further. To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; + "(20,0--20,0): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (19:1). Try indenting this further. To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; + "(20,0--20,0): Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (19:1). Try indenting this further. To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7."; "(3,12--3,13): The type 'a' is not defined."; "(3,9--3,13): The type 'int' does not have any proper subtypes and cannot be used as the source of a type test or runtime coercion."; "(4,15--4,16): The type 'b' is not defined."; "(4,12--4,16): The type 'bool' does not have any proper subtypes and cannot be used as the source of a type test or runtime coercion."; - "(5,4--5,10): This runtime coercion or type test from type\u001d 'a \u001d to \u001d int \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; - "(6,4--6,10): This runtime coercion or type test from type\u001d 'a \u001d to \u001d int \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(5,4--5,10): This runtime coercion or type test from type 'a to int involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(6,4--6,10): This runtime coercion or type test from type 'a to int involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; "(7,27--7,28): The type 'e' is not defined."; - "(7,24--7,28): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; + "(7,24--7,28): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed."; "(8,28--8,29): The type 'f' is not defined."; "(8,25--8,29): The type 'unit' does not have any proper subtypes and cannot be used as the source of a type test or runtime coercion."; "(9,25--9,26): The type 'g' is not defined."; @@ -1118,7 +1118,7 @@ let as :? z = "(12,12--12,16): The type ''a list' does not have any proper subtypes and cannot be used as the source of a type test or runtime coercion."; "(16,4--16,5): The pattern discriminator 't' is not defined."; "(16,14--16,15): The type 'u' is not defined."; - "(16,11--16,15): This runtime coercion or type test from type\u001d 'a \u001d to \u001d 'b \u001dinvolves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed." + "(16,11--16,15): This runtime coercion or type test from type 'a to 'b involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed." ] [] diff --git a/tests/FSharp.Compiler.Service.Tests/TypeChecker/TypeCheckerRecoveryTests.fs b/tests/FSharp.Compiler.Service.Tests/TypeChecker/TypeCheckerRecoveryTests.fs new file mode 100644 index 0000000000..07827b7d39 --- /dev/null +++ b/tests/FSharp.Compiler.Service.Tests/TypeChecker/TypeCheckerRecoveryTests.fs @@ -0,0 +1,52 @@ +module FSharp.Compiler.Service.Tests.TypeChecker.TypeCheckerRecoveryTests + +open FSharp.Compiler.Service.Tests +open FSharp.Test.Assert +open Xunit + +[] +let ``Let 01`` () = + let _, checkResults = getParseAndCheckResults """ +do + let a = b.ToString() +""" + + dumpDiagnosticNumbers checkResults |> shouldEqual [ + "(3,4--3,7)", 588 + "(3,12--3,13)", 39 + ] + + +[] +let ``Tuple 01`` () = + let _, checkResults = getParseAndCheckResults """ +open System + +Math.Max(a,) +""" + + dumpDiagnosticNumbers checkResults |> shouldEqual [ + "(4,10--4,11)", 3100 + "(4,9--4,10)", 39 + "(4,0--4,12)", 41 + ] + + assertHasSymbolUsages ["Max"] checkResults + + +[] +let ``Tuple 02`` () = + let _, checkResults = getParseAndCheckResults """ +open System + +Math.Max(a,b,) +""" + + dumpDiagnosticNumbers checkResults |> shouldEqual [ + "(4,12--4,13)", 3100 + "(4,9--4,10)", 39 + "(4,11--4,12)", 39 + "(4,0--4,14)", 503 + ] + + assertHasSymbolUsages ["Max"] checkResults \ No newline at end of file diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index e21079818d..2b3ccface3 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -1640,7 +1640,8 @@ Actual: | Some (ExecutionOutput {Outcome = Failure ex }) -> failwithf $"Eval or Execution has failed (expected to succeed): %A{ex}\n{diagnostics}" | _ -> - failwithf $"Operation failed (expected to succeed).\n{diagnostics}" + + failwithf $"Operation failed (expected to succeed).\n{diagnostics} \n OUTPUTs: %A{r.Output}" let shouldFail (result: CompilationResult) : CompilationResult = match result with diff --git a/tests/fsharp/typecheck/sigs/neg104.vsbsl b/tests/fsharp/typecheck/sigs/neg104.vsbsl index 165b4348e3..ab4a928249 100644 --- a/tests/fsharp/typecheck/sigs/neg104.vsbsl +++ b/tests/fsharp/typecheck/sigs/neg104.vsbsl @@ -23,6 +23,8 @@ neg104.fs(8,9,8,15): typecheck error FS0750: This construct may only be used wit neg104.fs(10,9,10,15): typecheck error FS0750: This construct may only be used within computation expressions +neg104.fs(13,21,13,26): typecheck error FS0003: This value is not a function and cannot be applied. + neg104.fs(20,9,20,15): typecheck error FS0025: Incomplete pattern matches on this expression. neg104.fs(23,9,23,15): typecheck error FS0025: Incomplete pattern matches on this expression. diff --git a/tests/fsharp/typecheck/sigs/neg110.bsl b/tests/fsharp/typecheck/sigs/neg110.bsl index 1cdd563a74..60cae99128 100644 --- a/tests/fsharp/typecheck/sigs/neg110.bsl +++ b/tests/fsharp/typecheck/sigs/neg110.bsl @@ -1,2 +1,2 @@ -neg110.fs(5,3,5,15): typecheck error FS3242: This type does not inherit Attribute, it will not work correctly with other .NET languages. +neg110.fs(5,3,5,15): typecheck error FS3242: This type does not inherit Attribute, it will not work correctly with other .NET languages. diff --git a/tests/fsharp/typecheck/sigs/neg135.vsbsl b/tests/fsharp/typecheck/sigs/neg135.vsbsl new file mode 100644 index 0000000000..e3d34411d0 --- /dev/null +++ b/tests/fsharp/typecheck/sigs/neg135.vsbsl @@ -0,0 +1,8 @@ + +neg135.fs(6,1,6,2): parse error FS0010: Unexpected symbol '}' in expression + +neg135.fs(4,5,4,11): parse error FS3122: Missing 'do' in 'while' expression. Expected 'while do '. + +neg135.fs(4,12,4,17): typecheck error FS0003: This value is not a function and cannot be applied. + +neg135.fs(4,12,4,17): typecheck error FS0003: This value is not a function and cannot be applied. diff --git a/tests/fsharp/typecheck/sigs/neg64.vsbsl b/tests/fsharp/typecheck/sigs/neg64.vsbsl index e9578dc373..26cdbc069c 100644 --- a/tests/fsharp/typecheck/sigs/neg64.vsbsl +++ b/tests/fsharp/typecheck/sigs/neg64.vsbsl @@ -1,2 +1,6 @@ neg64.fsx(32,32,32,33): parse error FS0010: Unexpected symbol ')' in if/then/else expression + +neg64.fsx(32,17,32,31): typecheck error FS0001: All branches of an 'if' expression must return values implicitly convertible to the type of the first branch, which here is 'string'. This branch returns a value of type 'bool'. + +neg64.fsx(27,11,27,13): typecheck error FS0025: Incomplete pattern matches on this expression. For example, the value 'Horizontal (_, _)' may indicate a case not covered by the pattern(s). diff --git a/tests/fsharp/typecheck/sigs/neg68.vsbsl b/tests/fsharp/typecheck/sigs/neg68.vsbsl index b55d58ee14..369c1e1586 100644 --- a/tests/fsharp/typecheck/sigs/neg68.vsbsl +++ b/tests/fsharp/typecheck/sigs/neg68.vsbsl @@ -1,6 +1,26 @@ neg68.fsx(71,46,71,47): parse error FS0010: Unexpected symbol ')' in binding. Expected incomplete structured construct at or before this point or other token. +neg68.fsx(71,32,71,33): typecheck error FS0062: This construct is for ML compatibility. Consider using the '+' operator instead. This may require a type annotation to indicate it acts on strings. This message can be disabled using '--nowarn:62' or '#nowarn "62"'. + +neg68.fsx(71,30,71,46): typecheck error FS0001: This expression was expected to have type + 'float' +but here has type + 'string' + +neg68.fsx(71,30,71,31): typecheck error FS1133: No constructors are available for the type 'm' + +neg68.fsx(71,43,71,44): typecheck error FS0062: This construct is for ML compatibility. Consider using the '+' operator instead. This may require a type annotation to indicate it acts on strings. This message can be disabled using '--nowarn:62' or '#nowarn "62"'. + +neg68.fsx(71,39,71,45): typecheck error FS0001: The type 'string' does not match the type 'int' + +neg68.fsx(71,39,71,41): typecheck error FS1133: No constructors are available for the type 'kg' + +neg68.fsx(71,44,71,45): typecheck error FS0001: This expression was expected to have type + 'string' +but here has type + 'int' + neg68.fsx(123,40,123,41): typecheck error FS0001: The type 'bool' does not match the type 'float<'u>' neg68.fsx(123,38,123,39): typecheck error FS0043: The type 'bool' does not match the type 'float<'u>' diff --git a/tests/fsharp/typecheck/sigs/neg70.vsbsl b/tests/fsharp/typecheck/sigs/neg70.vsbsl index 16c15ba378..c392fc9898 100644 --- a/tests/fsharp/typecheck/sigs/neg70.vsbsl +++ b/tests/fsharp/typecheck/sigs/neg70.vsbsl @@ -1,2 +1,14 @@ neg70.fsx(109,64,109,65): parse error FS0010: Unexpected symbol ')' in binding. Expected incomplete structured construct at or before this point or other token. + +neg70.fsx(107,29,107,69): typecheck error FS0507: No accessible member or object constructor named 'Rectangle' takes 0 arguments. Note the call to this member also provides 1 named arguments. + +neg70.fsx(108,39,108,40): typecheck error FS0039: The value or constructor 'y' is not defined. + +neg70.fsx(110,18,110,43): typecheck error FS0041: No overloads match for method 'FillEllipse'. + +Known types of arguments: Brush * (int * bool * bool * bool) + +Available overloads: + - Graphics.FillEllipse(brush: Brush, rect: Rectangle) : unit // Argument 'rect' doesn't match + - Graphics.FillEllipse(brush: Brush, rect: RectangleF) : unit // Argument 'rect' doesn't match diff --git a/tests/fsharp/typecheck/sigs/neg79.vsbsl b/tests/fsharp/typecheck/sigs/neg79.vsbsl index b5599e2795..452690e0d9 100644 --- a/tests/fsharp/typecheck/sigs/neg79.vsbsl +++ b/tests/fsharp/typecheck/sigs/neg79.vsbsl @@ -1,2 +1,6 @@ neg79.fsx(31,32,31,33): parse error FS0010: Unexpected symbol ')' in if/then/else expression + +neg79.fsx(31,17,31,31): typecheck error FS0001: All branches of an 'if' expression must return values implicitly convertible to the type of the first branch, which here is 'string'. This branch returns a value of type 'bool'. + +neg79.fsx(26,11,26,13): typecheck error FS0025: Incomplete pattern matches on this expression. For example, the value 'Horizontal (_, _)' may indicate a case not covered by the pattern(s). diff --git a/tests/fsharp/typecheck/sigs/neg80.vsbsl b/tests/fsharp/typecheck/sigs/neg80.vsbsl index 86e8d40b6f..66f66c479d 100644 --- a/tests/fsharp/typecheck/sigs/neg80.vsbsl +++ b/tests/fsharp/typecheck/sigs/neg80.vsbsl @@ -1,2 +1,4 @@ neg80.fsx(79,5,79,6): parse error FS0010: Unexpected symbol '|' in pattern matching + +neg80.fsx(79,7,79,28): typecheck error FS0026: This rule will never be matched diff --git a/tests/fsharp/typecheck/sigs/neg82.vsbsl b/tests/fsharp/typecheck/sigs/neg82.vsbsl index a57ce6cbf6..af56fd45ac 100644 --- a/tests/fsharp/typecheck/sigs/neg82.vsbsl +++ b/tests/fsharp/typecheck/sigs/neg82.vsbsl @@ -26,4 +26,6 @@ To continue using non-conforming indentation, pass the '--strict-indentation-' f neg82.fsx(138,1,138,4): parse error FS0058: Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (102:1). Try indenting this further. To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7. +neg82.fsx(76,11,76,13): typecheck error FS0025: Incomplete pattern matches on this expression. For example, the value 'Horizontal (_, _)' may indicate a case not covered by the pattern(s). + neg82.fsx(93,5,93,7): typecheck error FS0039: The value, namespace, type or module 'sb' is not defined. diff --git a/tests/fsharp/typecheck/sigs/neg83.vsbsl b/tests/fsharp/typecheck/sigs/neg83.vsbsl index b8858cfbe1..84ee39a23f 100644 --- a/tests/fsharp/typecheck/sigs/neg83.vsbsl +++ b/tests/fsharp/typecheck/sigs/neg83.vsbsl @@ -8,3 +8,21 @@ neg83.fsx(13,2,13,5): parse error FS0058: Unexpected syntax or possible incorrec To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7. neg83.fsx(16,1,16,1): parse error FS0010: Incomplete structured construct at or before this point in expression + +neg83.fsx(8,12,8,39): typecheck error FS0001: Type mismatch. Expecting a + '('a -> 'a) -> string -> 'b' +but given a + ''c list -> 'd list' +The type ''a list' does not match the type ''b -> 'b' + +neg83.fsx(8,12,8,39): typecheck error FS0001: Type mismatch. Expecting a + '('a -> 'a) -> string -> 'b' +but given a + ''c list -> 'd list' +The type ''a list' does not match the type ''c -> 'c' + +neg83.fsx(10,15,10,17): typecheck error FS3217: This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? + +neg83.fsx(15,4,15,31): typecheck error FS0001: The type ''a list' does not match the type ''b -> 'b' + +neg83.fsx(15,4,15,31): typecheck error FS0001: The type ''a list' does not match the type ''c -> 'c' diff --git a/tests/fsharp/typecheck/sigs/neg84.vsbsl b/tests/fsharp/typecheck/sigs/neg84.vsbsl index 6d4db3adec..ca1137c006 100644 --- a/tests/fsharp/typecheck/sigs/neg84.vsbsl +++ b/tests/fsharp/typecheck/sigs/neg84.vsbsl @@ -1,2 +1,4 @@ neg84.fsx(11,1,11,1): parse error FS0010: Incomplete structured construct at or before this point in expression + +neg84.fsx(4,10,4,12): typecheck error FS0025: Incomplete pattern matches on this expression. For example, the value '[_]' may indicate a case not covered by the pattern(s). diff --git a/tests/fsharp/typecheck/sigs/neg86.vsbsl b/tests/fsharp/typecheck/sigs/neg86.vsbsl index 667ca721ae..53212577f6 100644 --- a/tests/fsharp/typecheck/sigs/neg86.vsbsl +++ b/tests/fsharp/typecheck/sigs/neg86.vsbsl @@ -9,6 +9,13 @@ neg86.fsx(8,13,8,17): typecheck error FS3167: 'join' must be followed by 'in'. U neg86.fsx(9,21,9,22): typecheck error FS0039: The value or constructor 'e' is not defined. +neg86.fsx(18,20,18,22): typecheck error FS3145: This is not a known query operator. Query operators are identifiers such as 'select', 'where', 'sortBy', 'thenBy', 'groupBy', 'groupValBy', 'join', 'groupJoin', 'sumBy' and 'averageBy', defined using corresponding methods on the 'QueryBuilder' type. + +neg86.fsx(18,20,18,22): typecheck error FS0039: The value or constructor 'op_Atin' is not defined. Maybe you want one of the following: + Option + option + Option + neg86.fsx(23,13,23,17): typecheck error FS3097: Incorrect syntax for 'join'. Usage: join var in collection on (outerKey = innerKey). Note that parentheses are required after 'on'. neg86.fsx(28,13,28,17): typecheck error FS3097: Incorrect syntax for 'join'. Usage: join var in collection on (outerKey = innerKey). Note that parentheses are required after 'on'.