From a1a370b7105ab9e3366640da832920c061939a34 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Mon, 24 Feb 2025 13:26:20 +0100 Subject: [PATCH] revert to stable warning when arg is other than obj --- .../Checking/Expressions/CheckExpressions.fs | 2 -- .../CustomAttributes/Basic/Basic.fs | 8 +++----- .../OptionalDefaultParamArgs.fs | 20 ++++++++----------- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index 5d236c1a1c5..df64c4da62e 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -9787,8 +9787,6 @@ and GetNewInferenceTypeForMethodArg (cenv: cenv) x = | SynExpr.Quote (_, raw, a, _, _) -> if raw then cont (0, mkRawQuotedExprTy g) else loopExpr a (cont << fun struct (depth, ty) -> depth + 1, mkQuotedExprTy g ty) - | SynExpr.Const (SynConst.Unit, _) -> - cont (0, g.unit_ty) | _ -> cont (0, NewInferenceType g) let struct (_depth, ty) = loopExpr x id diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/Basic.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/Basic.fs index edb58e75a10..1e3c99dc8a5 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/Basic.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/Basic.fs @@ -106,11 +106,9 @@ module CustomAttributes_Basic = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 193, Line 10, Col 3, Line 10, Col 59, """Type constraint mismatch. The type - 'unit' - is not compatible with type - 'int array' - """) + (Error 1, Line 10, Col 3, Line 10, Col 59, "This expression was expected to have type\n 'int array' \nbut here has type\n 'unit' ") + (Error 267, Line 10, Col 3, Line 10, Col 59, "This is not a valid constant expression or custom attribute value") + (Error 850, Line 10, Col 3, Line 10, Col 59, "This attribute cannot be used in this version of F#") (Error 850, Line 13, Col 3, Line 13, Col 101, "This attribute cannot be used in this version of F#") (Error 850, Line 16, Col 3, Line 16, Col 50, "This attribute cannot be used in this version of F#") ] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MemberDefinitions/OptionalDefaultParamArgs/OptionalDefaultParamArgs.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MemberDefinitions/OptionalDefaultParamArgs/OptionalDefaultParamArgs.fs index 6ea21bf539d..8ba293dce2a 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MemberDefinitions/OptionalDefaultParamArgs/OptionalDefaultParamArgs.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MemberDefinitions/OptionalDefaultParamArgs/OptionalDefaultParamArgs.fs @@ -35,12 +35,9 @@ module MemberDefinitions_OptionalDefaultParamArgs = compilation |> verifyCompile |> shouldFail - |> withDiagnostics - [(Error 193, Line 13, Col 18, Line 13, Col 20, "Type constraint mismatch. The type - 'unit' - is not compatible with type - 'int' - ")] + |> withDiagnostics [ + (Error 1, Line 13, Col 18, Line 13, Col 20, "This expression was expected to have type\n 'int' \nbut here has type\n 'unit' ") + ] // SOURCE=InterfaceMethod.fs [] @@ -80,12 +77,11 @@ module MemberDefinitions_OptionalDefaultParamArgs = |> verifyCompile |> shouldFail |> withDiagnostics - [(Warning 3211, Line 10, Col 62, Line 10, Col 63, "The default value does not have the same type as the argument. The DefaultParameterValue attribute and any Optional attribute will be ignored. Note: 'null' needs to be annotated with the correct type, e.g. 'DefaultParameterValue(null:obj)'."); - (Error 193, Line 13, Col 25, Line 13, Col 27, "Type constraint mismatch. The type - 'unit' - is not compatible with type - 'string' - ")] + [ Warning 3211, Line 10, Col 62, Line 10, Col 63, "The default value does not have the same type as the argument. The DefaultParameterValue attribute and any Optional attribute will be ignored. Note: 'null' needs to be annotated with the correct type, e.g. 'DefaultParameterValue(null:obj)'." + Error 1, Line 13, Col 25, Line 13, Col 27, "This expression was expected to have type + 'string' + but here has type + 'unit' "] [] let ``W_WrongDefaultObjType_fs`` compilation =