From 1799aaf29034f01357684c7716b6eed8fc76468a Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 23 Apr 2025 15:27:24 +0100 Subject: [PATCH 01/18] make attribute targets mismatches a warning and not an error. --- .../Checking/Expressions/CheckExpressions.fs | 2 +- .../AttributeUsage/AttributeUsage.fs | 215 +++++++++--------- .../CustomAttributes/Basic/Basic.fs | 7 +- .../EntryPoint/EntryPoint.fs | 2 +- .../LetBindings/Basic/Basic.fs | 4 +- .../ErrorMessages/TailCallAttribute.fs | 32 +-- 6 files changed, 125 insertions(+), 137 deletions(-) diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index 5f390038e35..e2d21975311 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -11367,7 +11367,7 @@ and TcAttributeEx canFail (cenv: cenv) (env: TcEnv) attrTgt attrEx (synAttr: Syn if (directedTgts = AttributeTargets.Assembly || directedTgts = AttributeTargets.Module) then error(Error(FSComp.SR.tcAttributeIsNotValidForLanguageElementUseDo(), mAttr)) else - error(Error(FSComp.SR.tcAttributeIsNotValidForLanguageElement(), mAttr)) + warning(Error(FSComp.SR.tcAttributeIsNotValidForLanguageElement(), mAttr)) match ResolveObjectConstructor cenv.nameResolver env.DisplayEnv mAttr ad ty with | Exception _ when canFail = TcCanFail.IgnoreAllErrors || canFail = TcCanFail.IgnoreMemberResoutionError -> [ ], true diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs index c7c2cf72eca..f027745b73e 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs @@ -104,10 +104,10 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 21, Col 21, Line 21, Col 22, "This attribute is not valid for use on this language element") - (Error 842, Line 24, Col 21, Line 24, Col 29, "This attribute is not valid for use on this language element") - (Error 842, Line 27, Col 7, Line 27, Col 16, "This attribute is not valid for use on this language element") - (Error 842, Line 18, Col 7, Line 18, Col 8, "This attribute is not valid for use on this language element") + (Warning 842, Line 21, Col 21, Line 21, Col 22, "This attribute is not valid for use on this language element") + (Warning 842, Line 24, Col 21, Line 24, Col 29, "This attribute is not valid for use on this language element") + (Warning 842, Line 27, Col 7, Line 27, Col 16, "This attribute is not valid for use on this language element") + (Warning 842, Line 18, Col 7, Line 18, Col 8, "This attribute is not valid for use on this language element") ] // SOURCE=E_AttributeTargets02.fs # E_AttributeTargets02.fs @@ -117,9 +117,10 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 14, Col 7, Line 14, Col 34, "This attribute is not valid for use on this language element") - (Error 842, Line 24, Col 7, Line 24, Col 36, "This attribute is not valid for use on this language element") - (Error 842, Line 29, Col 15, Line 29, Col 47, "This attribute is not valid for use on this language element") + (Warning 842, Line 14, Col 7, Line 14, Col 34, "This attribute is not valid for use on this language element") + (Warning 842, Line 24, Col 7, Line 24, Col 36, "This attribute is not valid for use on this language element") + (Warning 842, Line 29, Col 15, Line 29, Col 47, "This attribute is not valid for use on this language element") + (Error 3172, Line 28, Col 14, Line 28, Col 17, "A property's getter and setter must have the same type. Property 'Foo' has getter of type 'int' but setter of type 'obj'.") ] // SOURCE=E_AttributeTargetIsField01.fs # E_AttributeTargetIsField01.fs @@ -140,23 +141,23 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 9, Col 3, Line 9, Col 12, "This attribute is not valid for use on this language element") - (Error 842, Line 12, Col 3, Line 12, Col 12, "This attribute is not valid for use on this language element") - (Error 842, Line 15, Col 3, Line 15, Col 12, "This attribute is not valid for use on this language element") - (Error 842, Line 18, Col 3, Line 18, Col 12, "This attribute is not valid for use on this language element") - (Error 842, Line 21, Col 3, Line 21, Col 12, "This attribute is not valid for use on this language element") - (Error 842, Line 24, Col 3, Line 24, Col 12, "This attribute is not valid for use on this language element") - (Error 842, Line 27, Col 3, Line 27, Col 12, "This attribute is not valid for use on this language element") - (Error 842, Line 30, Col 3, Line 30, Col 12, "This attribute is not valid for use on this language element") - (Error 842, Line 33, Col 3, Line 33, Col 12, "This attribute is not valid for use on this language element") - (Error 842, Line 36, Col 3, Line 36, Col 12, "This attribute is not valid for use on this language element") - (Error 842, Line 39, Col 3, Line 39, Col 12, "This attribute is not valid for use on this language element") - (Error 842, Line 42, Col 3, Line 42, Col 12, "This attribute is not valid for use on this language element") - (Error 842, Line 45, Col 3, Line 45, Col 12, "This attribute is not valid for use on this language element") - (Error 842, Line 49, Col 3, Line 49, Col 12, "This attribute is not valid for use on this language element") - (Error 842, Line 56, Col 3, Line 56, Col 12, "This attribute is not valid for use on this language element") - (Error 842, Line 64, Col 3, Line 64, Col 12, "This attribute is not valid for use on this language element") - (Error 842, Line 66, Col 7, Line 66, Col 16, "This attribute is not valid for use on this language element") + (Warning 842, Line 9, Col 3, Line 9, Col 12, "This attribute is not valid for use on this language element") + (Warning 842, Line 12, Col 3, Line 12, Col 12, "This attribute is not valid for use on this language element") + (Warning 842, Line 15, Col 3, Line 15, Col 12, "This attribute is not valid for use on this language element") + (Warning 842, Line 18, Col 3, Line 18, Col 12, "This attribute is not valid for use on this language element") + (Warning 842, Line 21, Col 3, Line 21, Col 12, "This attribute is not valid for use on this language element") + (Warning 842, Line 24, Col 3, Line 24, Col 12, "This attribute is not valid for use on this language element") + (Warning 842, Line 27, Col 3, Line 27, Col 12, "This attribute is not valid for use on this language element") + (Warning 842, Line 30, Col 3, Line 30, Col 12, "This attribute is not valid for use on this language element") + (Warning 842, Line 33, Col 3, Line 33, Col 12, "This attribute is not valid for use on this language element") + (Warning 842, Line 36, Col 3, Line 36, Col 12, "This attribute is not valid for use on this language element") + (Warning 842, Line 39, Col 3, Line 39, Col 12, "This attribute is not valid for use on this language element") + (Warning 842, Line 42, Col 3, Line 42, Col 12, "This attribute is not valid for use on this language element") + (Warning 842, Line 45, Col 3, Line 45, Col 12, "This attribute is not valid for use on this language element") + (Warning 842, Line 49, Col 3, Line 49, Col 12, "This attribute is not valid for use on this language element") + (Warning 842, Line 56, Col 3, Line 56, Col 12, "This attribute is not valid for use on this language element") + (Warning 842, Line 64, Col 3, Line 64, Col 12, "This attribute is not valid for use on this language element") + (Warning 842, Line 66, Col 7, Line 66, Col 16, "This attribute is not valid for use on this language element") ] // SOURCE=E_AttributeTargetIsField02.fs # E_AttributeTargetIsField02.fs @@ -194,17 +195,17 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 9, Col 3, Line 9, Col 13, "This attribute is not valid for use on this language element") - (Error 842, Line 12, Col 3, Line 12, Col 13, "This attribute is not valid for use on this language element") - (Error 842, Line 15, Col 3, Line 15, Col 13, "This attribute is not valid for use on this language element") - (Error 842, Line 18, Col 3, Line 18, Col 13, "This attribute is not valid for use on this language element") - (Error 842, Line 21, Col 3, Line 21, Col 13, "This attribute is not valid for use on this language element") - (Error 842, Line 24, Col 3, Line 24, Col 13, "This attribute is not valid for use on this language element") - (Error 842, Line 26, Col 7, Line 26, Col 17, "This attribute is not valid for use on this language element") - (Error 842, Line 28, Col 3, Line 28, Col 13, "This attribute is not valid for use on this language element") - (Error 842, Line 31, Col 3, Line 31, Col 13, "This attribute is not valid for use on this language element") - (Error 842, Line 34, Col 3, Line 34, Col 13, "This attribute is not valid for use on this language element") - (Error 842, Line 39, Col 3, Line 39, Col 13, "This attribute is not valid for use on this language element") + (Warning 842, Line 9, Col 3, Line 9, Col 13, "This attribute is not valid for use on this language element") + (Warning 842, Line 12, Col 3, Line 12, Col 13, "This attribute is not valid for use on this language element") + (Warning 842, Line 15, Col 3, Line 15, Col 13, "This attribute is not valid for use on this language element") + (Warning 842, Line 18, Col 3, Line 18, Col 13, "This attribute is not valid for use on this language element") + (Warning 842, Line 21, Col 3, Line 21, Col 13, "This attribute is not valid for use on this language element") + (Warning 842, Line 24, Col 3, Line 24, Col 13, "This attribute is not valid for use on this language element") + (Warning 842, Line 26, Col 7, Line 26, Col 17, "This attribute is not valid for use on this language element") + (Warning 842, Line 28, Col 3, Line 28, Col 13, "This attribute is not valid for use on this language element") + (Warning 842, Line 31, Col 3, Line 31, Col 13, "This attribute is not valid for use on this language element") + (Warning 842, Line 34, Col 3, Line 34, Col 13, "This attribute is not valid for use on this language element") + (Warning 842, Line 39, Col 3, Line 39, Col 13, "This attribute is not valid for use on this language element") ] // SOURCE=E_AttributeTargetIsMethod03.fs # E_AttributeTargetIsMethod03.fs @@ -225,21 +226,21 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 12, Col 6, Line 12, Col 16, "This attribute is not valid for use on this language element") - (Error 842, Line 15, Col 6, Line 15, Col 16, "This attribute is not valid for use on this language element") - (Error 842, Line 18, Col 6, Line 18, Col 16, "This attribute is not valid for use on this language element") - (Error 842, Line 20, Col 10, Line 20, Col 20, "This attribute is not valid for use on this language element") - (Error 842, Line 22, Col 6, Line 22, Col 16, "This attribute is not valid for use on this language element") - (Error 842, Line 25, Col 6, Line 25, Col 16, "This attribute is not valid for use on this language element") - (Error 842, Line 28, Col 6, Line 28, Col 16, "This attribute is not valid for use on this language element") - (Error 842, Line 31, Col 6, Line 31, Col 16, "This attribute is not valid for use on this language element") - (Error 842, Line 34, Col 6, Line 34, Col 16, "This attribute is not valid for use on this language element") - (Error 842, Line 37, Col 6, Line 37, Col 16, "This attribute is not valid for use on this language element") - (Error 842, Line 39, Col 10, Line 39, Col 20, "This attribute is not valid for use on this language element") - (Error 842, Line 41, Col 6, Line 41, Col 16, "This attribute is not valid for use on this language element") - (Error 842, Line 44, Col 6, Line 44, Col 16, "This attribute is not valid for use on this language element") - (Error 842, Line 47, Col 6, Line 47, Col 16, "This attribute is not valid for use on this language element") - (Error 842, Line 52, Col 6, Line 52, Col 16, "This attribute is not valid for use on this language element") + (Warning 842, Line 12, Col 6, Line 12, Col 16, "This attribute is not valid for use on this language element") + (Warning 842, Line 15, Col 6, Line 15, Col 16, "This attribute is not valid for use on this language element") + (Warning 842, Line 18, Col 6, Line 18, Col 16, "This attribute is not valid for use on this language element") + (Warning 842, Line 20, Col 10, Line 20, Col 20, "This attribute is not valid for use on this language element") + (Warning 842, Line 22, Col 6, Line 22, Col 16, "This attribute is not valid for use on this language element") + (Warning 842, Line 25, Col 6, Line 25, Col 16, "This attribute is not valid for use on this language element") + (Warning 842, Line 28, Col 6, Line 28, Col 16, "This attribute is not valid for use on this language element") + (Warning 842, Line 31, Col 6, Line 31, Col 16, "This attribute is not valid for use on this language element") + (Warning 842, Line 34, Col 6, Line 34, Col 16, "This attribute is not valid for use on this language element") + (Warning 842, Line 37, Col 6, Line 37, Col 16, "This attribute is not valid for use on this language element") + (Warning 842, Line 39, Col 10, Line 39, Col 20, "This attribute is not valid for use on this language element") + (Warning 842, Line 41, Col 6, Line 41, Col 16, "This attribute is not valid for use on this language element") + (Warning 842, Line 44, Col 6, Line 44, Col 16, "This attribute is not valid for use on this language element") + (Warning 842, Line 47, Col 6, Line 47, Col 16, "This attribute is not valid for use on this language element") + (Warning 842, Line 52, Col 6, Line 52, Col 16, "This attribute is not valid for use on this language element") ] // SOURCE=E_AttributeTargetIsMethod04.fs # E_AttributeTargetIsMethod04.fs @@ -250,8 +251,8 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 10, Col 3, Line 10, Col 15, "This attribute is not valid for use on this language element") - (Error 842, Line 13, Col 3, Line 13, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 10, Col 3, Line 10, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 13, Col 3, Line 13, Col 15, "This attribute is not valid for use on this language element") ] // SOURCE=E_ConditionalAttribute.fs SCFLAGS="--test:ErrorRanges" # E_ConditionalAttribute.fs @@ -293,7 +294,7 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 12, Col 3, Line 12, Col 6, "This attribute is not valid for use on this language element") + (Warning 842, Line 12, Col 3, Line 12, Col 6, "This attribute is not valid for use on this language element") ] // SOURCE=AttributeTargetIsStruct.fs # AttributeTargetIsStruct.fs @@ -342,18 +343,18 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 13, Col 3, Line 13, Col 14, "This attribute is not valid for use on this language element") - (Error 842, Line 19, Col 3, Line 19, Col 14, "This attribute is not valid for use on this language element") - (Error 842, Line 22, Col 11, Line 22, Col 22, "This attribute is not valid for use on this language element") - (Error 842, Line 25, Col 3, Line 25, Col 14, "This attribute is not valid for use on this language element") - (Error 842, Line 34, Col 3, Line 34, Col 18, "This attribute is not valid for use on this language element") - (Error 842, Line 35, Col 3, Line 35, Col 15, "This attribute is not valid for use on this language element") - (Error 842, Line 40, Col 3, Line 40, Col 14, "This attribute is not valid for use on this language element") - (Error 842, Line 41, Col 3, Line 41, Col 18, "This attribute is not valid for use on this language element") - (Error 842, Line 49, Col 3, Line 49, Col 18, "This attribute is not valid for use on this language element") - (Error 842, Line 50, Col 3, Line 50, Col 15, "This attribute is not valid for use on this language element") - (Error 842, Line 53, Col 3, Line 53, Col 14, "This attribute is not valid for use on this language element") - (Error 842, Line 54, Col 3, Line 54, Col 18, "This attribute is not valid for use on this language element") + (Warning 842, Line 13, Col 3, Line 13, Col 14, "This attribute is not valid for use on this language element") + (Warning 842, Line 19, Col 3, Line 19, Col 14, "This attribute is not valid for use on this language element") + (Warning 842, Line 22, Col 11, Line 22, Col 22, "This attribute is not valid for use on this language element") + (Warning 842, Line 25, Col 3, Line 25, Col 14, "This attribute is not valid for use on this language element") + (Warning 842, Line 34, Col 3, Line 34, Col 18, "This attribute is not valid for use on this language element") + (Warning 842, Line 35, Col 3, Line 35, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 40, Col 3, Line 40, Col 14, "This attribute is not valid for use on this language element") + (Warning 842, Line 41, Col 3, Line 41, Col 18, "This attribute is not valid for use on this language element") + (Warning 842, Line 49, Col 3, Line 49, Col 18, "This attribute is not valid for use on this language element") + (Warning 842, Line 50, Col 3, Line 50, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 53, Col 3, Line 53, Col 14, "This attribute is not valid for use on this language element") + (Warning 842, Line 54, Col 3, Line 54, Col 18, "This attribute is not valid for use on this language element") ] // SOURCE=E_AttributeTargetIsClass.fs # E_AttributeTargetIsClass.fs @@ -372,9 +373,9 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 13, Col 3, Line 13, Col 15, "This attribute is not valid for use on this language element") - (Error 842, Line 19, Col 3, Line 19, Col 15, "This attribute is not valid for use on this language element") - (Error 842, Line 22, Col 10, Line 22, Col 22, "This attribute is not valid for use on this language element") + (Warning 842, Line 13, Col 3, Line 13, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 19, Col 3, Line 19, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 22, Col 10, Line 22, Col 22, "This attribute is not valid for use on this language element") ] // SOURCE=E_AttributeTargetIsClass01.fs # E_AttributeTargetIsClass01.fs @@ -393,8 +394,8 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 7, Col 3, Line 7, Col 18, "This attribute is not valid for use on this language element") - (Error 842, Line 10, Col 10, Line 10, Col 25, "This attribute is not valid for use on this language element") + (Warning 842, Line 7, Col 3, Line 7, Col 18, "This attribute is not valid for use on this language element") + (Warning 842, Line 10, Col 10, Line 10, Col 25, "This attribute is not valid for use on this language element") ] // SOURCE=MarshalAsAttribute.fs # MarshalAsAttribute.fs @@ -480,7 +481,7 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 14, Col 5, Line 14, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 14, Col 5, Line 14, Col 15, "This attribute is not valid for use on this language element") ] // SOURCE=E_AttributeTargetIsField03.fs # E_AttributeTargetIsField03.fs @@ -491,8 +492,8 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 14, Col 5, Line 14, Col 15, "This attribute is not valid for use on this language element") - (Error 842, Line 15, Col 5, Line 15, Col 25, "This attribute is not valid for use on this language element") + (Warning 842, Line 14, Col 5, Line 14, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 15, Col 5, Line 15, Col 25, "This attribute is not valid for use on this language element") ] // SOURCE=E_AttributeTargetIsProperty01.fs # E_AttributeTargetIsField03.fs @@ -511,8 +512,8 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 14, Col 5, Line 14, Col 18, "This attribute is not valid for use on this language element") - (Error 842, Line 15, Col 5, Line 15, Col 25, "This attribute is not valid for use on this language element") + (Warning 842, Line 14, Col 5, Line 14, Col 18, "This attribute is not valid for use on this language element") + (Warning 842, Line 15, Col 5, Line 15, Col 25, "This attribute is not valid for use on this language element") ] // SOURCE=E_AttributeTargetIsCtor01.fs # E_AttributeTargetIsCtor01.fs @@ -531,10 +532,10 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 9, Col 15, Line 9, Col 27, "This attribute is not valid for use on this language element") - (Error 842, Line 11, Col 16, Line 11, Col 28, "This attribute is not valid for use on this language element") - (Error 842, Line 14, Col 15, Line 14, Col 27, "This attribute is not valid for use on this language element") - (Error 842, Line 17, Col 16, Line 17, Col 28, "This attribute is not valid for use on this language element") + (Warning 842, Line 9, Col 15, Line 9, Col 27, "This attribute is not valid for use on this language element") + (Warning 842, Line 11, Col 16, Line 11, Col 28, "This attribute is not valid for use on this language element") + (Warning 842, Line 14, Col 15, Line 14, Col 27, "This attribute is not valid for use on this language element") + (Warning 842, Line 17, Col 16, Line 17, Col 28, "This attribute is not valid for use on this language element") ] // SOURCE=AttributeTargetsIsEnum01.fs # AttributeTargetsIsEnum01.fs @@ -568,10 +569,10 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 19, Col 3, Line 19, Col 15, "This attribute is not valid for use on this language element") - (Error 842, Line 20, Col 3, Line 20, Col 14, "This attribute is not valid for use on this language element") - (Error 842, Line 21, Col 3, Line 21, Col 18, "This attribute is not valid for use on this language element") - (Error 842, Line 22, Col 3, Line 22, Col 17, "This attribute is not valid for use on this language element") + (Warning 842, Line 19, Col 3, Line 19, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 20, Col 3, Line 20, Col 14, "This attribute is not valid for use on this language element") + (Warning 842, Line 21, Col 3, Line 21, Col 18, "This attribute is not valid for use on this language element") + (Warning 842, Line 22, Col 3, Line 22, Col 17, "This attribute is not valid for use on this language element") ] // SOURCE=AttributeTargetsIsDelegate01.fs # AttributeTargetsIsDelegate01.fs @@ -605,10 +606,10 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 19, Col 3, Line 19, Col 14, "This attribute is not valid for use on this language element") - (Error 842, Line 20, Col 3, Line 20, Col 15, "This attribute is not valid for use on this language element") - (Error 842, Line 21, Col 3, Line 21, Col 18, "This attribute is not valid for use on this language element") - (Error 842, Line 22, Col 3, Line 22, Col 13, "This attribute is not valid for use on this language element") + (Warning 842, Line 19, Col 3, Line 19, Col 14, "This attribute is not valid for use on this language element") + (Warning 842, Line 20, Col 3, Line 20, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 21, Col 3, Line 21, Col 18, "This attribute is not valid for use on this language element") + (Warning 842, Line 22, Col 3, Line 22, Col 13, "This attribute is not valid for use on this language element") ] [] @@ -654,10 +655,10 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 11, Col 3, Line 11, Col 14, "This attribute is not valid for use on this language element") - (Error 842, Line 14, Col 3, Line 14, Col 15, "This attribute is not valid for use on this language element") - (Error 842, Line 18, Col 3, Line 18, Col 14, "This attribute is not valid for use on this language element") - (Error 842, Line 19, Col 3, Line 19, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 11, Col 3, Line 11, Col 14, "This attribute is not valid for use on this language element") + (Warning 842, Line 14, Col 3, Line 14, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 18, Col 3, Line 18, Col 14, "This attribute is not valid for use on this language element") + (Warning 842, Line 19, Col 3, Line 19, Col 15, "This attribute is not valid for use on this language element") ] // SOURCE= E_AttributeTargetIsClass02.fs # E_AttributeTargetIsClass02.fs @@ -676,18 +677,18 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 15, Col 3, Line 15, Col 18, "This attribute is not valid for use on this language element"); - (Error 842, Line 16, Col 3, Line 16, Col 15, "This attribute is not valid for use on this language element") - (Error 842, Line 20, Col 3, Line 20, Col 14, "This attribute is not valid for use on this language element") - (Error 842, Line 21, Col 3, Line 21, Col 18, "This attribute is not valid for use on this language element") - (Error 842, Line 26, Col 3, Line 26, Col 14, "This attribute is not valid for use on this language element") - (Error 842, Line 27, Col 3, Line 27, Col 18, "This attribute is not valid for use on this language element") - (Error 842, Line 34, Col 3, Line 34, Col 14, "This attribute is not valid for use on this language element") - (Error 842, Line 35, Col 3, Line 35, Col 18, "This attribute is not valid for use on this language element") - (Error 842, Line 43, Col 3, Line 43, Col 18, "This attribute is not valid for use on this language element") - (Error 842, Line 44, Col 3, Line 44, Col 15, "This attribute is not valid for use on this language element") - (Error 842, Line 47, Col 3, Line 47, Col 14, "This attribute is not valid for use on this language element") - (Error 842, Line 48, Col 3, Line 48, Col 18, "This attribute is not valid for use on this language element") + (Warning 842, Line 15, Col 3, Line 15, Col 18, "This attribute is not valid for use on this language element"); + (Warning 842, Line 16, Col 3, Line 16, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 20, Col 3, Line 20, Col 14, "This attribute is not valid for use on this language element") + (Warning 842, Line 21, Col 3, Line 21, Col 18, "This attribute is not valid for use on this language element") + (Warning 842, Line 26, Col 3, Line 26, Col 14, "This attribute is not valid for use on this language element") + (Warning 842, Line 27, Col 3, Line 27, Col 18, "This attribute is not valid for use on this language element") + (Warning 842, Line 34, Col 3, Line 34, Col 14, "This attribute is not valid for use on this language element") + (Warning 842, Line 35, Col 3, Line 35, Col 18, "This attribute is not valid for use on this language element") + (Warning 842, Line 43, Col 3, Line 43, Col 18, "This attribute is not valid for use on this language element") + (Warning 842, Line 44, Col 3, Line 44, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 47, Col 3, Line 47, Col 14, "This attribute is not valid for use on this language element") + (Warning 842, Line 48, Col 3, Line 48, Col 18, "This attribute is not valid for use on this language element") ] // SOURCE= CLIMutableAttribute01.fs # CLIMutableAttribute01.fs @@ -756,8 +757,8 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) = (Error 934, Line 33, Col 10, Line 33, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute") (Error 934, Line 36, Col 10, Line 36, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute") (Error 934, Line 39, Col 10, Line 39, Col 13, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute") - (Error 842, Line 41, Col 7, Line 41, Col 23, "This attribute is not valid for use on this language element") - (Error 842, Line 44, Col 7, Line 44, Col 23, "This attribute is not valid for use on this language element") + (Warning 842, Line 41, Col 7, Line 41, Col 23, "This attribute is not valid for use on this language element") + (Warning 842, Line 44, Col 7, Line 44, Col 23, "This attribute is not valid for use on this language element") (Error 935, Line 54, Col 10, Line 54, Col 11, "Types with the 'AllowNullLiteral' attribute may only inherit from or implement types which also allow the use of the null literal") ] @@ -775,8 +776,8 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) = (Error 934, Line 33, Col 10, Line 33, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute") (Error 934, Line 36, Col 10, Line 36, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute") (Error 934, Line 39, Col 10, Line 39, Col 13, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute") - (Error 842, Line 41, Col 7, Line 41, Col 23, "This attribute is not valid for use on this language element") - (Error 842, Line 44, Col 7, Line 44, Col 23, "This attribute is not valid for use on this language element") + (Warning 842, Line 41, Col 7, Line 41, Col 23, "This attribute is not valid for use on this language element") + (Warning 842, Line 44, Col 7, Line 44, Col 23, "This attribute is not valid for use on this language element") (Error 935, Line 54, Col 10, Line 54, Col 11, "Types with the 'AllowNullLiteral' attribute may only inherit from or implement types which also allow the use of the null literal") ] 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 1e3c99dc8a5..44ee388af9d 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/Basic.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/Basic.fs @@ -61,7 +61,7 @@ module CustomAttributes_Basic = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 15, Col 7, Line 15, Col 17, "This attribute is not valid for use on this language element") + (Warning 842, Line 15, Col 7, Line 15, Col 17, "This attribute is not valid for use on this language element") ] // SOURCE=E_AttributeApplication04.fs SCFLAGS="--test:ErrorRanges" # E_AttributeApplication04.fs @@ -71,7 +71,7 @@ module CustomAttributes_Basic = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 14, Col 3, Line 14, Col 13, "This attribute is not valid for use on this language element") + (Warning 842, Line 14, Col 3, Line 14, Col 13, "This attribute is not valid for use on this language element") ] // SOURCE=E_AttributeApplication05.fs SCFLAGS="--test:ErrorRanges" # E_AttributeApplication05.fs @@ -81,7 +81,8 @@ module CustomAttributes_Basic = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 842, Line 8, Col 7, Line 8, Col 8, "This attribute is not valid for use on this language element") + (Warning 842, Line 8, Col 7, Line 8, Col 8, "This attribute is not valid for use on this language element") + (Error 824, Line 8, Col 7, Line 8, Col 8, "Attributes are not permitted on 'let' bindings in expressions") (Warning 20, Line 8, Col 1, Line 8, Col 31, "The result of this expression has type 'int' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") ] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/EntryPoint/EntryPoint.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/EntryPoint/EntryPoint.fs index ce51bcf6c14..38b84fb6498 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/EntryPoint/EntryPoint.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/EntryPoint/EntryPoint.fs @@ -75,7 +75,7 @@ module EntryPoint = |> compile |> shouldFail |> withDiagnostics [ - (Error 842, Line 9, Col 3, Line 9, Col 13, """This attribute is not valid for use on this language element""") + (Warning 842, Line 9, Col 3, Line 9, Col 13, """This attribute is not valid for use on this language element""") ] // SOURCE=E_twoattributesonsamefunction001.fs SCFLAGS="--test:ErrorRanges" # E_twoattributesonsamefunction001.fs diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/LetBindings/Basic/Basic.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/LetBindings/Basic/Basic.fs index c0a19c9ad3e..b59d28cbdd2 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/LetBindings/Basic/Basic.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/LetBindings/Basic/Basic.fs @@ -53,9 +53,9 @@ module LetBindings_Basic = |> shouldFail |> withDiagnostics [ (Error 683, Line 14, Col 6, Line 14, Col 27, "Attributes are not allowed within patterns") - (Error 842, Line 14, Col 8, Line 14, Col 25, "This attribute is not valid for use on this language element") + (Warning 842, Line 14, Col 8, Line 14, Col 25, "This attribute is not valid for use on this language element") (Error 683, Line 14, Col 42, Line 14, Col 63, "Attributes are not allowed within patterns") - (Error 842, Line 14, Col 44, Line 14, Col 61, "This attribute is not valid for use on this language element") + (Warning 842, Line 14, Col 44, Line 14, Col 61, "This attribute is not valid for use on this language element") ] // SOURCE=E_ErrorsForInlineValue.fs SCFLAGS="--test:ErrorRanges" # E_ErrorsForInlineValue.fs diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs index 1b68505ab1e..81ce04fc05a 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs @@ -245,7 +245,7 @@ namespace N [] let ``Warn successfully for invalid tailcalls in type methods`` () = - """ + FSharp """ namespace N module M = @@ -261,29 +261,12 @@ namespace N printfn "M2 called" this.M1() + 2 // should warn """ - |> FSharp |> withLangVersion80 |> compile |> shouldFail - |> withResults [ - { Error = Warning 3569 - Range = { StartLine = 10 - StartColumn = 17 - EndLine = 10 - EndColumn = 26 } - Message = - "The member or function 'M2' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way." } - { Error = Warning 3569 - Range = { StartLine = 15 - StartColumn = 17 - EndLine = 15 - EndColumn = 26 } - Message = -#if Debug - "The member or function 'M2' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way." } -#else - "The member or function 'M1' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way." } -#endif + |> withDiagnostics [ + (Warning 3569, Line 10, Col 17, Line 10, Col 26, "The member or function 'M2' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way."); + (Warning 3569, Line 15, Col 17, Line 15, Col 26, "The member or function 'M1' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way.") ] [] @@ -1481,7 +1464,10 @@ namespace N |> withLangVersionPreview |> compile |> shouldFail - |> withSingleDiagnostic (Error 842, Line 6, Col 11, Line 6, Col 19, "This attribute is not valid for use on this language element") + |> withDiagnostics [ + (Warning 842, Line 6, Col 11, Line 6, Col 19, "This attribute is not valid for use on this language element") + (Warning 3861, Line 7, Col 13, Line 7, Col 18, "The TailCall attribute should only be applied to recursive functions.") + ] [] let ``Error about attribute on recursive let-bound value`` () = @@ -1497,7 +1483,7 @@ namespace N |> withLangVersionPreview |> compile |> shouldFail - |> withSingleDiagnostic (Error 842, Line 6, Col 11, Line 6, Col 19, "This attribute is not valid for use on this language element") + |> withSingleDiagnostic (Warning 842, Line 6, Col 11, Line 6, Col 19, "This attribute is not valid for use on this language element") [] let ``Warn about self-defined attribute`` () = // is the analysis available for users of older FSharp.Core versions From 55507e9e7e98e640678932f96a25cb3bacc82904 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 23 Apr 2025 15:39:04 +0100 Subject: [PATCH 02/18] release notes --- docs/release-notes/.FSharp.Compiler.Service/9.0.300.md | 1 + 1 file changed, 1 insertion(+) 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 16f5721e22a..05e15a667dd 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md @@ -48,6 +48,7 @@ * Warning for "useless null handling" works with piped syntax constructs now ([PR #18331](https://github.com/dotnet/fsharp/pull/18331)) * Make indent in generated overridden member code depend on the context, not fix to 4. ([PR #18341](https://github.com/dotnet/fsharp/pull/18341)) * Adjust caller info attribute error message range ([PR #18388](https://github.com/dotnet/fsharp/pull/18388)) +* Make attribute targets mismatch a warning and not an error ([PR #18492](https://github.com/dotnet/fsharp/pull/18492)) ### Breaking Changes * Struct unions with overlapping fields now generate mappings needed for reading via reflection ([Issue #18121](https://github.com/dotnet/fsharp/issues/17797), [PR #18274](https://github.com/dotnet/fsharp/pull/17877)) From 17380183feebe6a1cf30a8f678965b6cd689de82 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 23 Apr 2025 16:19:59 +0100 Subject: [PATCH 03/18] update tests --- .../PatternMatchCompilationTests.fs | 1 + .../Language/StructActivePatternTests.fs | 2 +- tests/fsharp/typecheck/sigs/neg16.bsl | 4 +- tests/fsharp/typecheck/sigs/neg20.bsl | 46 +++++++++---------- tests/fsharp/typecheck/sigs/neg32.bsl | 2 +- .../fsharp/typecheck/sigs/version50/neg20.bsl | 46 +++++++++---------- .../UnitsOfMeasure/WithOOP/E_GenericUOM01.fs | 2 +- 7 files changed, 52 insertions(+), 51 deletions(-) diff --git a/tests/FSharp.Compiler.Service.Tests/PatternMatchCompilationTests.fs b/tests/FSharp.Compiler.Service.Tests/PatternMatchCompilationTests.fs index 1b6d54d3577..cf870698077 100644 --- a/tests/FSharp.Compiler.Service.Tests/PatternMatchCompilationTests.fs +++ b/tests/FSharp.Compiler.Service.Tests/PatternMatchCompilationTests.fs @@ -41,6 +41,7 @@ match () with dumpDiagnostics checkResults |> shouldEqual [ "(3,2--3,25): Attributes are not allowed within patterns" "(3,4--3,23): This attribute is not valid for use on this language element" + "(3,17--3,22): This is not a valid constant expression or custom attribute value" ] diff --git a/tests/fsharp/Compiler/Language/StructActivePatternTests.fs b/tests/fsharp/Compiler/Language/StructActivePatternTests.fs index aac654f549c..4c2451142fa 100644 --- a/tests/fsharp/Compiler/Language/StructActivePatternTests.fs +++ b/tests/fsharp/Compiler/Language/StructActivePatternTests.fs @@ -176,7 +176,7 @@ let (|Foo|_|) x = ValueNone [] let (|Foo|_|) x = ValueNone """ - [|(FSharpDiagnosticSeverity.Error, 842, (2, 3, 2, 9), + [|(FSharpDiagnosticSeverity.Warning, 842, (2, 3, 2, 9), "This attribute is not valid for use on this language element"); (FSharpDiagnosticSeverity.Error, 3350, (3, 6, 3, 13), "Feature 'Boolean-returning and return-type-directed partial active patterns' is not available in F# 8.0. Please use language version 9.0 or greater.")|] diff --git a/tests/fsharp/typecheck/sigs/neg16.bsl b/tests/fsharp/typecheck/sigs/neg16.bsl index 4c2300470f7..448ca9127be 100644 --- a/tests/fsharp/typecheck/sigs/neg16.bsl +++ b/tests/fsharp/typecheck/sigs/neg16.bsl @@ -13,9 +13,9 @@ neg16.fs(44,10,44,11): typecheck error FS0934: Records, union, abbreviations and neg16.fs(47,10,47,13): typecheck error FS0934: Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute -neg16.fs(49,7,49,23): typecheck error FS0842: This attribute is not valid for use on this language element +neg16.fs(49,7,49,23): typecheck warning FS0842: This attribute is not valid for use on this language element -neg16.fs(52,7,52,23): typecheck error FS0842: This attribute is not valid for use on this language element +neg16.fs(52,7,52,23): typecheck warning FS0842: This attribute is not valid for use on this language element neg16.fs(59,8,59,17): typecheck error FS0001: This expression was expected to have type 'Choice<'a,'b>' diff --git a/tests/fsharp/typecheck/sigs/neg20.bsl b/tests/fsharp/typecheck/sigs/neg20.bsl index 5229dcaacf6..28fa11b53f7 100644 --- a/tests/fsharp/typecheck/sigs/neg20.bsl +++ b/tests/fsharp/typecheck/sigs/neg20.bsl @@ -213,53 +213,53 @@ neg20.fs(190,34,190,39): typecheck error FS0001: This expression was expected to but here has type 'objnull' -neg20.fs(195,5,195,10): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(195,5,195,10): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(198,5,198,11): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(198,5,198,11): typecheck warning FS0842: This attribute is not valid for use on this language element neg20.fs(202,7,202,9): typecheck error FS0825: The 'DefaultValue' attribute may only be used on 'val' declarations -neg20.fs(204,5,204,14): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(204,5,204,14): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(207,5,207,11): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(207,5,207,11): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(210,5,210,12): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(210,5,210,12): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(213,5,213,33): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(213,5,213,33): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(216,5,216,12): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(216,5,216,12): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(219,5,219,15): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(219,5,219,15): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(222,5,222,31): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(222,5,222,31): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(225,5,225,22): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(225,5,225,22): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(228,5,228,23): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(228,5,228,23): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(231,5,231,21): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(231,5,231,21): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(234,5,234,34): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(234,5,234,34): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(237,5,237,34): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(237,5,237,34): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(240,5,240,23): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(240,5,240,23): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(243,5,243,23): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(243,5,243,23): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(249,9,249,27): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(249,9,249,27): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(255,5,255,28): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(255,5,255,28): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(258,5,258,38): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(258,5,258,38): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(261,5,261,17): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(261,5,261,17): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(265,5,265,24): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(265,5,265,24): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(268,5,268,27): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(268,5,268,27): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(271,5,271,15): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(271,5,271,15): typecheck warning FS0842: This attribute is not valid for use on this language element neg20.fs(278,14,278,95): typecheck error FS0507: No accessible member or object constructor named 'ProcessStartInfo' takes 0 arguments. Note the call to this member also provides 2 named arguments. diff --git a/tests/fsharp/typecheck/sigs/neg32.bsl b/tests/fsharp/typecheck/sigs/neg32.bsl index 87fbc723312..376138c1858 100644 --- a/tests/fsharp/typecheck/sigs/neg32.bsl +++ b/tests/fsharp/typecheck/sigs/neg32.bsl @@ -1,5 +1,5 @@ -neg32.fs(17,11,17,56): typecheck error FS0842: This attribute is not valid for use on this language element +neg32.fs(17,11,17,56): typecheck warning FS0842: This attribute is not valid for use on this language element neg32.fs(24,15,24,16): typecheck error FS0043: The member or object constructor 'TryParse' does not take 1 argument(s). An overload was found taking 2 arguments. diff --git a/tests/fsharp/typecheck/sigs/version50/neg20.bsl b/tests/fsharp/typecheck/sigs/version50/neg20.bsl index 394f7777b2a..f85f1d5d14f 100644 --- a/tests/fsharp/typecheck/sigs/version50/neg20.bsl +++ b/tests/fsharp/typecheck/sigs/version50/neg20.bsl @@ -261,53 +261,53 @@ neg20.fs(190,34,190,39): typecheck error FS0001: This expression was expected to but here has type 'objnull' -neg20.fs(195,5,195,10): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(195,5,195,10): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(198,5,198,11): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(198,5,198,11): typecheck warning FS0842: This attribute is not valid for use on this language element neg20.fs(202,7,202,9): typecheck error FS0825: The 'DefaultValue' attribute may only be used on 'val' declarations -neg20.fs(204,5,204,14): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(204,5,204,14): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(207,5,207,11): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(207,5,207,11): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(210,5,210,12): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(210,5,210,12): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(213,5,213,33): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(213,5,213,33): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(216,5,216,12): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(216,5,216,12): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(219,5,219,15): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(219,5,219,15): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(222,5,222,31): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(222,5,222,31): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(225,5,225,22): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(225,5,225,22): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(228,5,228,23): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(228,5,228,23): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(231,5,231,21): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(231,5,231,21): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(234,5,234,34): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(234,5,234,34): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(237,5,237,34): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(237,5,237,34): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(240,5,240,23): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(240,5,240,23): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(243,5,243,23): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(243,5,243,23): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(249,9,249,27): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(249,9,249,27): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(255,5,255,28): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(255,5,255,28): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(258,5,258,38): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(258,5,258,38): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(261,5,261,17): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(261,5,261,17): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(265,5,265,24): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(265,5,265,24): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(268,5,268,27): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(268,5,268,27): typecheck warning FS0842: This attribute is not valid for use on this language element -neg20.fs(271,5,271,15): typecheck error FS0842: This attribute is not valid for use on this language element +neg20.fs(271,5,271,15): typecheck warning FS0842: This attribute is not valid for use on this language element neg20.fs(278,14,278,95): typecheck error FS0507: No accessible member or object constructor named 'ProcessStartInfo' takes 0 arguments. Note the call to this member also provides 2 named arguments. diff --git a/tests/fsharpqa/Source/Conformance/UnitsOfMeasure/WithOOP/E_GenericUOM01.fs b/tests/fsharpqa/Source/Conformance/UnitsOfMeasure/WithOOP/E_GenericUOM01.fs index 369697935e3..0f27193b5a7 100644 --- a/tests/fsharpqa/Source/Conformance/UnitsOfMeasure/WithOOP/E_GenericUOM01.fs +++ b/tests/fsharpqa/Source/Conformance/UnitsOfMeasure/WithOOP/E_GenericUOM01.fs @@ -1,7 +1,7 @@ // #Regression #Conformance #UnitsOfMeasure #ObjectOrientedTypes // Verify error when putting invalid attributes on type arguments // (We should only allow [].) -//This attribute is not valid for use on this language element +//This attribute is not valid for use on this language element open System From 6f2b7064781a2c33c254f17ffac1a31a8cd3f41e Mon Sep 17 00:00:00 2001 From: edgargonzalez Date: Tue, 29 Apr 2025 09:43:56 +0100 Subject: [PATCH 04/18] update baselines --- tests/fsharp/typecheck/sigs/neg16.bsl | 4 +- tests/fsharp/typecheck/sigs/neg20.bsl | 48 ++++++++++--------- tests/fsharp/typecheck/sigs/neg32.bsl | 4 +- .../fsharp/typecheck/sigs/version50/neg20.bsl | 48 ++++++++++--------- 4 files changed, 54 insertions(+), 50 deletions(-) diff --git a/tests/fsharp/typecheck/sigs/neg16.bsl b/tests/fsharp/typecheck/sigs/neg16.bsl index 448ca9127be..4c2300470f7 100644 --- a/tests/fsharp/typecheck/sigs/neg16.bsl +++ b/tests/fsharp/typecheck/sigs/neg16.bsl @@ -13,9 +13,9 @@ neg16.fs(44,10,44,11): typecheck error FS0934: Records, union, abbreviations and neg16.fs(47,10,47,13): typecheck error FS0934: Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute -neg16.fs(49,7,49,23): typecheck warning FS0842: This attribute is not valid for use on this language element +neg16.fs(49,7,49,23): typecheck error FS0842: This attribute is not valid for use on this language element -neg16.fs(52,7,52,23): typecheck warning FS0842: This attribute is not valid for use on this language element +neg16.fs(52,7,52,23): typecheck error FS0842: This attribute is not valid for use on this language element neg16.fs(59,8,59,17): typecheck error FS0001: This expression was expected to have type 'Choice<'a,'b>' diff --git a/tests/fsharp/typecheck/sigs/neg20.bsl b/tests/fsharp/typecheck/sigs/neg20.bsl index 28fa11b53f7..2ff8515a78a 100644 --- a/tests/fsharp/typecheck/sigs/neg20.bsl +++ b/tests/fsharp/typecheck/sigs/neg20.bsl @@ -213,53 +213,53 @@ neg20.fs(190,34,190,39): typecheck error FS0001: This expression was expected to but here has type 'objnull' -neg20.fs(195,5,195,10): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(195,5,195,10): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(198,5,198,11): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(198,5,198,11): typecheck error FS0842: This attribute is not valid for use on this language element neg20.fs(202,7,202,9): typecheck error FS0825: The 'DefaultValue' attribute may only be used on 'val' declarations -neg20.fs(204,5,204,14): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(204,5,204,14): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(207,5,207,11): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(207,5,207,11): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(210,5,210,12): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(210,5,210,12): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(213,5,213,33): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(213,5,213,33): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(216,5,216,12): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(216,5,216,12): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(219,5,219,15): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(219,5,219,15): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(222,5,222,31): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(222,5,222,31): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(225,5,225,22): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(225,5,225,22): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(228,5,228,23): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(228,5,228,23): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(231,5,231,21): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(231,5,231,21): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(234,5,234,34): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(234,5,234,34): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(237,5,237,34): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(237,5,237,34): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(240,5,240,23): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(240,5,240,23): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(243,5,243,23): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(243,5,243,23): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(249,9,249,27): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(249,9,249,27): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(255,5,255,28): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(255,5,255,28): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(258,5,258,38): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(258,5,258,38): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(261,5,261,17): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(261,5,261,17): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(265,5,265,24): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(265,5,265,24): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(268,5,268,27): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(268,5,268,27): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(271,5,271,15): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(271,5,271,15): typecheck error FS0842: This attribute is not valid for use on this language element neg20.fs(278,14,278,95): typecheck error FS0507: No accessible member or object constructor named 'ProcessStartInfo' takes 0 arguments. Note the call to this member also provides 2 named arguments. @@ -294,6 +294,7 @@ neg20.fs(335,11,335,24): typecheck error FS0041: A unique overload for method 'S Known type of argument: 'a0 Candidates: + - System.String(value: System.ReadOnlySpan) : System.String - System.String(value: char array) : System.String - System.String(value: nativeptr) : System.String - System.String(value: nativeptr) : System.String @@ -303,6 +304,7 @@ neg20.fs(336,11,336,22): typecheck error FS0041: A unique overload for method 'G Known type of argument: 'a0 Candidates: + - System.Guid(b: System.ReadOnlySpan) : System.Guid - System.Guid(b: byte array) : System.Guid - System.Guid(g: string) : System.Guid diff --git a/tests/fsharp/typecheck/sigs/neg32.bsl b/tests/fsharp/typecheck/sigs/neg32.bsl index 376138c1858..7649c0719b5 100644 --- a/tests/fsharp/typecheck/sigs/neg32.bsl +++ b/tests/fsharp/typecheck/sigs/neg32.bsl @@ -1,7 +1,7 @@ -neg32.fs(17,11,17,56): typecheck warning FS0842: This attribute is not valid for use on this language element +neg32.fs(17,11,17,56): typecheck error FS0842: This attribute is not valid for use on this language element -neg32.fs(24,15,24,16): typecheck error FS0043: The member or object constructor 'TryParse' does not take 1 argument(s). An overload was found taking 2 arguments. +neg32.fs(24,15,24,16): typecheck error FS0043: The member or object constructor 'TryParse' does not take 1 argument(s). An overload was found taking 4 arguments. neg32.fs(43,17,43,19): typecheck error FS0039: The type parameter 'T is not defined. diff --git a/tests/fsharp/typecheck/sigs/version50/neg20.bsl b/tests/fsharp/typecheck/sigs/version50/neg20.bsl index f85f1d5d14f..d5de8268fab 100644 --- a/tests/fsharp/typecheck/sigs/version50/neg20.bsl +++ b/tests/fsharp/typecheck/sigs/version50/neg20.bsl @@ -261,53 +261,53 @@ neg20.fs(190,34,190,39): typecheck error FS0001: This expression was expected to but here has type 'objnull' -neg20.fs(195,5,195,10): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(195,5,195,10): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(198,5,198,11): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(198,5,198,11): typecheck error FS0842: This attribute is not valid for use on this language element neg20.fs(202,7,202,9): typecheck error FS0825: The 'DefaultValue' attribute may only be used on 'val' declarations -neg20.fs(204,5,204,14): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(204,5,204,14): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(207,5,207,11): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(207,5,207,11): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(210,5,210,12): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(210,5,210,12): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(213,5,213,33): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(213,5,213,33): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(216,5,216,12): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(216,5,216,12): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(219,5,219,15): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(219,5,219,15): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(222,5,222,31): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(222,5,222,31): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(225,5,225,22): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(225,5,225,22): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(228,5,228,23): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(228,5,228,23): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(231,5,231,21): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(231,5,231,21): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(234,5,234,34): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(234,5,234,34): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(237,5,237,34): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(237,5,237,34): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(240,5,240,23): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(240,5,240,23): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(243,5,243,23): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(243,5,243,23): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(249,9,249,27): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(249,9,249,27): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(255,5,255,28): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(255,5,255,28): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(258,5,258,38): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(258,5,258,38): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(261,5,261,17): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(261,5,261,17): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(265,5,265,24): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(265,5,265,24): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(268,5,268,27): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(268,5,268,27): typecheck error FS0842: This attribute is not valid for use on this language element -neg20.fs(271,5,271,15): typecheck warning FS0842: This attribute is not valid for use on this language element +neg20.fs(271,5,271,15): typecheck error FS0842: This attribute is not valid for use on this language element neg20.fs(278,14,278,95): typecheck error FS0507: No accessible member or object constructor named 'ProcessStartInfo' takes 0 arguments. Note the call to this member also provides 2 named arguments. @@ -342,6 +342,7 @@ neg20.fs(335,11,335,24): typecheck error FS0041: A unique overload for method 'S Known type of argument: 'a0 Candidates: + - System.String(value: System.ReadOnlySpan) : System.String - System.String(value: char array) : System.String - System.String(value: nativeptr) : System.String - System.String(value: nativeptr) : System.String @@ -351,6 +352,7 @@ neg20.fs(336,11,336,22): typecheck error FS0041: A unique overload for method 'G Known type of argument: 'a0 Candidates: + - System.Guid(b: System.ReadOnlySpan) : System.Guid - System.Guid(b: byte array) : System.Guid - System.Guid(g: string) : System.Guid From 75d8f5ef637741991df6c15ae75d202b8412dd65 Mon Sep 17 00:00:00 2001 From: edgargonzalez Date: Tue, 29 Apr 2025 19:33:38 +0100 Subject: [PATCH 05/18] Update baselines --- tests/fsharp/typecheck/sigs/neg20.bsl | 2 -- tests/fsharp/typecheck/sigs/neg32.bsl | 2 +- tests/fsharp/typecheck/sigs/version50/neg20.bsl | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/fsharp/typecheck/sigs/neg20.bsl b/tests/fsharp/typecheck/sigs/neg20.bsl index 2ff8515a78a..5229dcaacf6 100644 --- a/tests/fsharp/typecheck/sigs/neg20.bsl +++ b/tests/fsharp/typecheck/sigs/neg20.bsl @@ -294,7 +294,6 @@ neg20.fs(335,11,335,24): typecheck error FS0041: A unique overload for method 'S Known type of argument: 'a0 Candidates: - - System.String(value: System.ReadOnlySpan) : System.String - System.String(value: char array) : System.String - System.String(value: nativeptr) : System.String - System.String(value: nativeptr) : System.String @@ -304,7 +303,6 @@ neg20.fs(336,11,336,22): typecheck error FS0041: A unique overload for method 'G Known type of argument: 'a0 Candidates: - - System.Guid(b: System.ReadOnlySpan) : System.Guid - System.Guid(b: byte array) : System.Guid - System.Guid(g: string) : System.Guid diff --git a/tests/fsharp/typecheck/sigs/neg32.bsl b/tests/fsharp/typecheck/sigs/neg32.bsl index 7649c0719b5..87fbc723312 100644 --- a/tests/fsharp/typecheck/sigs/neg32.bsl +++ b/tests/fsharp/typecheck/sigs/neg32.bsl @@ -1,7 +1,7 @@ neg32.fs(17,11,17,56): typecheck error FS0842: This attribute is not valid for use on this language element -neg32.fs(24,15,24,16): typecheck error FS0043: The member or object constructor 'TryParse' does not take 1 argument(s). An overload was found taking 4 arguments. +neg32.fs(24,15,24,16): typecheck error FS0043: The member or object constructor 'TryParse' does not take 1 argument(s). An overload was found taking 2 arguments. neg32.fs(43,17,43,19): typecheck error FS0039: The type parameter 'T is not defined. diff --git a/tests/fsharp/typecheck/sigs/version50/neg20.bsl b/tests/fsharp/typecheck/sigs/version50/neg20.bsl index d5de8268fab..394f7777b2a 100644 --- a/tests/fsharp/typecheck/sigs/version50/neg20.bsl +++ b/tests/fsharp/typecheck/sigs/version50/neg20.bsl @@ -342,7 +342,6 @@ neg20.fs(335,11,335,24): typecheck error FS0041: A unique overload for method 'S Known type of argument: 'a0 Candidates: - - System.String(value: System.ReadOnlySpan) : System.String - System.String(value: char array) : System.String - System.String(value: nativeptr) : System.String - System.String(value: nativeptr) : System.String @@ -352,7 +351,6 @@ neg20.fs(336,11,336,22): typecheck error FS0041: A unique overload for method 'G Known type of argument: 'a0 Candidates: - - System.Guid(b: System.ReadOnlySpan) : System.Guid - System.Guid(b: byte array) : System.Guid - System.Guid(g: string) : System.Guid From 4248f2a9225b2533cb4137d1e1b4311ce9e3cad1 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 30 Apr 2025 21:58:10 +0100 Subject: [PATCH 06/18] Move attribute form logic to an AP --- .../Checking/Expressions/CheckExpressions.fs | 55 +++++++++++-------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index e2d21975311..567e1da0310 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -3187,6 +3187,24 @@ let BuildRecdFieldSet g m objExpr (rfinfo: RecdFieldInfo) argExpr = let wrap, objExpr, _readonly, _writeonly = mkExprAddrOfExpr g boxity false DefinitelyMutates objExpr None m wrap (mkRecdFieldSetViaExprAddr (objExpr, rfinfo.RecdFieldRef, rfinfo.TypeInst, argExpr, m) ) +// This is used to check the target of an attribute with the form of +// Long Form: [] +// Short Form: [] +let (|LongFormAttrTarget|UnrecognizedLongAttrTarget|ShortFormAttributeTarget|) (targetIndicator: Ident option) = + match targetIndicator with + | Some id when id.idText = "assembly" -> LongFormAttrTarget AttributeTargets.Assembly + | Some id when id.idText = "module" -> LongFormAttrTarget AttributeTargets.Module + | Some id when id.idText = "return" -> LongFormAttrTarget AttributeTargets.ReturnValue + | Some id when id.idText = "field" -> LongFormAttrTarget AttributeTargets.Field + | Some id when id.idText = "property" -> LongFormAttrTarget AttributeTargets.Property + | Some id when id.idText = "method" -> LongFormAttrTarget AttributeTargets.Method + | Some id when id.idText = "param" -> LongFormAttrTarget AttributeTargets.Parameter + | Some id when id.idText = "type" -> LongFormAttrTarget AttributeTargets.TyconDecl + | Some id when id.idText = "constructor" -> LongFormAttrTarget AttributeTargets.Constructor + | Some id when id.idText = "event" -> LongFormAttrTarget AttributeTargets.Event + | Some id -> UnrecognizedLongAttrTarget id + | None -> ShortFormAttributeTarget + //------------------------------------------------------------------------- // Helpers dealing with named and optional args at callsites //------------------------------------------------------------------------- @@ -11344,27 +11362,18 @@ and TcAttributeEx canFail (cenv: cenv) (env: TcEnv) attrTgt attrEx (synAttr: Syn (validOnDefault, inheritedDefault) | _ -> (validOnDefault, inheritedDefault) - let possibleTgts = enum validOn &&& attrTgt - let directedTgts = + let attributeTargets = enum validOn &&& attrTgt + let directedTargets = match targetIndicator with - | Some id when id.idText = "assembly" -> AttributeTargets.Assembly - | Some id when id.idText = "module" -> AttributeTargets.Module - | Some id when id.idText = "return" -> AttributeTargets.ReturnValue - | Some id when id.idText = "field" -> AttributeTargets.Field - | Some id when id.idText = "property" -> AttributeTargets.Property - | Some id when id.idText = "method" -> AttributeTargets.Method - | Some id when id.idText = "param" -> AttributeTargets.Parameter - | Some id when id.idText = "type" -> AttributeTargets.TyconDecl - | Some id when id.idText = "constructor" -> AttributeTargets.Constructor - | Some id when id.idText = "event" -> AttributeTargets.Event - | Some id -> - errorR(Error(FSComp.SR.tcUnrecognizedAttributeTarget(), id.idRange)) - possibleTgts - // mask explicit targets - | _ -> possibleTgts &&& ~~~ attrEx - let constrainedTgts = possibleTgts &&& directedTgts - if constrainedTgts = enum 0 then - if (directedTgts = AttributeTargets.Assembly || directedTgts = AttributeTargets.Module) then + | LongFormAttrTarget attrTarget -> attrTarget + | UnrecognizedLongAttrTarget attrTarget -> + errorR(Error(FSComp.SR.tcUnrecognizedAttributeTarget(), attrTarget.idRange)) + attributeTargets + | ShortFormAttributeTarget -> attributeTargets &&& ~~~ attrEx + + let constrainedTargets = attributeTargets &&& directedTargets + if constrainedTargets = enum 0 then + if (directedTargets = AttributeTargets.Assembly || directedTargets = AttributeTargets.Module) then error(Error(FSComp.SR.tcAttributeIsNotValidForLanguageElementUseDo(), mAttr)) else warning(Error(FSComp.SR.tcAttributeIsNotValidForLanguageElement(), mAttr)) @@ -11428,11 +11437,11 @@ and TcAttributeEx canFail (cenv: cenv) (env: TcEnv) attrTgt attrEx (synAttr: Syn if isStruct then error (Error(FSComp.SR.tcCustomAttributeMustBeReferenceType(), m)) if args.Length <> ilMethRef.ArgTypes.Length then error (Error(FSComp.SR.tcCustomAttributeArgumentMismatch(), m)) let args = args |> List.map mkAttribExpr - Attrib(tcref, ILAttrib ilMethRef, args, namedAttribArgMap, isAppliedToGetterOrSetter, Some constrainedTgts, m) + Attrib(tcref, ILAttrib ilMethRef, args, namedAttribArgMap, isAppliedToGetterOrSetter, Some constrainedTargets, m) | Expr.App (InnerExprPat(ExprValWithPossibleTypeInst(vref, _, _, _)), _, _, args, _) -> let args = args |> List.collect (function Expr.Const (Const.Unit, _, _) -> [] | expr -> tryDestRefTupleExpr expr) |> List.map mkAttribExpr - Attrib(tcref, FSAttrib vref, args, namedAttribArgMap, isAppliedToGetterOrSetter, Some constrainedTgts, mAttr) + Attrib(tcref, FSAttrib vref, args, namedAttribArgMap, isAppliedToGetterOrSetter, Some constrainedTargets, mAttr) | _ -> error (Error(FSComp.SR.tcCustomAttributeMustInvokeConstructor(), mAttr)) @@ -11440,7 +11449,7 @@ and TcAttributeEx canFail (cenv: cenv) (env: TcEnv) attrTgt attrEx (synAttr: Syn | _ -> error(Error(FSComp.SR.tcAttributeExpressionsMustBeConstructorCalls(), mAttr)) - [ (constrainedTgts, attrib) ], false + [ (constrainedTargets, attrib) ], false and TcAttributesWithPossibleTargetsEx canFail (cenv: cenv) env attrTgt attrEx synAttribs = From 049472bc7d4b830fe4f19f068566a6f1cd45998c Mon Sep 17 00:00:00 2001 From: edgargonzalez Date: Fri, 30 May 2025 18:28:56 +0100 Subject: [PATCH 07/18] Better error message for attribute targets --- .../Checking/Expressions/CheckExpressions.fs | 26 ++++++++++++++++++- .../Checking/Expressions/CheckExpressions.fsi | 2 ++ src/Compiler/Driver/CompilerDiagnostics.fs | 7 +++++ src/Compiler/FSComp.txt | 1 - src/Compiler/FSStrings.resx | 3 +++ src/Compiler/xlf/FSComp.txt.cs.xlf | 5 ---- src/Compiler/xlf/FSComp.txt.de.xlf | 5 ---- src/Compiler/xlf/FSComp.txt.es.xlf | 5 ---- src/Compiler/xlf/FSComp.txt.fr.xlf | 5 ---- src/Compiler/xlf/FSComp.txt.it.xlf | 5 ---- src/Compiler/xlf/FSComp.txt.ja.xlf | 5 ---- src/Compiler/xlf/FSComp.txt.ko.xlf | 5 ---- src/Compiler/xlf/FSComp.txt.pl.xlf | 5 ---- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 5 ---- src/Compiler/xlf/FSComp.txt.ru.xlf | 5 ---- src/Compiler/xlf/FSComp.txt.tr.xlf | 5 ---- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 5 ---- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 5 ---- src/Compiler/xlf/FSStrings.cs.xlf | 5 ++++ src/Compiler/xlf/FSStrings.de.xlf | 5 ++++ src/Compiler/xlf/FSStrings.es.xlf | 5 ++++ src/Compiler/xlf/FSStrings.fr.xlf | 5 ++++ src/Compiler/xlf/FSStrings.it.xlf | 5 ++++ src/Compiler/xlf/FSStrings.ja.xlf | 5 ++++ src/Compiler/xlf/FSStrings.ko.xlf | 5 ++++ src/Compiler/xlf/FSStrings.pl.xlf | 5 ++++ src/Compiler/xlf/FSStrings.pt-BR.xlf | 5 ++++ src/Compiler/xlf/FSStrings.ru.xlf | 5 ++++ src/Compiler/xlf/FSStrings.tr.xlf | 5 ++++ src/Compiler/xlf/FSStrings.zh-Hans.xlf | 5 ++++ src/Compiler/xlf/FSStrings.zh-Hant.xlf | 5 ++++ .../AttributeUsage/AttributeUsage.fs | 9 ++++--- 32 files changed, 107 insertions(+), 71 deletions(-) diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index 4ce2fb1700b..0f60a6f4247 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -143,6 +143,8 @@ exception StandardOperatorRedefinitionWarning of string * range exception InvalidInternalsVisibleToAssemblyName of badName: string * fileName: string option +exception InvalidAttributeTargetForLanguageElement of string * string * range + //---------------------------------------------------------------------------------------------- // Helpers for determining if/what specifiers a string has. // Used to decide if interpolated string can be lowered to a concat call. @@ -11353,7 +11355,29 @@ and CheckAttributeUsage (g: TcGlobals) (mAttr: range) (tcref: TyconRef) (attrTgt if (directedTargets = AttributeTargets.Assembly || directedTargets = AttributeTargets.Module) then errorR(Error(FSComp.SR.tcAttributeIsNotValidForLanguageElementUseDo(), mAttr)) else - warning(Error(FSComp.SR.tcAttributeIsNotValidForLanguageElement(), mAttr)) + let attributeTargetsToString (targets: int) = + [| + if targets &&& int AttributeTargets.Assembly <> 0 then "assembly" + if targets &&& int AttributeTargets.Module <> 0 then "module" + if targets &&& int AttributeTargets.Class <> 0 then "class" + if targets &&& int AttributeTargets.Struct <> 0 then "struct" + if targets &&& int AttributeTargets.Enum <> 0 then "enum" + if targets &&& int AttributeTargets.Constructor <> 0 then "constructor" + if targets &&& int AttributeTargets.Method <> 0 then "method" + if targets &&& int AttributeTargets.Property <> 0 then "property" + if targets &&& int AttributeTargets.Field <> 0 then "field" + if targets &&& int AttributeTargets.Event <> 0 then "event" + if targets &&& int AttributeTargets.Interface <> 0 then "interface" + if targets &&& int AttributeTargets.Parameter <> 0 then "parameter" + if targets &&& int AttributeTargets.Delegate <> 0 then "delegate" + if targets &&& int AttributeTargets.ReturnValue <> 0 then "return value" + if targets &&& int AttributeTargets.GenericParameter <> 0 then "type parameter" + |] |> String.concat ", " + + let currentTarget = attributeTargetsToString (int directedTargets) + let validTargets = attributeTargetsToString validOn + + warning(InvalidAttributeTargetForLanguageElement(currentTarget, validTargets, mAttr)) constrainedTargets diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fsi b/src/Compiler/Checking/Expressions/CheckExpressions.fsi index 5992a4afc95..4ac4436d1f0 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fsi +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fsi @@ -121,6 +121,8 @@ exception StandardOperatorRedefinitionWarning of string * range exception InvalidInternalsVisibleToAssemblyName of badName: string * fileName: string option +exception InvalidAttributeTargetForLanguageElement of string * string * range + val TcFieldInit: range -> ILFieldInit -> Const /// Indicates whether a syntactic type is allowed to include new type variables diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index 9fa8bc73f30..14705ebaaa0 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -155,6 +155,7 @@ type Exception with | LibraryUseOnly m | FieldsFromDifferentTypes(_, _, _, m) | IndeterminateType m + | InvalidAttributeTargetForLanguageElement(_, _, m) | TyconBadArgs(_, _, _, m) -> Some m | FieldNotContained(_, _, _, _, _, arf, _, _) -> Some arf.Range @@ -353,6 +354,7 @@ type Exception with | ConstraintSolverNullnessWarningWithTypes _ -> 3261 | ConstraintSolverNullnessWarningWithType _ -> 3261 | ConstraintSolverNullnessWarning _ -> 3261 + | InvalidAttributeTargetForLanguageElement _ -> 842 | _ -> 193 type PhasedDiagnostic with @@ -611,6 +613,8 @@ module OldStyleMessages = let DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferE () = Message("DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer", "%s%s%s%s") + let InvalidAttributeTargetForLanguageElementE () = Message("InvalidAttributeTargetForLanguageElement", "%s%s") + #if DEBUG let mutable showParserStackOnParseError = false #endif @@ -1932,6 +1936,9 @@ type Exception with s2 ) + | InvalidAttributeTargetForLanguageElement(currentTargets, validTargets, _m) -> + os.AppendString(InvalidAttributeTargetForLanguageElementE().Format currentTargets validTargets) + // Strip TargetInvocationException wrappers | :? TargetInvocationException as e when isNotNull e.InnerException -> (!!e.InnerException).Output(os, suggestNames) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 78dde5bd148..f259f06cac0 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -698,7 +698,6 @@ tcUnnamedArgumentsDoNotFormPrefix,"The unnamed arguments do not form a prefix of 839,tcUnexpectedConditionInImportedAssembly,"Unexpected condition in imported assembly: failed to decode AttributeUsage attribute" 840,tcUnrecognizedAttributeTarget,"Unrecognized attribute target. Valid attribute targets are 'assembly', 'module', 'type', 'method', 'property', 'return', 'param', 'field', 'event', 'constructor'." 841,tcAttributeIsNotValidForLanguageElementUseDo,"This attribute is not valid for use on this language element. Assembly attributes should be attached to a 'do ()' declaration, if necessary within an F# module." -842,tcAttributeIsNotValidForLanguageElement,"This attribute is not valid for use on this language element" 843,tcOptionalArgumentsCannotBeUsedInCustomAttribute,"Optional arguments cannot be used in custom attributes" 844,tcPropertyCannotBeSet0,"This property cannot be set" 845,tcPropertyOrFieldNotFoundInAttribute,"This property or field was not found on this custom attribute type" diff --git a/src/Compiler/FSStrings.resx b/src/Compiler/FSStrings.resx index 1b8be22d319..5158fe03c8e 100644 --- a/src/Compiler/FSStrings.resx +++ b/src/Compiler/FSStrings.resx @@ -1146,4 +1146,7 @@ keyword 'while!' + + This attribute cannot be applied to {0}. Valid targets are: {1} + \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index bcd1c3fb0bd..a5b8ccea72c 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -5142,11 +5142,6 @@ Tento atribut není platný pro použití u tohoto elementu jazyka. Atributy sestavení by měly být připojené k deklaraci do (), v případě potřeby v modulu F#. - - This attribute is not valid for use on this language element - Tento atribut není platný pro použití u tohoto elementu jazyka. - - Optional arguments cannot be used in custom attributes Nepovinné argumenty se u vlastních atributů použít nedají. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 0886b9ec60b..1db6227b2c1 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -5142,11 +5142,6 @@ Dieses Attribut ist für dieses Sprachelement nicht gültig. Assemblyattribute sollten an eine "do ()"-Deklaration angefügt werden, falls notwendig innerhalb eines F#-Moduls. - - This attribute is not valid for use on this language element - Dieses Attribut ist für dieses Sprachelement nicht gültig. - - Optional arguments cannot be used in custom attributes Optionale Argumente dürfen nicht für benutzerdefinierte Attribute verwendet werden. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index bdb43c5e1af..af22fc12b97 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -5142,11 +5142,6 @@ Este atributo no es válido para usarlo en este elemento de lenguaje. Los atributos de ensamblado deben asociarse a una declaración 'do ()', si es necesario en un módulo de F#. - - This attribute is not valid for use on this language element - Este atributo no es válido para usarlo en este elemento de lenguaje. - - Optional arguments cannot be used in custom attributes No se pueden usar argumentos opcionales en atributos personalizados. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 5344354b3ab..d8521ad69c7 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -5142,11 +5142,6 @@ L'utilisation de cet attribut n'est pas valide sur cet élément de langage. Les attributs d'assembly doivent être attachés à une déclaration 'do ()', si nécessaire, dans un module F#. - - This attribute is not valid for use on this language element - L'utilisation de cet attribut n'est pas valide sur cet élément de langage - - Optional arguments cannot be used in custom attributes Impossible d'utiliser les arguments facultatifs dans les attributs personnalisés diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index ec472ee00b9..a90c21be7f5 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -5142,11 +5142,6 @@ Attributo non valido per l'utilizzo in questo elemento del linguaggio. Gli attributi degli assembly devono essere collegati a una dichiarazione 'do ()', se necessario all'interno di un modulo F#. - - This attribute is not valid for use on this language element - Attributo non valido per l'utilizzo in questo elemento del linguaggio - - Optional arguments cannot be used in custom attributes Non è possibile usare argomenti facoltativi in attributi personalizzati diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 8db04ab1625..2d73a80d922 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -5142,11 +5142,6 @@ この言語要素では、この属性を使用できません。アセンブリの属性は (必要に応じて F# モジュール内で) 'do ()' 宣言にアタッチする必要があります。 - - This attribute is not valid for use on this language element - この言語要素では、この属性を使用できません - - Optional arguments cannot be used in custom attributes カスタム属性にはオプションの引数を使用できません diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index a17460ee156..40212a33d41 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -5142,11 +5142,6 @@ 이 특성은 이 언어 요소에 사용할 수 없습니다. 어셈블리 특성은 필요한 경우 F# 모듈 내에서 'do ()' 선언에 연결해야 합니다. - - This attribute is not valid for use on this language element - 이 특성은 이 언어 요소에 사용할 수 없습니다. - - Optional arguments cannot be used in custom attributes 선택적 인수는 사용자 지정 특성에 사용할 수 없습니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 94416cfb231..a09db011347 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -5142,11 +5142,6 @@ Ten atrybut jest nieprawidłowy do użycia w tym elemencie języka. Atrybuty zestawu powinny być dołączone do deklaracji „do ()” (w module języka F#, jeśli to konieczne). - - This attribute is not valid for use on this language element - Ten atrybut jest nieprawidłowy do użycia w tym elemencie języka - - Optional arguments cannot be used in custom attributes Argumenty opcjonalne nie mogą być używane w atrybutach niestandardowych diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 99709def4e0..b682506de78 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -5142,11 +5142,6 @@ Este atributo não é válido para ser usado neste elemento de linguagem. Os atributos de assembly devem ser anexados a uma declaração 'do ()' e, se necessário, em um módulo F#. - - This attribute is not valid for use on this language element - Este atributo não é válido para ser usado neste elemento de linguagem - - Optional arguments cannot be used in custom attributes Argumentos opcionais não podem ser usados em atributos personalizados diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index e1e97fdf67e..65a95382c57 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -5142,11 +5142,6 @@ Не допускается использование этого атрибута для этого элемента языка. Атрибуты сборки необходимо присоединять к объявлению "do ()" (при необходимости внутри модуля F#). - - This attribute is not valid for use on this language element - Не допускается использование этого атрибута для этого элемента языка - - Optional arguments cannot be used in custom attributes Необязательные аргументы не могут использоваться в пользовательских атрибутах diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index cff0f89ef17..634e75e9ac5 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -5142,11 +5142,6 @@ Bu öznitelik, bu dil öğesinde kullanılmak için geçerli değil. Bütünleştirilmiş kod öznitelikleri, bir 'do ()' bildirimine, gerekirse F# modülü içine iliştirilmelidir. - - This attribute is not valid for use on this language element - Bu öznitelik, bu dil öğesinde kullanılmak için geçerli değil - - Optional arguments cannot be used in custom attributes İsteğe bağlı bağımsız değişkenler özel özniteliklerde kullanılamaz diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 5ce3ac9c822..29267d81ebd 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -5142,11 +5142,6 @@ 对此语言元素使用此特性无效。如有需要,应将程序集特性附加到 F# 模块中的“do ()”声明。 - - This attribute is not valid for use on this language element - 对此语言元素使用此特性无效 - - Optional arguments cannot be used in custom attributes 自定义特性中不能使用可选参数 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index ae4eeed6b13..e99afe9583d 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -5142,11 +5142,6 @@ 這個屬性不能用在這個語言項目上。組件屬性應該附加到 'do ()' 宣告 (如果 F# 模組中需要的話)。 - - This attribute is not valid for use on this language element - 這個屬性不能用在這個語言項目上 - - Optional arguments cannot be used in custom attributes 選擇性的引數不能用在自訂屬性中 diff --git a/src/Compiler/xlf/FSStrings.cs.xlf b/src/Compiler/xlf/FSStrings.cs.xlf index b7040399218..1d275cdc009 100644 --- a/src/Compiler/xlf/FSStrings.cs.xlf +++ b/src/Compiler/xlf/FSStrings.cs.xlf @@ -57,6 +57,11 @@ Nejméně jedna informační zpráva v načteném souboru\n + + This attribute cannot be applied to {0}. Valid targets are: {1} + This attribute cannot be applied to {0}. Valid targets are: {1} + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Případy sjednocení s malými písmeny jsou povolené jenom při použití atributu RequireQualifiedAccess. diff --git a/src/Compiler/xlf/FSStrings.de.xlf b/src/Compiler/xlf/FSStrings.de.xlf index 83242b1a2ed..4b839f91baa 100644 --- a/src/Compiler/xlf/FSStrings.de.xlf +++ b/src/Compiler/xlf/FSStrings.de.xlf @@ -57,6 +57,11 @@ Mindestens eine Informationsmeldung in der geladenen Datei.\n + + This attribute cannot be applied to {0}. Valid targets are: {1} + This attribute cannot be applied to {0}. Valid targets are: {1} + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Diskriminierte Union-Fälle in Kleinbuchstaben sind nur zulässig, wenn das RequireQualifiedAccess-Attribut verwendet wird. diff --git a/src/Compiler/xlf/FSStrings.es.xlf b/src/Compiler/xlf/FSStrings.es.xlf index b874728926e..b6000d87d81 100644 --- a/src/Compiler/xlf/FSStrings.es.xlf +++ b/src/Compiler/xlf/FSStrings.es.xlf @@ -57,6 +57,11 @@ Uno o más mensajes informativos en el archivo cargado.\n + + This attribute cannot be applied to {0}. Valid targets are: {1} + This attribute cannot be applied to {0}. Valid targets are: {1} + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Los casos de unión discriminada en minúsculas solo se permiten cuando se usa el atributo RequireQualifiedAccess diff --git a/src/Compiler/xlf/FSStrings.fr.xlf b/src/Compiler/xlf/FSStrings.fr.xlf index e6d9ea22b80..cf9b5d2b347 100644 --- a/src/Compiler/xlf/FSStrings.fr.xlf +++ b/src/Compiler/xlf/FSStrings.fr.xlf @@ -57,6 +57,11 @@ Un ou plusieurs messages d’information dans le fichier chargé.\n + + This attribute cannot be applied to {0}. Valid targets are: {1} + This attribute cannot be applied to {0}. Valid targets are: {1} + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Les cas d’union discriminée en minuscules sont uniquement autorisés lors de l’utilisation de l’attribut RequireQualifiedAccess. diff --git a/src/Compiler/xlf/FSStrings.it.xlf b/src/Compiler/xlf/FSStrings.it.xlf index 91edb4c9e53..5f40c023f03 100644 --- a/src/Compiler/xlf/FSStrings.it.xlf +++ b/src/Compiler/xlf/FSStrings.it.xlf @@ -57,6 +57,11 @@ Uno o più messaggi informativi nel file caricato.\n + + This attribute cannot be applied to {0}. Valid targets are: {1} + This attribute cannot be applied to {0}. Valid targets are: {1} + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute I casi di unione discriminati minuscoli sono consentiti solo quando si usa l'attributo RequireQualifiedAccess diff --git a/src/Compiler/xlf/FSStrings.ja.xlf b/src/Compiler/xlf/FSStrings.ja.xlf index af62fb0a030..1c634815c42 100644 --- a/src/Compiler/xlf/FSStrings.ja.xlf +++ b/src/Compiler/xlf/FSStrings.ja.xlf @@ -57,6 +57,11 @@ 読み込まれたファイル内の 1 つ以上の情報メッセージ。\n + + This attribute cannot be applied to {0}. Valid targets are: {1} + This attribute cannot be applied to {0}. Valid targets are: {1} + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute 小文字で区別される和集合のケースは、RequireQualifiedAccess 属性を使用する場合にのみ許可されます diff --git a/src/Compiler/xlf/FSStrings.ko.xlf b/src/Compiler/xlf/FSStrings.ko.xlf index d6eebed9afc..32708160962 100644 --- a/src/Compiler/xlf/FSStrings.ko.xlf +++ b/src/Compiler/xlf/FSStrings.ko.xlf @@ -57,6 +57,11 @@ 로드된 파일에 하나 이상의 정보 메시지가 있습니다.\n + + This attribute cannot be applied to {0}. Valid targets are: {1} + This attribute cannot be applied to {0}. Valid targets are: {1} + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute 소문자로 구분된 공용 구조체 케이스는 RequireQualifiedAccess 특성을 사용하는 경우에만 허용됩니다. diff --git a/src/Compiler/xlf/FSStrings.pl.xlf b/src/Compiler/xlf/FSStrings.pl.xlf index cf4407fa898..f4e0e71d9d1 100644 --- a/src/Compiler/xlf/FSStrings.pl.xlf +++ b/src/Compiler/xlf/FSStrings.pl.xlf @@ -57,6 +57,11 @@ Jeden lub więcej komunikatów informacyjnych w załadowanym pliku.\n + + This attribute cannot be applied to {0}. Valid targets are: {1} + This attribute cannot be applied to {0}. Valid targets are: {1} + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Przypadki unii z dyskryminatorem z małymi literami są dozwolone tylko w przypadku używania atrybutu RequireQualifiedAccess diff --git a/src/Compiler/xlf/FSStrings.pt-BR.xlf b/src/Compiler/xlf/FSStrings.pt-BR.xlf index 80d7ede40c3..3d808961ac1 100644 --- a/src/Compiler/xlf/FSStrings.pt-BR.xlf +++ b/src/Compiler/xlf/FSStrings.pt-BR.xlf @@ -57,6 +57,11 @@ Uma ou mais mensagens informativas no arquivo carregado.\n + + This attribute cannot be applied to {0}. Valid targets are: {1} + This attribute cannot be applied to {0}. Valid targets are: {1} + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Os casos de união discriminados em letras minúsculas só são permitidos ao usar o atributo RequireQualifiedAccess diff --git a/src/Compiler/xlf/FSStrings.ru.xlf b/src/Compiler/xlf/FSStrings.ru.xlf index 28e040426d7..429cafe3ed1 100644 --- a/src/Compiler/xlf/FSStrings.ru.xlf +++ b/src/Compiler/xlf/FSStrings.ru.xlf @@ -57,6 +57,11 @@ Одно или несколько информационных сообщений в загруженном файле.\n + + This attribute cannot be applied to {0}. Valid targets are: {1} + This attribute cannot be applied to {0}. Valid targets are: {1} + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Размеченные в нижнем регистре случаи объединения разрешены только при использовании атрибута RequireQualifiedAccess diff --git a/src/Compiler/xlf/FSStrings.tr.xlf b/src/Compiler/xlf/FSStrings.tr.xlf index 8f81ede3df9..10684127e79 100644 --- a/src/Compiler/xlf/FSStrings.tr.xlf +++ b/src/Compiler/xlf/FSStrings.tr.xlf @@ -57,6 +57,11 @@ Yüklenen dosyada bir veya daha fazla bilgi mesajı.\n + + This attribute cannot be applied to {0}. Valid targets are: {1} + This attribute cannot be applied to {0}. Valid targets are: {1} + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Küçük harf ayrımlı birleşim durumlarına yalnızca RequireQualifiedAccess özniteliği kullanılırken izin verilir diff --git a/src/Compiler/xlf/FSStrings.zh-Hans.xlf b/src/Compiler/xlf/FSStrings.zh-Hans.xlf index 21191e552c3..d9b7a85c36e 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hans.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hans.xlf @@ -57,6 +57,11 @@ 加载文件 .\n 中有一条或多条信息性消息 + + This attribute cannot be applied to {0}. Valid targets are: {1} + This attribute cannot be applied to {0}. Valid targets are: {1} + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute 仅当使用 RequireQualifiedAccess 属性时才允许区分小写的联合事例 diff --git a/src/Compiler/xlf/FSStrings.zh-Hant.xlf b/src/Compiler/xlf/FSStrings.zh-Hant.xlf index 5f834c4e1ff..597dcf45422 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hant.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hant.xlf @@ -57,6 +57,11 @@ 已載入檔案中的一或多個資訊訊息。\n + + This attribute cannot be applied to {0}. Valid targets are: {1} + This attribute cannot be applied to {0}. Valid targets are: {1} + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute 只有在使用 RequireQualifiedAccess 屬性時,才允許小寫區分聯結案例 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs index b0fa891d2b7..6b5991ba7cd 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs @@ -114,10 +114,11 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 21, Col 21, Line 21, Col 22, "This attribute is not valid for use on this language element") - (Warning 842, Line 24, Col 21, Line 24, Col 29, "This attribute is not valid for use on this language element") - (Warning 842, Line 27, Col 7, Line 27, Col 16, "This attribute is not valid for use on this language element") - (Warning 842, Line 18, Col 7, Line 18, Col 8, "This attribute is not valid for use on this language element") + (Warning 842, Line 21, Col 21, Line 21, Col 22, "This attribute cannot be applied to property, field. Valid targets are: method") + (Warning 842, Line 21, Col 21, Line 21, Col 22, "This attribute cannot be applied to field. Valid targets are: method") + (Warning 842, Line 24, Col 21, Line 24, Col 29, "This attribute cannot be applied to field. Valid targets are: method") + (Warning 842, Line 27, Col 7, Line 27, Col 16, "This attribute cannot be applied to method. Valid targets are: method") + (Warning 842, Line 18, Col 7, Line 18, Col 8, "This attribute cannot be applied to property, field, return value. Valid targets are: method") ] // SOURCE=E_AttributeTargets02.fs # E_AttributeTargets02.fs From f643b603079c7749fb474dab68977cc8ac3aa599 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sat, 31 May 2025 07:20:23 +0100 Subject: [PATCH 08/18] Update src/Compiler/Checking/Expressions/CheckExpressions.fs Co-authored-by: Brian Rourke Boll --- src/Compiler/Checking/Expressions/CheckExpressions.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index 0f60a6f4247..7295f20fac3 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -143,7 +143,7 @@ exception StandardOperatorRedefinitionWarning of string * range exception InvalidInternalsVisibleToAssemblyName of badName: string * fileName: string option -exception InvalidAttributeTargetForLanguageElement of string * string * range +exception InvalidAttributeTargetForLanguageElement of actualTarget: string * validTargets: string * range: range //---------------------------------------------------------------------------------------------- // Helpers for determining if/what specifiers a string has. From 61483cee76a84cafa4c82987cb3241ef9f76c95b Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sat, 31 May 2025 08:11:26 +0100 Subject: [PATCH 09/18] use attrTgt instead of directedTargets --- src/Compiler/Checking/Expressions/CheckExpressions.fs | 2 +- src/Compiler/Checking/Expressions/CheckExpressions.fsi | 2 +- src/Compiler/Driver/CompilerDiagnostics.fs | 4 ++-- .../CustomAttributes/AttributeUsage/AttributeUsage.fs | 10 ++++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index 7295f20fac3..cc1f511b0b9 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -11374,7 +11374,7 @@ and CheckAttributeUsage (g: TcGlobals) (mAttr: range) (tcref: TyconRef) (attrTgt if targets &&& int AttributeTargets.GenericParameter <> 0 then "type parameter" |] |> String.concat ", " - let currentTarget = attributeTargetsToString (int directedTargets) + let currentTarget = attributeTargetsToString (int attrTgt) let validTargets = attributeTargetsToString validOn warning(InvalidAttributeTargetForLanguageElement(currentTarget, validTargets, mAttr)) diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fsi b/src/Compiler/Checking/Expressions/CheckExpressions.fsi index 4ac4436d1f0..25f5f85d2d9 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fsi +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fsi @@ -121,7 +121,7 @@ exception StandardOperatorRedefinitionWarning of string * range exception InvalidInternalsVisibleToAssemblyName of badName: string * fileName: string option -exception InvalidAttributeTargetForLanguageElement of string * string * range +exception InvalidAttributeTargetForLanguageElement of actualTarget: string * validTargets: string * range: range val TcFieldInit: range -> ILFieldInit -> Const diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index 14705ebaaa0..bd49b9025cb 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -1936,8 +1936,8 @@ type Exception with s2 ) - | InvalidAttributeTargetForLanguageElement(currentTargets, validTargets, _m) -> - os.AppendString(InvalidAttributeTargetForLanguageElementE().Format currentTargets validTargets) + | InvalidAttributeTargetForLanguageElement(actualTarget, validTargets, _m) -> + os.AppendString(InvalidAttributeTargetForLanguageElementE().Format actualTarget validTargets) // Strip TargetInvocationException wrappers | :? TargetInvocationException as e when isNotNull e.InnerException -> (!!e.InnerException).Output(os, suggestNames) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs index 6b5991ba7cd..70bbef1745d 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs @@ -114,10 +114,12 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 21, Col 21, Line 21, Col 22, "This attribute cannot be applied to property, field. Valid targets are: method") - (Warning 842, Line 21, Col 21, Line 21, Col 22, "This attribute cannot be applied to field. Valid targets are: method") - (Warning 842, Line 24, Col 21, Line 24, Col 29, "This attribute cannot be applied to field. Valid targets are: method") - (Warning 842, Line 27, Col 7, Line 27, Col 16, "This attribute cannot be applied to method. Valid targets are: method") + (Warning 842, Line 21, Col 21, Line 21, Col 22, "This attribute cannot be applied to property, field. Valid targets are: method"); + (Warning 842, Line 21, Col 21, Line 21, Col 22, "This attribute cannot be applied to field. Valid targets are: method"); + (Warning 842, Line 24, Col 21, Line 24, Col 29, "This attribute cannot be applied to property, field. Valid targets are: method"); + (Warning 842, Line 24, Col 21, Line 24, Col 29, "This attribute cannot be applied to field. Valid targets are: method"); + (Warning 842, Line 27, Col 7, Line 27, Col 16, "This attribute cannot be applied to property, event, return value. Valid targets are: method"); + (Warning 842, Line 27, Col 7, Line 27, Col 16, "This attribute cannot be applied to property. Valid targets are: method"); (Warning 842, Line 18, Col 7, Line 18, Col 8, "This attribute cannot be applied to property, field, return value. Valid targets are: method") ] From 81089cee9c34390cd4cd492ae8faa293972acaa0 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sat, 31 May 2025 13:30:09 +0100 Subject: [PATCH 10/18] update attrTgt --- .../Checking/Expressions/CheckExpressions.fs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index cc1f511b0b9..e978e4d2865 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -11372,11 +11372,16 @@ and CheckAttributeUsage (g: TcGlobals) (mAttr: range) (tcref: TyconRef) (attrTgt if targets &&& int AttributeTargets.Delegate <> 0 then "delegate" if targets &&& int AttributeTargets.ReturnValue <> 0 then "return value" if targets &&& int AttributeTargets.GenericParameter <> 0 then "type parameter" - |] |> String.concat ", " + |] + + let currentTargets = attributeTargetsToString (int attrTgt) + + let currentTarget = String.concat ", " currentTargets + let validTargets = + attributeTargetsToString validOn + |> Array.except currentTargets + |> String.concat ", " - let currentTarget = attributeTargetsToString (int attrTgt) - let validTargets = attributeTargetsToString validOn - warning(InvalidAttributeTargetForLanguageElement(currentTarget, validTargets, mAttr)) constrainedTargets From f207e3703ee407db2964fcc37cd75b68707f307d Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sat, 31 May 2025 13:30:17 +0100 Subject: [PATCH 11/18] update tests --- .../AttributeUsage/AttributeUsage.fs | 298 +++++++++--------- 1 file changed, 149 insertions(+), 149 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs index 70bbef1745d..54e5488bd02 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs @@ -130,17 +130,17 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 14, Col 7, Line 14, Col 34, "This attribute is not valid for use on this language element") - (Warning 842, Line 24, Col 7, Line 24, Col 36, "This attribute is not valid for use on this language element") - (Warning 842, Line 29, Col 15, Line 29, Col 47, "This attribute is not valid for use on this language element") + (Warning 842, Line 14, Col 7, Line 14, Col 34, "This attribute cannot be applied to field. Valid targets are: class, struct, enum, constructor, method, property, event, interface, delegate"); + (Warning 842, Line 24, Col 7, Line 24, Col 36, "This attribute cannot be applied to property, event, return value. Valid targets are: class, struct, enum, constructor, method, field, interface, delegate"); + (Warning 842, Line 29, Col 15, Line 29, Col 47, "This attribute cannot be applied to method, event, return value. Valid targets are: class, struct, enum, constructor, property, field, interface, delegate"); (Error 3172, Line 28, Col 14, Line 28, Col 17, "A property's getter and setter must have the same type. Property 'Foo' has getter of type 'int' but setter of type 'obj'.") ] // SOURCE=E_AttributeTargetIsField01.fs # E_AttributeTargetIsField01.fs [] - let ``E_AttributeTargetIsField01_fs 8_0`` compilation = + let ``E_AttributeTargetIsField01_fs 9_0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> withOptions ["--nowarn:25"] |> verifyCompile |> shouldSucceed @@ -154,30 +154,30 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 9, Col 3, Line 9, Col 12, "This attribute is not valid for use on this language element") - (Warning 842, Line 12, Col 3, Line 12, Col 12, "This attribute is not valid for use on this language element") - (Warning 842, Line 15, Col 3, Line 15, Col 12, "This attribute is not valid for use on this language element") - (Warning 842, Line 18, Col 3, Line 18, Col 12, "This attribute is not valid for use on this language element") - (Warning 842, Line 21, Col 3, Line 21, Col 12, "This attribute is not valid for use on this language element") - (Warning 842, Line 24, Col 3, Line 24, Col 12, "This attribute is not valid for use on this language element") - (Warning 842, Line 27, Col 3, Line 27, Col 12, "This attribute is not valid for use on this language element") - (Warning 842, Line 30, Col 3, Line 30, Col 12, "This attribute is not valid for use on this language element") - (Warning 842, Line 33, Col 3, Line 33, Col 12, "This attribute is not valid for use on this language element") - (Warning 842, Line 36, Col 3, Line 36, Col 12, "This attribute is not valid for use on this language element") - (Warning 842, Line 39, Col 3, Line 39, Col 12, "This attribute is not valid for use on this language element") - (Warning 842, Line 42, Col 3, Line 42, Col 12, "This attribute is not valid for use on this language element") - (Warning 842, Line 45, Col 3, Line 45, Col 12, "This attribute is not valid for use on this language element") - (Warning 842, Line 49, Col 3, Line 49, Col 12, "This attribute is not valid for use on this language element") - (Warning 842, Line 56, Col 3, Line 56, Col 12, "This attribute is not valid for use on this language element") - (Warning 842, Line 64, Col 3, Line 64, Col 12, "This attribute is not valid for use on this language element") - (Warning 842, Line 66, Col 7, Line 66, Col 16, "This attribute is not valid for use on this language element") + (Warning 842, Line 9, Col 3, Line 9, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field") + (Warning 842, Line 12, Col 3, Line 12, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field") + (Warning 842, Line 15, Col 3, Line 15, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field") + (Warning 842, Line 18, Col 3, Line 18, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field") + (Warning 842, Line 21, Col 3, Line 21, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field") + (Warning 842, Line 24, Col 3, Line 24, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field") + (Warning 842, Line 27, Col 3, Line 27, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field") + (Warning 842, Line 30, Col 3, Line 30, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field") + (Warning 842, Line 33, Col 3, Line 33, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field") + (Warning 842, Line 36, Col 3, Line 36, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field") + (Warning 842, Line 39, Col 3, Line 39, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field") + (Warning 842, Line 42, Col 3, Line 42, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field") + (Warning 842, Line 45, Col 3, Line 45, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field") + (Warning 842, Line 49, Col 3, Line 49, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field") + (Warning 842, Line 56, Col 3, Line 56, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field") + (Warning 842, Line 64, Col 3, Line 64, Col 12, "This attribute cannot be applied to method, return value. Valid targets are: field") + (Warning 842, Line 66, Col 7, Line 66, Col 16, "This attribute cannot be applied to method, return value. Valid targets are: field") ] // SOURCE=E_AttributeTargetIsField02.fs # E_AttributeTargetIsField02.fs [] - let ``E_AttributeTargetIsField02_fs 8.0`` compilation = + let ``E_AttributeTargetIsField02_fs 9.0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> withOptions ["--nowarn:25"] |> verifyCompile |> shouldSucceed @@ -192,9 +192,9 @@ module CustomAttributes_AttributeUsage = // SOURCE=E_AttributeTargetIsMethod02.fs # E_AttributeTargetIsMethod02.fs [] - let ``E_AttributeTargetIsMethod02_fs 8_0`` compilation = + let ``E_AttributeTargetIsMethod02_fs 9_0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> withOptions ["--nowarn:25"] |> verifyCompile |> shouldSucceed @@ -208,24 +208,24 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 9, Col 3, Line 9, Col 13, "This attribute is not valid for use on this language element") - (Warning 842, Line 12, Col 3, Line 12, Col 13, "This attribute is not valid for use on this language element") - (Warning 842, Line 15, Col 3, Line 15, Col 13, "This attribute is not valid for use on this language element") - (Warning 842, Line 18, Col 3, Line 18, Col 13, "This attribute is not valid for use on this language element") - (Warning 842, Line 21, Col 3, Line 21, Col 13, "This attribute is not valid for use on this language element") - (Warning 842, Line 24, Col 3, Line 24, Col 13, "This attribute is not valid for use on this language element") - (Warning 842, Line 26, Col 7, Line 26, Col 17, "This attribute is not valid for use on this language element") - (Warning 842, Line 28, Col 3, Line 28, Col 13, "This attribute is not valid for use on this language element") - (Warning 842, Line 31, Col 3, Line 31, Col 13, "This attribute is not valid for use on this language element") - (Warning 842, Line 34, Col 3, Line 34, Col 13, "This attribute is not valid for use on this language element") - (Warning 842, Line 39, Col 3, Line 39, Col 13, "This attribute is not valid for use on this language element") + (Warning 842, Line 9, Col 3, Line 9, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 12, Col 3, Line 12, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 15, Col 3, Line 15, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 18, Col 3, Line 18, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 21, Col 3, Line 21, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 24, Col 3, Line 24, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 26, Col 7, Line 26, Col 17, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 28, Col 3, Line 28, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 31, Col 3, Line 31, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 34, Col 3, Line 34, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 39, Col 3, Line 39, Col 13, "This attribute cannot be applied to property, field, return value. Valid targets are: method") ] // SOURCE=E_AttributeTargetIsMethod03.fs # E_AttributeTargetIsMethod03.fs [] - let ``E_AttributeTargetIsMethod03_fs 8_0`` compilation = + let ``E_AttributeTargetIsMethod03_fs 9_0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> withOptions ["--nowarn:25"] |> verifyCompile |> shouldSucceed @@ -239,21 +239,21 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 12, Col 6, Line 12, Col 16, "This attribute is not valid for use on this language element") - (Warning 842, Line 15, Col 6, Line 15, Col 16, "This attribute is not valid for use on this language element") - (Warning 842, Line 18, Col 6, Line 18, Col 16, "This attribute is not valid for use on this language element") - (Warning 842, Line 20, Col 10, Line 20, Col 20, "This attribute is not valid for use on this language element") - (Warning 842, Line 22, Col 6, Line 22, Col 16, "This attribute is not valid for use on this language element") - (Warning 842, Line 25, Col 6, Line 25, Col 16, "This attribute is not valid for use on this language element") - (Warning 842, Line 28, Col 6, Line 28, Col 16, "This attribute is not valid for use on this language element") - (Warning 842, Line 31, Col 6, Line 31, Col 16, "This attribute is not valid for use on this language element") - (Warning 842, Line 34, Col 6, Line 34, Col 16, "This attribute is not valid for use on this language element") - (Warning 842, Line 37, Col 6, Line 37, Col 16, "This attribute is not valid for use on this language element") - (Warning 842, Line 39, Col 10, Line 39, Col 20, "This attribute is not valid for use on this language element") - (Warning 842, Line 41, Col 6, Line 41, Col 16, "This attribute is not valid for use on this language element") - (Warning 842, Line 44, Col 6, Line 44, Col 16, "This attribute is not valid for use on this language element") - (Warning 842, Line 47, Col 6, Line 47, Col 16, "This attribute is not valid for use on this language element") - (Warning 842, Line 52, Col 6, Line 52, Col 16, "This attribute is not valid for use on this language element") + (Warning 842, Line 12, Col 6, Line 12, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 15, Col 6, Line 15, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 18, Col 6, Line 18, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 20, Col 10, Line 20, Col 20, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 22, Col 6, Line 22, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 25, Col 6, Line 25, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 28, Col 6, Line 28, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 31, Col 6, Line 31, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 34, Col 6, Line 34, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 37, Col 6, Line 37, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 39, Col 10, Line 39, Col 20, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 41, Col 6, Line 41, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 44, Col 6, Line 44, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 47, Col 6, Line 47, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method") + (Warning 842, Line 52, Col 6, Line 52, Col 16, "This attribute cannot be applied to property, field, return value. Valid targets are: method") ] // SOURCE=E_AttributeTargetIsMethod04.fs # E_AttributeTargetIsMethod04.fs @@ -264,8 +264,8 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 10, Col 3, Line 10, Col 15, "This attribute is not valid for use on this language element") - (Warning 842, Line 13, Col 3, Line 13, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 10, Col 3, Line 10, Col 15, "This attribute cannot be applied to class, struct, enum, interface, delegate. Valid targets are: method"); + (Warning 842, Line 13, Col 3, Line 13, Col 15, "This attribute cannot be applied to class, struct, enum, interface, delegate. Valid targets are: method") ] // SOURCE=E_ConditionalAttribute.fs SCFLAGS="--test:ErrorRanges" # E_ConditionalAttribute.fs @@ -307,14 +307,14 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 12, Col 3, Line 12, Col 6, "This attribute is not valid for use on this language element") + (Warning 842, Line 12, Col 3, Line 12, Col 6, "This attribute cannot be applied to method, property, field, return value. Valid targets are: assembly, class") ] // SOURCE=AttributeTargetIsStruct.fs # AttributeTargetIsStruct.fs [] - let ``AttributeTargetIsStruct_fs 8.0`` compilation = + let ``AttributeTargetIsStruct_fs 9.0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> verifyCompile |> shouldSucceed @@ -327,9 +327,9 @@ module CustomAttributes_AttributeUsage = // SOURCE=AttributeTargetIsClass.fs # AttributeTargetIsClass.fs [] - let ``AttributeTargetIsClass_fs 8.0`` compilation = + let ``AttributeTargetIsClass_fs 9.0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> verifyCompile |> shouldSucceed @@ -342,9 +342,9 @@ module CustomAttributes_AttributeUsage = // SOURCE=E_AttributeTargetIsStruct.fs # E_AttributeTargetIsStruct.fs [] - let ``E_AttributeTargetIsStruct_fs 8.0`` compilation = + let ``E_AttributeTargetIsStruct_fs 9.0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> verifyCompile |> shouldSucceed @@ -356,25 +356,25 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 13, Col 3, Line 13, Col 14, "This attribute is not valid for use on this language element") - (Warning 842, Line 19, Col 3, Line 19, Col 14, "This attribute is not valid for use on this language element") - (Warning 842, Line 22, Col 11, Line 22, Col 22, "This attribute is not valid for use on this language element") - (Warning 842, Line 25, Col 3, Line 25, Col 14, "This attribute is not valid for use on this language element") - (Warning 842, Line 34, Col 3, Line 34, Col 18, "This attribute is not valid for use on this language element") - (Warning 842, Line 35, Col 3, Line 35, Col 15, "This attribute is not valid for use on this language element") - (Warning 842, Line 40, Col 3, Line 40, Col 14, "This attribute is not valid for use on this language element") - (Warning 842, Line 41, Col 3, Line 41, Col 18, "This attribute is not valid for use on this language element") - (Warning 842, Line 49, Col 3, Line 49, Col 18, "This attribute is not valid for use on this language element") - (Warning 842, Line 50, Col 3, Line 50, Col 15, "This attribute is not valid for use on this language element") - (Warning 842, Line 53, Col 3, Line 53, Col 14, "This attribute is not valid for use on this language element") - (Warning 842, Line 54, Col 3, Line 54, Col 18, "This attribute is not valid for use on this language element") + (Warning 842, Line 13, Col 3, Line 13, Col 14, "This attribute cannot be applied to struct. Valid targets are: class") + (Warning 842, Line 19, Col 3, Line 19, Col 14, "This attribute cannot be applied to struct. Valid targets are: class") + (Warning 842, Line 22, Col 11, Line 22, Col 22, "This attribute cannot be applied to struct. Valid targets are: class") + (Warning 842, Line 25, Col 3, Line 25, Col 14, "This attribute cannot be applied to struct. Valid targets are: class") + (Warning 842, Line 34, Col 3, Line 34, Col 18, "This attribute cannot be applied to class. Valid targets are: interface") + (Warning 842, Line 35, Col 3, Line 35, Col 15, "This attribute cannot be applied to class. Valid targets are: struct") + (Warning 842, Line 40, Col 3, Line 40, Col 14, "This attribute cannot be applied to struct. Valid targets are: class") + (Warning 842, Line 41, Col 3, Line 41, Col 18, "This attribute cannot be applied to struct. Valid targets are: interface") + (Warning 842, Line 49, Col 3, Line 49, Col 18, "This attribute cannot be applied to class. Valid targets are: interface") + (Warning 842, Line 50, Col 3, Line 50, Col 15, "This attribute cannot be applied to class. Valid targets are: struct") + (Warning 842, Line 53, Col 3, Line 53, Col 14, "This attribute cannot be applied to struct. Valid targets are: class") + (Warning 842, Line 54, Col 3, Line 54, Col 18, "This attribute cannot be applied to struct. Valid targets are: interface") ] // SOURCE=E_AttributeTargetIsClass.fs # E_AttributeTargetIsClass.fs [] - let ``E_AttributeTargetIsClass_fs 8_0`` compilation = + let ``E_AttributeTargetIsClass_fs 9_0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> verifyCompile |> shouldSucceed @@ -386,16 +386,16 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 13, Col 3, Line 13, Col 15, "This attribute is not valid for use on this language element") - (Warning 842, Line 19, Col 3, Line 19, Col 15, "This attribute is not valid for use on this language element") - (Warning 842, Line 22, Col 10, Line 22, Col 22, "This attribute is not valid for use on this language element") + (Warning 842, Line 13, Col 3, Line 13, Col 15, "This attribute cannot be applied to class. Valid targets are: struct") + (Warning 842, Line 19, Col 3, Line 19, Col 15, "This attribute cannot be applied to class. Valid targets are: struct") + (Warning 842, Line 22, Col 10, Line 22, Col 22, "This attribute cannot be applied to class. Valid targets are: struct") ] // SOURCE=E_AttributeTargetIsClass01.fs # E_AttributeTargetIsClass01.fs [] - let ``E_AttributeTargetIsClass01_fs 8_0`` compilation = + let ``E_AttributeTargetIsClass01_fs 9_0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> verifyCompile |> shouldSucceed @@ -407,8 +407,8 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 7, Col 3, Line 7, Col 18, "This attribute is not valid for use on this language element") - (Warning 842, Line 10, Col 10, Line 10, Col 25, "This attribute is not valid for use on this language element") + (Warning 842, Line 7, Col 3, Line 7, Col 18, "This attribute cannot be applied to class. Valid targets are: interface"); + (Warning 842, Line 10, Col 10, Line 10, Col 25, "This attribute cannot be applied to class. Valid targets are: interface") ] // SOURCE=MarshalAsAttribute.fs # MarshalAsAttribute.fs @@ -488,13 +488,13 @@ module CustomAttributes_AttributeUsage = // SOURCE=E_AttributeTargetIsField03.fs # E_AttributeTargetIsField03.fs [] - let ``E_AttributeTargetIsField03_fs 8_0`` compilation = + let ``E_AttributeTargetIsField03_fs 9_0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 14, Col 5, Line 14, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 14, Col 5, Line 14, Col 15, "This attribute cannot be applied to method, property. Valid targets are: field") ] // SOURCE=E_AttributeTargetIsField03.fs # E_AttributeTargetIsField03.fs @@ -506,7 +506,7 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 14, Col 5, Line 14, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 14, Col 5, Line 14, Col 15, "This attribute cannot be applied to method, property. Valid targets are: field") ] // SOURCE=E_AttributeTargetIsField03.fs # E_AttributeTargetIsField03.fs @@ -517,7 +517,7 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 14, Col 5, Line 14, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 14, Col 5, Line 14, Col 15, "This attribute cannot be applied to method, property. Valid targets are: field") ] // SOURCE=E_AttributeTargetIsField03.fs # E_AttributeTargetIsField03.fs @@ -529,16 +529,16 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 14, Col 5, Line 14, Col 15, "This attribute is not valid for use on this language element"); - (Warning 3878, Line 14, Col 18, Line 14, Col 23, "This attribute is not valid for use on union cases with fields."); + (Warning 842, Line 14, Col 5, Line 14, Col 15, "This attribute cannot be applied to method, property. Valid targets are: field") + (Warning 3878, Line 14, Col 18, Line 14, Col 23, "This attribute is not valid for use on union cases with fields.") (Warning 3878, Line 15, Col 28, Line 15, Col 33, "This attribute is not valid for use on union cases with fields.") ] // SOURCE=E_AttributeTargetIsProperty01.fs # E_AttributeTargetIsField03.fs [] - let ``E_AttributeTargetIsProperty01_fs 8_0`` compilation = + let ``E_AttributeTargetIsProperty01_fs 9_0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> verifyCompile |> shouldSucceed @@ -552,9 +552,9 @@ module CustomAttributes_AttributeUsage = // SOURCE=E_AttributeTargetIsCtor01.fs # E_AttributeTargetIsCtor01.fs [] - let ``E_AttributeTargetIsCtor01_fs 8_0`` compilation = + let ``E_AttributeTargetIsCtor01_fs 9_0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> verifyCompile |> shouldSucceed @@ -566,17 +566,17 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 9, Col 15, Line 9, Col 27, "This attribute is not valid for use on this language element") - (Warning 842, Line 11, Col 16, Line 11, Col 28, "This attribute is not valid for use on this language element") - (Warning 842, Line 14, Col 15, Line 14, Col 27, "This attribute is not valid for use on this language element") - (Warning 842, Line 17, Col 16, Line 17, Col 28, "This attribute is not valid for use on this language element") + (Warning 842, Line 9, Col 15, Line 9, Col 27, "This attribute cannot be applied to constructor. Valid targets are: method") + (Warning 842, Line 11, Col 16, Line 11, Col 28, "This attribute cannot be applied to constructor. Valid targets are: method") + (Warning 842, Line 14, Col 15, Line 14, Col 27, "This attribute cannot be applied to constructor. Valid targets are: method") + (Warning 842, Line 17, Col 16, Line 17, Col 28, "This attribute cannot be applied to constructor. Valid targets are: method") ] // SOURCE=AttributeTargetsIsEnum01.fs # AttributeTargetsIsEnum01.fs [] - let ``AttributeTargetsIsEnum01_fs 8.0`` compilation = + let ``AttributeTargetsIsEnum01_fs 9.0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> verifyCompile |> shouldSucceed @@ -589,9 +589,9 @@ module CustomAttributes_AttributeUsage = // SOURCE=E_AttributeTargetIsEnum01.fs # E_AttributeTargetIsEnum01.fs [] - let ``E_AttributeTargetIsEnum01_fs 8_0`` compilation = + let ``E_AttributeTargetIsEnum01_fs 9_0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> verifyCompile |> shouldSucceed @@ -603,17 +603,17 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 19, Col 3, Line 19, Col 15, "This attribute is not valid for use on this language element") - (Warning 842, Line 20, Col 3, Line 20, Col 14, "This attribute is not valid for use on this language element") - (Warning 842, Line 21, Col 3, Line 21, Col 18, "This attribute is not valid for use on this language element") - (Warning 842, Line 22, Col 3, Line 22, Col 17, "This attribute is not valid for use on this language element") + (Warning 842, Line 19, Col 3, Line 19, Col 15, "This attribute cannot be applied to enum. Valid targets are: struct") + (Warning 842, Line 20, Col 3, Line 20, Col 14, "This attribute cannot be applied to enum. Valid targets are: class") + (Warning 842, Line 21, Col 3, Line 21, Col 18, "This attribute cannot be applied to enum. Valid targets are: interface") + (Warning 842, Line 22, Col 3, Line 22, Col 17, "This attribute cannot be applied to enum. Valid targets are: delegate") ] // SOURCE=AttributeTargetsIsDelegate01.fs # AttributeTargetsIsDelegate01.fs [] - let ``AttributeTargetsIsDelegate01_fs 8.0`` compilation = + let ``AttributeTargetsIsDelegate01_fs 9.0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> verifyCompile |> shouldSucceed @@ -626,9 +626,9 @@ module CustomAttributes_AttributeUsage = // SOURCE=E_AttributeTargetIsDelegate01.fs # E_AttributeTargetIsDelegate01.fs [] - let ``E_AttributeTargetIsDelegate01_fs 8.0`` compilation = + let ``E_AttributeTargetIsDelegate01_fs 9.0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> verifyCompile |> shouldSucceed @@ -640,10 +640,10 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 19, Col 3, Line 19, Col 14, "This attribute is not valid for use on this language element") - (Warning 842, Line 20, Col 3, Line 20, Col 15, "This attribute is not valid for use on this language element") - (Warning 842, Line 21, Col 3, Line 21, Col 18, "This attribute is not valid for use on this language element") - (Warning 842, Line 22, Col 3, Line 22, Col 13, "This attribute is not valid for use on this language element") + (Warning 842, Line 19, Col 3, Line 19, Col 14, "This attribute cannot be applied to delegate. Valid targets are: class") + (Warning 842, Line 20, Col 3, Line 20, Col 15, "This attribute cannot be applied to delegate. Valid targets are: struct") + (Warning 842, Line 21, Col 3, Line 21, Col 18, "This attribute cannot be applied to delegate. Valid targets are: interface") + (Warning 842, Line 22, Col 3, Line 22, Col 13, "This attribute cannot be applied to delegate. Valid targets are: enum") ] [] @@ -659,9 +659,9 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) = // SOURCE=AttributeTargetsIsInterface.fs # AttributeTargetsIsInterface.fs [] - let ``AttributeTargetsIsInterface_fs 8.0`` compilation = + let ``AttributeTargetsIsInterface_fs 9.0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> verifyCompile |> shouldSucceed @@ -675,9 +675,9 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) = // SOURCE=E_AttributeTargetIsInterface.fs # E_AttributeTargetIsInterface.fs [] - let ``E_AttributeTargetIsInterface_fs 8_0`` compilation = + let ``E_AttributeTargetIsInterface_fs 9_0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> verifyCompile |> shouldSucceed @@ -689,17 +689,17 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 11, Col 3, Line 11, Col 14, "This attribute is not valid for use on this language element") - (Warning 842, Line 14, Col 3, Line 14, Col 15, "This attribute is not valid for use on this language element") - (Warning 842, Line 18, Col 3, Line 18, Col 14, "This attribute is not valid for use on this language element") - (Warning 842, Line 19, Col 3, Line 19, Col 15, "This attribute is not valid for use on this language element") + (Warning 842, Line 11, Col 3, Line 11, Col 14, "This attribute cannot be applied to interface. Valid targets are: class") + (Warning 842, Line 14, Col 3, Line 14, Col 15, "This attribute cannot be applied to interface. Valid targets are: struct") + (Warning 842, Line 18, Col 3, Line 18, Col 14, "This attribute cannot be applied to interface. Valid targets are: class") + (Warning 842, Line 19, Col 3, Line 19, Col 15, "This attribute cannot be applied to interface. Valid targets are: struct") ] // SOURCE= E_AttributeTargetIsClass02.fs # E_AttributeTargetIsClass02.fs [] - let ``E_AttributeTargetIsClass02_fs 8.0`` compilation = + let ``E_AttributeTargetIsClass02_fs 9.0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> verifyCompile |> shouldSucceed @@ -711,18 +711,18 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 15, Col 3, Line 15, Col 18, "This attribute is not valid for use on this language element"); - (Warning 842, Line 16, Col 3, Line 16, Col 15, "This attribute is not valid for use on this language element") - (Warning 842, Line 20, Col 3, Line 20, Col 14, "This attribute is not valid for use on this language element") - (Warning 842, Line 21, Col 3, Line 21, Col 18, "This attribute is not valid for use on this language element") - (Warning 842, Line 26, Col 3, Line 26, Col 14, "This attribute is not valid for use on this language element") - (Warning 842, Line 27, Col 3, Line 27, Col 18, "This attribute is not valid for use on this language element") - (Warning 842, Line 34, Col 3, Line 34, Col 14, "This attribute is not valid for use on this language element") - (Warning 842, Line 35, Col 3, Line 35, Col 18, "This attribute is not valid for use on this language element") - (Warning 842, Line 43, Col 3, Line 43, Col 18, "This attribute is not valid for use on this language element") - (Warning 842, Line 44, Col 3, Line 44, Col 15, "This attribute is not valid for use on this language element") - (Warning 842, Line 47, Col 3, Line 47, Col 14, "This attribute is not valid for use on this language element") - (Warning 842, Line 48, Col 3, Line 48, Col 18, "This attribute is not valid for use on this language element") + (Warning 842, Line 15, Col 3, Line 15, Col 18, "This attribute cannot be applied to class. Valid targets are: interface") + (Warning 842, Line 16, Col 3, Line 16, Col 15, "This attribute cannot be applied to class. Valid targets are: struct") + (Warning 842, Line 20, Col 3, Line 20, Col 14, "This attribute cannot be applied to struct. Valid targets are: class") + (Warning 842, Line 21, Col 3, Line 21, Col 18, "This attribute cannot be applied to struct. Valid targets are: interface") + (Warning 842, Line 26, Col 3, Line 26, Col 14, "This attribute cannot be applied to struct. Valid targets are: class") + (Warning 842, Line 27, Col 3, Line 27, Col 18, "This attribute cannot be applied to struct. Valid targets are: interface") + (Warning 842, Line 34, Col 3, Line 34, Col 14, "This attribute cannot be applied to struct. Valid targets are: class") + (Warning 842, Line 35, Col 3, Line 35, Col 18, "This attribute cannot be applied to struct. Valid targets are: interface") + (Warning 842, Line 43, Col 3, Line 43, Col 18, "This attribute cannot be applied to class. Valid targets are: interface") + (Warning 842, Line 44, Col 3, Line 44, Col 15, "This attribute cannot be applied to class. Valid targets are: struct") + (Warning 842, Line 47, Col 3, Line 47, Col 14, "This attribute cannot be applied to struct. Valid targets are: class") + (Warning 842, Line 48, Col 3, Line 48, Col 18, "This attribute cannot be applied to struct. Valid targets are: interface") ] // SOURCE= CLIMutableAttribute01.fs # CLIMutableAttribute01.fs @@ -779,9 +779,9 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) = // SOURCE= E_AllowNullLiteral.fs # E_AllowNullLiteral.fs [] - let ``E_AllowNullLiteral 8.0`` compilation = + let ``E_AllowNullLiteral 9.0`` compilation = compilation - |> withLangVersion80 + |> withLangVersion90 |> verifyCompile |> shouldFail |> withDiagnostics [ @@ -791,8 +791,8 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) = (Error 934, Line 33, Col 10, Line 33, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute") (Error 934, Line 36, Col 10, Line 36, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute") (Error 934, Line 39, Col 10, Line 39, Col 13, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute") - (Warning 842, Line 41, Col 7, Line 41, Col 23, "This attribute is not valid for use on this language element") - (Warning 842, Line 44, Col 7, Line 44, Col 23, "This attribute is not valid for use on this language element") + (Warning 842, Line 41, Col 7, Line 41, Col 23, "This attribute cannot be applied to method, property, field, return value. Valid targets are: class, interface") + (Warning 842, Line 44, Col 7, Line 44, Col 23, "This attribute cannot be applied to method, property, field, return value. Valid targets are: class, interface") (Error 935, Line 54, Col 10, Line 54, Col 11, "Types with the 'AllowNullLiteral' attribute may only inherit from or implement types which also allow the use of the null literal") ] @@ -804,14 +804,14 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 935, Line 15, Col 10, Line 15, Col 11, "Types with the 'AllowNullLiteral' attribute may only inherit from or implement types which also allow the use of the null literal") - (Error 934, Line 27, Col 10, Line 27, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute") - (Error 934, Line 30, Col 10, Line 30, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute") - (Error 934, Line 33, Col 10, Line 33, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute") - (Error 934, Line 36, Col 10, Line 36, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute") - (Error 934, Line 39, Col 10, Line 39, Col 13, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute") - (Warning 842, Line 41, Col 7, Line 41, Col 23, "This attribute is not valid for use on this language element") - (Warning 842, Line 44, Col 7, Line 44, Col 23, "This attribute is not valid for use on this language element") + (Error 935, Line 15, Col 10, Line 15, Col 11, "Types with the 'AllowNullLiteral' attribute may only inherit from or implement types which also allow the use of the null literal"); + (Error 934, Line 27, Col 10, Line 27, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute"); + (Error 934, Line 30, Col 10, Line 30, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute"); + (Error 934, Line 33, Col 10, Line 33, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute"); + (Error 934, Line 36, Col 10, Line 36, Col 11, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute"); + (Error 934, Line 39, Col 10, Line 39, Col 13, "Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute"); + (Warning 842, Line 41, Col 7, Line 41, Col 23, "This attribute cannot be applied to method, property, field, return value. Valid targets are: class, interface"); + (Warning 842, Line 44, Col 7, Line 44, Col 23, "This attribute cannot be applied to method, property, field, return value. Valid targets are: class, interface"); (Error 935, Line 54, Col 10, Line 54, Col 11, "Types with the 'AllowNullLiteral' attribute may only inherit from or implement types which also allow the use of the null literal") ] From 7b1386ce45f9f14240eae97a93f82ef11f0f87c0 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sat, 31 May 2025 20:41:01 +0100 Subject: [PATCH 12/18] Add InvalidAttributeTargetForLanguageElement2 as fallback --- .../Checking/Expressions/CheckExpressions.fs | 11 +++-------- .../Checking/Expressions/CheckExpressions.fsi | 5 ++++- src/Compiler/Driver/CompilerDiagnostics.fs | 12 +++++++++--- src/Compiler/FSStrings.resx | 5 ++++- src/Compiler/xlf/FSStrings.cs.xlf | 7 ++++++- src/Compiler/xlf/FSStrings.de.xlf | 7 ++++++- src/Compiler/xlf/FSStrings.es.xlf | 7 ++++++- src/Compiler/xlf/FSStrings.fr.xlf | 7 ++++++- src/Compiler/xlf/FSStrings.it.xlf | 7 ++++++- src/Compiler/xlf/FSStrings.ja.xlf | 7 ++++++- src/Compiler/xlf/FSStrings.ko.xlf | 7 ++++++- src/Compiler/xlf/FSStrings.pl.xlf | 7 ++++++- src/Compiler/xlf/FSStrings.pt-BR.xlf | 7 ++++++- src/Compiler/xlf/FSStrings.ru.xlf | 7 ++++++- src/Compiler/xlf/FSStrings.tr.xlf | 7 ++++++- src/Compiler/xlf/FSStrings.zh-Hans.xlf | 7 ++++++- src/Compiler/xlf/FSStrings.zh-Hant.xlf | 7 ++++++- .../CustomAttributes/Basic/Basic.fs | 4 ++-- 18 files changed, 100 insertions(+), 28 deletions(-) diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index e978e4d2865..2a7ca519297 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -143,7 +143,7 @@ exception StandardOperatorRedefinitionWarning of string * range exception InvalidInternalsVisibleToAssemblyName of badName: string * fileName: string option -exception InvalidAttributeTargetForLanguageElement of actualTarget: string * validTargets: string * range: range +exception InvalidAttributeTargetForLanguageElement of actualTarget: string array * validTargets: string array * range: range //---------------------------------------------------------------------------------------------- // Helpers for determining if/what specifiers a string has. @@ -11375,14 +11375,9 @@ and CheckAttributeUsage (g: TcGlobals) (mAttr: range) (tcref: TyconRef) (attrTgt |] let currentTargets = attributeTargetsToString (int attrTgt) + let validTargets = attributeTargetsToString validOn - let currentTarget = String.concat ", " currentTargets - let validTargets = - attributeTargetsToString validOn - |> Array.except currentTargets - |> String.concat ", " - - warning(InvalidAttributeTargetForLanguageElement(currentTarget, validTargets, mAttr)) + warning(InvalidAttributeTargetForLanguageElement(currentTargets, validTargets, mAttr)) constrainedTargets diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fsi b/src/Compiler/Checking/Expressions/CheckExpressions.fsi index 25f5f85d2d9..7725407954b 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fsi +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fsi @@ -121,7 +121,10 @@ exception StandardOperatorRedefinitionWarning of string * range exception InvalidInternalsVisibleToAssemblyName of badName: string * fileName: string option -exception InvalidAttributeTargetForLanguageElement of actualTarget: string * validTargets: string * range: range +exception InvalidAttributeTargetForLanguageElement of + actualTarget: string array * + validTargets: string array * + range: range val TcFieldInit: range -> ILFieldInit -> Const diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index bd49b9025cb..ea44060f0d7 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -613,7 +613,8 @@ module OldStyleMessages = let DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferE () = Message("DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer", "%s%s%s%s") - let InvalidAttributeTargetForLanguageElementE () = Message("InvalidAttributeTargetForLanguageElement", "%s%s") + let InvalidAttributeTargetForLanguageElement1E () = Message("InvalidAttributeTargetForLanguageElement1", "%s%s") + let InvalidAttributeTargetForLanguageElement2E () = Message("InvalidAttributeTargetForLanguageElement2", "") #if DEBUG let mutable showParserStackOnParseError = false @@ -1936,8 +1937,13 @@ type Exception with s2 ) - | InvalidAttributeTargetForLanguageElement(actualTarget, validTargets, _m) -> - os.AppendString(InvalidAttributeTargetForLanguageElementE().Format actualTarget validTargets) + | InvalidAttributeTargetForLanguageElement(currentTargets, validTargets, _m) -> + if Array.isEmpty currentTargets then + os.AppendString(InvalidAttributeTargetForLanguageElement2E().Format) + else + let currentTarget = String.concat ", " currentTargets + let validTargets = validTargets |> Array.except currentTargets |> String.concat ", " + os.AppendString(InvalidAttributeTargetForLanguageElement1E().Format currentTarget validTargets) // Strip TargetInvocationException wrappers | :? TargetInvocationException as e when isNotNull e.InnerException -> (!!e.InnerException).Output(os, suggestNames) diff --git a/src/Compiler/FSStrings.resx b/src/Compiler/FSStrings.resx index 5158fe03c8e..7ba844291c9 100644 --- a/src/Compiler/FSStrings.resx +++ b/src/Compiler/FSStrings.resx @@ -1146,7 +1146,10 @@ keyword 'while!' - + This attribute cannot be applied to {0}. Valid targets are: {1} + + This attribute is not valid for use on this language element + \ No newline at end of file diff --git a/src/Compiler/xlf/FSStrings.cs.xlf b/src/Compiler/xlf/FSStrings.cs.xlf index 1d275cdc009..62c8a4c9b5b 100644 --- a/src/Compiler/xlf/FSStrings.cs.xlf +++ b/src/Compiler/xlf/FSStrings.cs.xlf @@ -57,11 +57,16 @@ Nejméně jedna informační zpráva v načteném souboru\n - + This attribute cannot be applied to {0}. Valid targets are: {1} This attribute cannot be applied to {0}. Valid targets are: {1} + + This attribute is not valid for use on this language element + This attribute is not valid for use on this language element + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Případy sjednocení s malými písmeny jsou povolené jenom při použití atributu RequireQualifiedAccess. diff --git a/src/Compiler/xlf/FSStrings.de.xlf b/src/Compiler/xlf/FSStrings.de.xlf index 4b839f91baa..e2dd2734026 100644 --- a/src/Compiler/xlf/FSStrings.de.xlf +++ b/src/Compiler/xlf/FSStrings.de.xlf @@ -57,11 +57,16 @@ Mindestens eine Informationsmeldung in der geladenen Datei.\n - + This attribute cannot be applied to {0}. Valid targets are: {1} This attribute cannot be applied to {0}. Valid targets are: {1} + + This attribute is not valid for use on this language element + This attribute is not valid for use on this language element + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Diskriminierte Union-Fälle in Kleinbuchstaben sind nur zulässig, wenn das RequireQualifiedAccess-Attribut verwendet wird. diff --git a/src/Compiler/xlf/FSStrings.es.xlf b/src/Compiler/xlf/FSStrings.es.xlf index b6000d87d81..049ca1f4a7d 100644 --- a/src/Compiler/xlf/FSStrings.es.xlf +++ b/src/Compiler/xlf/FSStrings.es.xlf @@ -57,11 +57,16 @@ Uno o más mensajes informativos en el archivo cargado.\n - + This attribute cannot be applied to {0}. Valid targets are: {1} This attribute cannot be applied to {0}. Valid targets are: {1} + + This attribute is not valid for use on this language element + This attribute is not valid for use on this language element + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Los casos de unión discriminada en minúsculas solo se permiten cuando se usa el atributo RequireQualifiedAccess diff --git a/src/Compiler/xlf/FSStrings.fr.xlf b/src/Compiler/xlf/FSStrings.fr.xlf index cf9b5d2b347..976eee5f6e9 100644 --- a/src/Compiler/xlf/FSStrings.fr.xlf +++ b/src/Compiler/xlf/FSStrings.fr.xlf @@ -57,11 +57,16 @@ Un ou plusieurs messages d’information dans le fichier chargé.\n - + This attribute cannot be applied to {0}. Valid targets are: {1} This attribute cannot be applied to {0}. Valid targets are: {1} + + This attribute is not valid for use on this language element + This attribute is not valid for use on this language element + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Les cas d’union discriminée en minuscules sont uniquement autorisés lors de l’utilisation de l’attribut RequireQualifiedAccess. diff --git a/src/Compiler/xlf/FSStrings.it.xlf b/src/Compiler/xlf/FSStrings.it.xlf index 5f40c023f03..db50029a565 100644 --- a/src/Compiler/xlf/FSStrings.it.xlf +++ b/src/Compiler/xlf/FSStrings.it.xlf @@ -57,11 +57,16 @@ Uno o più messaggi informativi nel file caricato.\n - + This attribute cannot be applied to {0}. Valid targets are: {1} This attribute cannot be applied to {0}. Valid targets are: {1} + + This attribute is not valid for use on this language element + This attribute is not valid for use on this language element + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute I casi di unione discriminati minuscoli sono consentiti solo quando si usa l'attributo RequireQualifiedAccess diff --git a/src/Compiler/xlf/FSStrings.ja.xlf b/src/Compiler/xlf/FSStrings.ja.xlf index 1c634815c42..da93c4c5c75 100644 --- a/src/Compiler/xlf/FSStrings.ja.xlf +++ b/src/Compiler/xlf/FSStrings.ja.xlf @@ -57,11 +57,16 @@ 読み込まれたファイル内の 1 つ以上の情報メッセージ。\n - + This attribute cannot be applied to {0}. Valid targets are: {1} This attribute cannot be applied to {0}. Valid targets are: {1} + + This attribute is not valid for use on this language element + This attribute is not valid for use on this language element + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute 小文字で区別される和集合のケースは、RequireQualifiedAccess 属性を使用する場合にのみ許可されます diff --git a/src/Compiler/xlf/FSStrings.ko.xlf b/src/Compiler/xlf/FSStrings.ko.xlf index 32708160962..1e72407d464 100644 --- a/src/Compiler/xlf/FSStrings.ko.xlf +++ b/src/Compiler/xlf/FSStrings.ko.xlf @@ -57,11 +57,16 @@ 로드된 파일에 하나 이상의 정보 메시지가 있습니다.\n - + This attribute cannot be applied to {0}. Valid targets are: {1} This attribute cannot be applied to {0}. Valid targets are: {1} + + This attribute is not valid for use on this language element + This attribute is not valid for use on this language element + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute 소문자로 구분된 공용 구조체 케이스는 RequireQualifiedAccess 특성을 사용하는 경우에만 허용됩니다. diff --git a/src/Compiler/xlf/FSStrings.pl.xlf b/src/Compiler/xlf/FSStrings.pl.xlf index f4e0e71d9d1..145d4d51b92 100644 --- a/src/Compiler/xlf/FSStrings.pl.xlf +++ b/src/Compiler/xlf/FSStrings.pl.xlf @@ -57,11 +57,16 @@ Jeden lub więcej komunikatów informacyjnych w załadowanym pliku.\n - + This attribute cannot be applied to {0}. Valid targets are: {1} This attribute cannot be applied to {0}. Valid targets are: {1} + + This attribute is not valid for use on this language element + This attribute is not valid for use on this language element + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Przypadki unii z dyskryminatorem z małymi literami są dozwolone tylko w przypadku używania atrybutu RequireQualifiedAccess diff --git a/src/Compiler/xlf/FSStrings.pt-BR.xlf b/src/Compiler/xlf/FSStrings.pt-BR.xlf index 3d808961ac1..fe67af23217 100644 --- a/src/Compiler/xlf/FSStrings.pt-BR.xlf +++ b/src/Compiler/xlf/FSStrings.pt-BR.xlf @@ -57,11 +57,16 @@ Uma ou mais mensagens informativas no arquivo carregado.\n - + This attribute cannot be applied to {0}. Valid targets are: {1} This attribute cannot be applied to {0}. Valid targets are: {1} + + This attribute is not valid for use on this language element + This attribute is not valid for use on this language element + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Os casos de união discriminados em letras minúsculas só são permitidos ao usar o atributo RequireQualifiedAccess diff --git a/src/Compiler/xlf/FSStrings.ru.xlf b/src/Compiler/xlf/FSStrings.ru.xlf index 429cafe3ed1..5103380dc19 100644 --- a/src/Compiler/xlf/FSStrings.ru.xlf +++ b/src/Compiler/xlf/FSStrings.ru.xlf @@ -57,11 +57,16 @@ Одно или несколько информационных сообщений в загруженном файле.\n - + This attribute cannot be applied to {0}. Valid targets are: {1} This attribute cannot be applied to {0}. Valid targets are: {1} + + This attribute is not valid for use on this language element + This attribute is not valid for use on this language element + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Размеченные в нижнем регистре случаи объединения разрешены только при использовании атрибута RequireQualifiedAccess diff --git a/src/Compiler/xlf/FSStrings.tr.xlf b/src/Compiler/xlf/FSStrings.tr.xlf index 10684127e79..131cf82949b 100644 --- a/src/Compiler/xlf/FSStrings.tr.xlf +++ b/src/Compiler/xlf/FSStrings.tr.xlf @@ -57,11 +57,16 @@ Yüklenen dosyada bir veya daha fazla bilgi mesajı.\n - + This attribute cannot be applied to {0}. Valid targets are: {1} This attribute cannot be applied to {0}. Valid targets are: {1} + + This attribute is not valid for use on this language element + This attribute is not valid for use on this language element + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Küçük harf ayrımlı birleşim durumlarına yalnızca RequireQualifiedAccess özniteliği kullanılırken izin verilir diff --git a/src/Compiler/xlf/FSStrings.zh-Hans.xlf b/src/Compiler/xlf/FSStrings.zh-Hans.xlf index d9b7a85c36e..2184cffd9e4 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hans.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hans.xlf @@ -57,11 +57,16 @@ 加载文件 .\n 中有一条或多条信息性消息 - + This attribute cannot be applied to {0}. Valid targets are: {1} This attribute cannot be applied to {0}. Valid targets are: {1} + + This attribute is not valid for use on this language element + This attribute is not valid for use on this language element + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute 仅当使用 RequireQualifiedAccess 属性时才允许区分小写的联合事例 diff --git a/src/Compiler/xlf/FSStrings.zh-Hant.xlf b/src/Compiler/xlf/FSStrings.zh-Hant.xlf index 597dcf45422..856901cbc96 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hant.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hant.xlf @@ -57,11 +57,16 @@ 已載入檔案中的一或多個資訊訊息。\n - + This attribute cannot be applied to {0}. Valid targets are: {1} This attribute cannot be applied to {0}. Valid targets are: {1} + + This attribute is not valid for use on this language element + This attribute is not valid for use on this language element + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute 只有在使用 RequireQualifiedAccess 屬性時,才允許小寫區分聯結案例 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 44ee388af9d..b658816a2a0 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/Basic.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/Basic.fs @@ -61,7 +61,7 @@ module CustomAttributes_Basic = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 15, Col 7, Line 15, Col 17, "This attribute is not valid for use on this language element") + (Warning 842, Line 15, Col 7, Line 15, Col 17, "This attribute cannot be applied to property, event, return value. Valid targets are: parameter") ] // SOURCE=E_AttributeApplication04.fs SCFLAGS="--test:ErrorRanges" # E_AttributeApplication04.fs @@ -71,7 +71,7 @@ module CustomAttributes_Basic = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 14, Col 3, Line 14, Col 13, "This attribute is not valid for use on this language element") + (Warning 842, Line 14, Col 3, Line 14, Col 13, "This attribute cannot be applied to class, struct, enum, interface, delegate. Valid targets are: parameter") ] // SOURCE=E_AttributeApplication05.fs SCFLAGS="--test:ErrorRanges" # E_AttributeApplication05.fs From 0c55b19d6e2dd2c43c14def7ddd2ac979d99d014 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sat, 31 May 2025 20:50:21 +0100 Subject: [PATCH 13/18] Update more tests --- .../Conformance/BasicGrammarElements/EntryPoint/EntryPoint.fs | 2 +- .../Conformance/UnitsOfMeasure/WithOOP/WithOOP.fs | 2 +- .../ErrorMessages/TailCallAttribute.fs | 4 ++-- tests/fsharp/Compiler/Language/StructActivePatternTests.fs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/EntryPoint/EntryPoint.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/EntryPoint/EntryPoint.fs index 38b84fb6498..926ea53bc34 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/EntryPoint/EntryPoint.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/EntryPoint/EntryPoint.fs @@ -75,7 +75,7 @@ module EntryPoint = |> compile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 9, Col 3, Line 9, Col 13, """This attribute is not valid for use on this language element""") + (Warning 842, Line 9, Col 3, Line 9, Col 13, "This attribute cannot be applied to class. Valid targets are: method") ] // SOURCE=E_twoattributesonsamefunction001.fs SCFLAGS="--test:ErrorRanges" # E_twoattributesonsamefunction001.fs diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/UnitsOfMeasure/WithOOP/WithOOP.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/UnitsOfMeasure/WithOOP/WithOOP.fs index b915fe62341..26e64de57c6 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/UnitsOfMeasure/WithOOP/WithOOP.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/UnitsOfMeasure/WithOOP/WithOOP.fs @@ -48,7 +48,7 @@ module WithOOP = compilation |> getCompilation |> shouldFailWithDiagnostics [ - (Warning 842, Line 8, Col 36, Line 8, Col 51, "This attribute is not valid for use on this language element") + (Warning 842, Line 8, Col 36, Line 8, Col 51, "This attribute cannot be applied to type parameter. Valid targets are: class, struct, enum, constructor, method, property, field, event, interface, delegate") ] [] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs index 81ce04fc05a..d2559add4f3 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs @@ -1465,7 +1465,7 @@ namespace N |> compile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 6, Col 11, Line 6, Col 19, "This attribute is not valid for use on this language element") + (Warning 842, Line 6, Col 11, Line 6, Col 19, "This attribute cannot be applied to property, field, return value. Valid targets are: method") (Warning 3861, Line 7, Col 13, Line 7, Col 18, "The TailCall attribute should only be applied to recursive functions.") ] @@ -1483,7 +1483,7 @@ namespace N |> withLangVersionPreview |> compile |> shouldFail - |> withSingleDiagnostic (Warning 842, Line 6, Col 11, Line 6, Col 19, "This attribute is not valid for use on this language element") + |> withSingleDiagnostic (Warning 842, Line 6, Col 11, Line 6, Col 19, "This attribute cannot be applied to property, field, return value. Valid targets are: method") [] let ``Warn about self-defined attribute`` () = // is the analysis available for users of older FSharp.Core versions diff --git a/tests/fsharp/Compiler/Language/StructActivePatternTests.fs b/tests/fsharp/Compiler/Language/StructActivePatternTests.fs index 4c2451142fa..ea63a0f99e0 100644 --- a/tests/fsharp/Compiler/Language/StructActivePatternTests.fs +++ b/tests/fsharp/Compiler/Language/StructActivePatternTests.fs @@ -177,7 +177,7 @@ let (|Foo|_|) x = ValueNone let (|Foo|_|) x = ValueNone """ [|(FSharpDiagnosticSeverity.Warning, 842, (2, 3, 2, 9), - "This attribute is not valid for use on this language element"); + "This attribute cannot be applied to method, property, field, return value. Valid targets are: class, struct, parameter"); (FSharpDiagnosticSeverity.Error, 3350, (3, 6, 3, 13), "Feature 'Boolean-returning and return-type-directed partial active patterns' is not available in F# 8.0. Please use language version 9.0 or greater.")|] From a3090812ef5f59194ea0eac87d1a14f3023575d1 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sat, 31 May 2025 22:26:51 +0100 Subject: [PATCH 14/18] release notes --- docs/release-notes/.FSharp.Compiler.Service/10.0.100.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md index a3949c5b823..d132913dd76 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md @@ -5,6 +5,7 @@ * Fix parsing errors using anonymous records and units of measures ([PR #18543](https://github.com/dotnet/fsharp/pull/18543)) * Fix parsing errors using anonymous records and code quotations ([PR #18603](https://github.com/dotnet/fsharp/pull/18603)) +* Better error message for attribute targets. ([PR #18641](https://github.com/dotnet/fsharp/pull/18641)) * Fixed: Allow `return`, `return!`, `yield`, `yield!` type annotations without parentheses ([PR #18533](https://github.com/dotnet/fsharp/pull/18533)) * Range of `SynExprRecordField` should include the expression ([PR #18617](https://github.com/dotnet/fsharp/pull/18617)) * Allow `let!` and `use!` type annotations without requiring parentheses ([PR #18508](https://github.com/dotnet/fsharp/pull/18508)) From 75fed149be5fe5c8b328b1eff57b8980ed61cb92 Mon Sep 17 00:00:00 2001 From: edgargonzalez Date: Mon, 9 Jun 2025 22:09:34 +0100 Subject: [PATCH 15/18] PR feedback --- src/Compiler/Checking/Expressions/CheckExpressions.fs | 8 ++++---- src/Compiler/Checking/Expressions/CheckExpressions.fsi | 4 ++-- src/Compiler/Driver/CompilerDiagnostics.fs | 10 +++++----- .../CustomAttributes/AttributeUsage/AttributeUsage.fs | 8 ++++---- .../ErrorMessages/TailCallAttribute.fs | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index 028cc5a4d43..5862b907e05 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -143,7 +143,7 @@ exception StandardOperatorRedefinitionWarning of string * range exception InvalidInternalsVisibleToAssemblyName of badName: string * fileName: string option -exception InvalidAttributeTargetForLanguageElement of actualTarget: string array * validTargets: string array * range: range +exception InvalidAttributeTargetForLanguageElement of elementTargets: string array * allowedTargets: string array * range: range //---------------------------------------------------------------------------------------------- // Helpers for determining if/what specifiers a string has. @@ -11377,10 +11377,10 @@ and CheckAttributeUsage (g: TcGlobals) (mAttr: range) (tcref: TyconRef) (attrTgt if targets &&& int AttributeTargets.GenericParameter <> 0 then "type parameter" |] - let currentTargets = attributeTargetsToString (int attrTgt) - let validTargets = attributeTargetsToString validOn + let elementTargets = attributeTargetsToString (int attrTgt) + let allowedTargets = attributeTargetsToString validOn - warning(InvalidAttributeTargetForLanguageElement(currentTargets, validTargets, mAttr)) + warning(InvalidAttributeTargetForLanguageElement(elementTargets, allowedTargets, mAttr)) constrainedTargets diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fsi b/src/Compiler/Checking/Expressions/CheckExpressions.fsi index 7725407954b..9e3014896c8 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fsi +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fsi @@ -122,8 +122,8 @@ exception StandardOperatorRedefinitionWarning of string * range exception InvalidInternalsVisibleToAssemblyName of badName: string * fileName: string option exception InvalidAttributeTargetForLanguageElement of - actualTarget: string array * - validTargets: string array * + elementTargets: string array * + allowedTargets: string array * range: range val TcFieldInit: range -> ILFieldInit -> Const diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index 956f5a443a3..da7d3622a51 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -1937,13 +1937,13 @@ type Exception with s2 ) - | InvalidAttributeTargetForLanguageElement(currentTargets, validTargets, _m) -> - if Array.isEmpty currentTargets then + | InvalidAttributeTargetForLanguageElement(elementTargets, allowedTargets, _m) -> + if Array.isEmpty elementTargets then os.AppendString(InvalidAttributeTargetForLanguageElement2E().Format) else - let currentTarget = String.concat ", " currentTargets - let validTargets = validTargets |> Array.except currentTargets |> String.concat ", " - os.AppendString(InvalidAttributeTargetForLanguageElement1E().Format currentTarget validTargets) + let elementTargets = String.concat ", " elementTargets + let allowedTargets = allowedTargets |> String.concat ", " + os.AppendString(InvalidAttributeTargetForLanguageElement1E().Format elementTargets allowedTargets) // Strip TargetInvocationException wrappers | :? TargetInvocationException as e when isNotNull e.InnerException -> (!!e.InnerException).Output(os, suggestNames) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs index 49e00e4b1e3..f8bddafe923 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs @@ -130,10 +130,10 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 14, Col 7, Line 14, Col 34, "This attribute cannot be applied to field. Valid targets are: class, struct, enum, constructor, method, property, event, interface, delegate"); - (Warning 842, Line 24, Col 7, Line 24, Col 36, "This attribute cannot be applied to property, event, return value. Valid targets are: class, struct, enum, constructor, method, field, interface, delegate"); - (Warning 842, Line 29, Col 15, Line 29, Col 47, "This attribute cannot be applied to method, event, return value. Valid targets are: class, struct, enum, constructor, property, field, interface, delegate"); - (Error 3172, Line 28, Col 14, Line 28, Col 17, "A property's getter and setter must have the same type. Property 'Foo' has getter of type 'int' but setter of type 'obj'.") + (Warning 842, Line 14, Col 7, Line 14, Col 34, "This attribute cannot be applied to field. Valid targets are: class, struct, enum, constructor, method, property, field, event, interface, delegate"); + (Warning 842, Line 24, Col 7, Line 24, Col 36, "This attribute cannot be applied to property, event, return value. Valid targets are: class, struct, enum, constructor, method, property, field, event, interface, delegate"); + (Warning 842, Line 29, Col 15, Line 29, Col 47, "This attribute cannot be applied to method, event, return value. Valid targets are: class, struct, enum, constructor, method, property, field, event, interface, delegate"); + (Error 3172, Line 28, Col 14, Line 28, Col 17, "A property's getter and setter must have the same type. Property 'Foo' has getter of type 'int' but setter of type 'obj'.") ] // SOURCE=E_AttributeTargetIsField01.fs # E_AttributeTargetIsField01.fs diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs index d2559add4f3..440ab6b793c 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs @@ -265,8 +265,8 @@ namespace N |> compile |> shouldFail |> withDiagnostics [ - (Warning 3569, Line 10, Col 17, Line 10, Col 26, "The member or function 'M2' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way."); - (Warning 3569, Line 15, Col 17, Line 15, Col 26, "The member or function 'M1' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way.") + (Warning 3569, Line 10, Col 17, Line 10, Col 26, "The member or function 'M2' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way.") + (Warning 3569, Line 15, Col 17, Line 15, Col 26, "The member or function 'M2' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way.") ] [] From e115b57aebd6905d0cf434795f3b6825553169a4 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 19 Jun 2025 22:05:42 +0200 Subject: [PATCH 16/18] update tests --- .../ErrorMessages/TailCallAttribute.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs index 440ab6b793c..ce1c051181f 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs @@ -266,7 +266,7 @@ namespace N |> shouldFail |> withDiagnostics [ (Warning 3569, Line 10, Col 17, Line 10, Col 26, "The member or function 'M2' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way.") - (Warning 3569, Line 15, Col 17, Line 15, Col 26, "The member or function 'M2' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way.") + (Warning 3569, Line 15, Col 17, Line 15, Col 26, "The member or function 'M1' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way.") ] [] From 42496c356c139c266cafb31528135dcd0db8808d Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 19 Jun 2025 22:51:44 +0200 Subject: [PATCH 17/18] update tests --- tests/fsharp/Compiler/Language/StructActivePatternTests.fs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/fsharp/Compiler/Language/StructActivePatternTests.fs b/tests/fsharp/Compiler/Language/StructActivePatternTests.fs index ea63a0f99e0..e1d419c2738 100644 --- a/tests/fsharp/Compiler/Language/StructActivePatternTests.fs +++ b/tests/fsharp/Compiler/Language/StructActivePatternTests.fs @@ -176,9 +176,9 @@ let (|Foo|_|) x = ValueNone [] let (|Foo|_|) x = ValueNone """ - [|(FSharpDiagnosticSeverity.Warning, 842, (2, 3, 2, 9), - "This attribute cannot be applied to method, property, field, return value. Valid targets are: class, struct, parameter"); - (FSharpDiagnosticSeverity.Error, 3350, (3, 6, 3, 13), + [|(FSharpDiagnosticSeverity.Warning, 842, (2, 2, 2, 8), + "This attribute cannot be applied to method, property, field, return value. Valid targets are: class, struct, parameter, return value") + (FSharpDiagnosticSeverity.Error, 3350, (3, 5, 3, 12), "Feature 'Boolean-returning and return-type-directed partial active patterns' is not available in F# 8.0. Please use language version 9.0 or greater.")|] [] From 573461c5716fa1436a82018350200b46e6250279 Mon Sep 17 00:00:00 2001 From: edgargonzalez Date: Wed, 9 Jul 2025 17:56:27 -0500 Subject: [PATCH 18/18] update tests --- .../CustomAttributes/AttributeUsage/AttributeUsage.fs | 5 ++++- .../BasicGrammarElements/CustomAttributes/Basic/Basic.fs | 1 + tests/fsharp/Compiler/Language/StructActivePatternTests.fs | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs index 3947eedd3dd..c2246d10722 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs @@ -259,8 +259,10 @@ module CustomAttributes_AttributeUsage = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Warning 842, Line 10, Col 3, Line 10, Col 15, "This attribute cannot be applied to class, struct, enum, interface, delegate. Valid targets are: method"); + (Warning 842, Line 10, Col 3, Line 10, Col 15, "This attribute cannot be applied to class, struct, enum, interface, delegate. Valid targets are: method") + (Warning 842, Line 10, Col 3, Line 10, Col 15, "This attribute cannot be applied to class. Valid targets are: method") (Warning 842, Line 13, Col 3, Line 13, Col 15, "This attribute cannot be applied to class, struct, enum, interface, delegate. Valid targets are: method") + (Warning 842, Line 13, Col 3, Line 13, Col 15, "This attribute cannot be applied to struct. Valid targets are: method") ] // SOURCE=E_ConditionalAttribute.fs SCFLAGS="--test:ErrorRanges" # E_ConditionalAttribute.fs @@ -303,6 +305,7 @@ module CustomAttributes_AttributeUsage = |> shouldFail |> withDiagnostics [ (Warning 842, Line 12, Col 3, Line 12, Col 6, "This attribute cannot be applied to method, property, field, return value. Valid targets are: assembly, class") + (Warning 842, Line 12, Col 3, Line 12, Col 6, "This attribute cannot be applied to property, field, return value. Valid targets are: assembly, class") ] // SOURCE=AttributeTargetIsStruct.fs # AttributeTargetIsStruct.fs 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 e72f6552aae..2b51fbf11f7 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/Basic.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/Basic.fs @@ -72,6 +72,7 @@ module CustomAttributes_Basic = |> shouldFail |> withDiagnostics [ (Warning 842, Line 14, Col 3, Line 14, Col 13, "This attribute cannot be applied to class, struct, enum, interface, delegate. Valid targets are: parameter") + (Warning 842, Line 14, Col 3, Line 14, Col 13, "This attribute cannot be applied to class. Valid targets are: parameter") ] // SOURCE=E_AttributeApplication05.fs SCFLAGS="--test:ErrorRanges" # E_AttributeApplication05.fs diff --git a/tests/fsharp/Compiler/Language/StructActivePatternTests.fs b/tests/fsharp/Compiler/Language/StructActivePatternTests.fs index e1d419c2738..481d1cedb09 100644 --- a/tests/fsharp/Compiler/Language/StructActivePatternTests.fs +++ b/tests/fsharp/Compiler/Language/StructActivePatternTests.fs @@ -176,9 +176,9 @@ let (|Foo|_|) x = ValueNone [] let (|Foo|_|) x = ValueNone """ - [|(FSharpDiagnosticSeverity.Warning, 842, (2, 2, 2, 8), + [|(FSharpDiagnosticSeverity.Warning, 842, (2, 3, 2, 9), "This attribute cannot be applied to method, property, field, return value. Valid targets are: class, struct, parameter, return value") - (FSharpDiagnosticSeverity.Error, 3350, (3, 5, 3, 12), + (FSharpDiagnosticSeverity.Error, 3350, (3, 6, 3, 13), "Feature 'Boolean-returning and return-type-directed partial active patterns' is not available in F# 8.0. Please use language version 9.0 or greater.")|] []