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 b5b8830ba3d00f22cb8c2f1bec504fe28dc353fa Mon Sep 17 00:00:00 2001 From: edgargonzalez Date: Sat, 9 Aug 2025 15:51:11 +0200 Subject: [PATCH 07/18] Add "," as separator for pattern matching on multiple named discriminated unions fields --- src/Compiler/pars.fsy | 73 ++++++++++- .../data/SyntaxTree/Pattern/Named field 06.fs | 4 + .../SyntaxTree/Pattern/Named field 06.fs.bsl | 25 ++++ .../data/SyntaxTree/Pattern/Named field 07.fs | 5 + .../SyntaxTree/Pattern/Named field 07.fs.bsl | 28 +++++ .../data/SyntaxTree/Pattern/Named field 08.fs | 4 + .../SyntaxTree/Pattern/Named field 08.fs.bsl | 28 +++++ .../data/SyntaxTree/Pattern/Named field 09.fs | 4 + .../SyntaxTree/Pattern/Named field 09.fs.bsl | 24 ++++ .../data/SyntaxTree/Pattern/Named field 10.fs | 4 + .../SyntaxTree/Pattern/Named field 10.fs.bsl | 27 ++++ .../data/SyntaxTree/Pattern/Named field 11.fs | 6 + .../SyntaxTree/Pattern/Named field 11.fs.bsl | 119 ++++++++++++++++++ .../data/SyntaxTree/Pattern/Named field 12.fs | 6 + .../SyntaxTree/Pattern/Named field 12.fs.bsl | 119 ++++++++++++++++++ .../data/SyntaxTree/Pattern/Named field 13.fs | 6 + .../SyntaxTree/Pattern/Named field 13.fs.bsl | 119 ++++++++++++++++++ 17 files changed, 595 insertions(+), 6 deletions(-) create mode 100644 tests/service/data/SyntaxTree/Pattern/Named field 06.fs create mode 100644 tests/service/data/SyntaxTree/Pattern/Named field 06.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Pattern/Named field 07.fs create mode 100644 tests/service/data/SyntaxTree/Pattern/Named field 07.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Pattern/Named field 08.fs create mode 100644 tests/service/data/SyntaxTree/Pattern/Named field 08.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Pattern/Named field 09.fs create mode 100644 tests/service/data/SyntaxTree/Pattern/Named field 09.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Pattern/Named field 10.fs create mode 100644 tests/service/data/SyntaxTree/Pattern/Named field 10.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Pattern/Named field 11.fs create mode 100644 tests/service/data/SyntaxTree/Pattern/Named field 11.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Pattern/Named field 12.fs create mode 100644 tests/service/data/SyntaxTree/Pattern/Named field 12.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Pattern/Named field 13.fs create mode 100644 tests/service/data/SyntaxTree/Pattern/Named field 13.fs.bsl diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 8b0dfa4ae8c..febd28f6127 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -163,6 +163,7 @@ let parse_error_rich = Some(fun (ctxt: ParseErrorContext<_>) -> %type typ typEOF %type tyconSpfnList %type atomicPatsOrNamePatPairs +%type atomicPatsOrNamePatPairsWithCommas %type atomicPatterns %type patternResult %type declExpr @@ -3661,6 +3662,9 @@ namePatPairs: | namePatPair seps namePatPairs { $1 :: $3 } + | namePatPair seps UNDERSCORE + { [$1] } + | namePatPair seps seps namePatPairs { reportParseErrorAt (rhs parseState 3) (FSComp.SR.parsExpectingPattern ()) ($1 :: $4) } @@ -3677,42 +3681,68 @@ namePatPair: | ident recover { $1, None, patFromParseError (SynPat.Wild $1.idRange.EndRange) } +namePatPairsWithCommas: + | namePatPair opt_namePatSepsWithCommas + { [$1] } + + | namePatPair namePatSepsWithCommas UNDERSCORE + { [$1] } + + | namePatPair namePatSepsWithCommas namePatPairsWithCommas + { $1 :: $3 } + + | namePatPair namePatSepsWithCommas namePatSepsWithCommas namePatPairsWithCommas + { reportParseErrorAt (rhs parseState 3) (FSComp.SR.parsExpectingPattern ()) + ($1 :: $4) } + constrPattern: | atomicPatternLongIdent explicitValTyparDecls { let vis, lid = $1 SynPat.LongIdent(lid, None, Some $2, SynArgPats.Pats [], vis, lhs parseState) } - | atomicPatternLongIdent explicitValTyparDecls atomicPatsOrNamePatPairs %prec pat_app + | atomicPatternLongIdent explicitValTyparDecls atomicPatsOrNamePatPairsWithCommas %prec pat_app { let vis, lid = $1 let args, argsM = $3 let m = unionRanges (rhs2 parseState 1 2) argsM SynPat.LongIdent(lid, None, Some $2, args, vis, m) } - | atomicPatternLongIdent explicitValTyparDecls HIGH_PRECEDENCE_PAREN_APP atomicPatsOrNamePatPairs + | atomicPatternLongIdent explicitValTyparDecls HIGH_PRECEDENCE_PAREN_APP atomicPatsOrNamePatPairsWithCommas + { let vis, lid = $1 + let args, argsM = $4 + let m = unionRanges (rhs2 parseState 1 2) argsM + SynPat.LongIdent(lid, None, Some $2, args, vis, m) } + + | atomicPatternLongIdent explicitValTyparDecls HIGH_PRECEDENCE_BRACK_APP atomicPatsOrNamePatPairsWithCommas { let vis, lid = $1 let args, argsM = $4 let m = unionRanges (rhs2 parseState 1 2) argsM SynPat.LongIdent(lid, None, Some $2, args, vis, m) } - | atomicPatternLongIdent explicitValTyparDecls HIGH_PRECEDENCE_BRACK_APP atomicPatsOrNamePatPairs + | atomicPatternLongIdent explicitValTyparDecls HIGH_PRECEDENCE_PAREN_APP atomicPatsOrNamePatPairsWithCommas { let vis, lid = $1 let args, argsM = $4 let m = unionRanges (rhs2 parseState 1 2) argsM SynPat.LongIdent(lid, None, Some $2, args, vis, m) } - | atomicPatternLongIdent atomicPatsOrNamePatPairs %prec pat_app + | atomicPatternLongIdent explicitValTyparDecls HIGH_PRECEDENCE_BRACK_APP atomicPatsOrNamePatPairsWithCommas + { let vis, lid = $1 + let args, argsM = $4 + let m = unionRanges (rhs2 parseState 1 2) argsM + SynPat.LongIdent(lid, None, Some $2, args, vis, m) } + + | atomicPatternLongIdent atomicPatsOrNamePatPairsWithCommas %prec pat_app { let vis, lid = $1 let args, argsM = $2 let m = unionRanges (rhs parseState 1) argsM SynPat.LongIdent(lid, None, None, args, vis, m) } - | atomicPatternLongIdent HIGH_PRECEDENCE_PAREN_APP atomicPatsOrNamePatPairs + | atomicPatternLongIdent HIGH_PRECEDENCE_PAREN_APP atomicPatsOrNamePatPairsWithCommas { let vis, lid = $1 let args, argsM = $3 let m = unionRanges (rhs parseState 1) argsM SynPat.LongIdent(lid, None, None, args, vis, m) } - | atomicPatternLongIdent HIGH_PRECEDENCE_BRACK_APP atomicPatsOrNamePatPairs + | atomicPatternLongIdent HIGH_PRECEDENCE_BRACK_APP atomicPatsOrNamePatPairsWithCommas { let vis, lid = $1 let args, argsM = $3 let m = unionRanges (rhs parseState 1) argsM @@ -3749,6 +3779,24 @@ atomicPatsOrNamePatPairs: let mAll = (mParsed.StartRange, $1) ||> unionRangeWithListBy (fun p -> p.Range) SynArgPats.Pats $1, mAll } +atomicPatsOrNamePatPairsWithCommas: + | LPAREN namePatPairsWithCommas rparen + { let mParen = rhs2 parseState 1 3 + let trivia = { ParenRange = mParen } + SynArgPats.NamePatPairs($2, rhs parseState 2, trivia), mParen } + + | LPAREN namePatPairsWithCommas namePatSepsWithCommas atomicPattern rparen + { let mParen = rhs2 parseState 1 5 + let trivia = { ParenRange = mParen } + let namedPats = $2 + let wildPat = $4 + SynArgPats.NamePatPairs(namedPats, rhs parseState 2, trivia), mParen } + + | atomicPatterns + { let mParsed = rhs parseState 1 + let mAll = (mParsed.StartRange, $1) ||> unionRangeWithListBy (fun p -> p.Range) + SynArgPats.Pats $1, mAll } + atomicPatterns: | atomicPattern atomicPatterns %prec pat_args { $1 :: $2 } @@ -6994,6 +7042,19 @@ seps: | OBLOCKSEP SEMICOLON { Some (rhs parseState 2) } | SEMICOLON OBLOCKSEP { Some (rhs parseState 1) } +namePatSepsWithCommas: + | OBLOCKSEP { None } + | SEMICOLON { Some (rhs parseState 1) } + | COMMA { Some (rhs parseState 1) } + | OBLOCKSEP SEMICOLON { Some (rhs parseState 2) } + | OBLOCKSEP COMMA { Some (rhs parseState 2) } + | SEMICOLON OBLOCKSEP { Some (rhs parseState 1) } + | COMMA OBLOCKSEP { Some (rhs parseState 1) } + +opt_namePatSepsWithCommas: + | namePatSepsWithCommas { } + | /* EMPTY */ { } + /* An 'end' that's optional only in #light, where an ODECLEND gets inserted, and explicit 'end's get converted to OEND */ declEnd: | ODECLEND diff --git a/tests/service/data/SyntaxTree/Pattern/Named field 06.fs b/tests/service/data/SyntaxTree/Pattern/Named field 06.fs new file mode 100644 index 00000000000..58cb8775530 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/Named field 06.fs @@ -0,0 +1,4 @@ +module Module + +match 1 with +| A(a = _, b = _) -> 2 diff --git a/tests/service/data/SyntaxTree/Pattern/Named field 06.fs.bsl b/tests/service/data/SyntaxTree/Pattern/Named field 06.fs.bsl new file mode 100644 index 00000000000..39f1cd8229f --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/Named field 06.fs.bsl @@ -0,0 +1,25 @@ +ImplFile + (ParsedImplFileInput + ("/root/Pattern/Named field 06.fs", false, QualifiedNameOfFile Module, [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Expr + (Match + (Yes (3,0--3,12), Const (Int32 1, (3,6--3,7)), + [SynMatchClause + (LongIdent + (SynLongIdent ([A], [], [None]), None, None, + NamePatPairs + ([(a, Some (4,6--4,7), Wild (4,8--4,9)); + (b, Some (4,13--4,14), Wild (4,15--4,16))], + (4,4--4,17), { ParenRange = (4,3--4,17) }), None, + (4,2--4,17)), None, Const (Int32 2, (4,21--4,22)), + (4,2--4,22), Yes, { ArrowRange = Some (4,18--4,20) + BarRange = Some (4,0--4,1) })], + (3,0--4,22), { MatchKeyword = (3,0--3,5) + WithKeyword = (3,8--3,12) }), (3,0--4,22))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--4,22), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Pattern/Named field 07.fs b/tests/service/data/SyntaxTree/Pattern/Named field 07.fs new file mode 100644 index 00000000000..4c5c22e0efd --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/Named field 07.fs @@ -0,0 +1,5 @@ +module Module + +match 1 with +| A(a = _, b = ) -> 2 + diff --git a/tests/service/data/SyntaxTree/Pattern/Named field 07.fs.bsl b/tests/service/data/SyntaxTree/Pattern/Named field 07.fs.bsl new file mode 100644 index 00000000000..2ce9cc830e9 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/Named field 07.fs.bsl @@ -0,0 +1,28 @@ +ImplFile + (ParsedImplFileInput + ("/root/Pattern/Named field 07.fs", false, QualifiedNameOfFile Module, [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Expr + (Match + (Yes (3,0--3,12), Const (Int32 1, (3,6--3,7)), + [SynMatchClause + (LongIdent + (SynLongIdent ([A], [], [None]), None, None, + NamePatPairs + ([(a, Some (4,6--4,7), Wild (4,8--4,9)); + (b, Some (4,13--4,14), + FromParseError (Wild (4,14--4,14), (4,14--4,14)))], + (4,4--4,16), { ParenRange = (4,3--4,16) }), None, + (4,2--4,16)), None, Const (Int32 2, (4,20--4,21)), + (4,2--4,21), Yes, { ArrowRange = Some (4,17--4,19) + BarRange = Some (4,0--4,1) })], + (3,0--4,21), { MatchKeyword = (3,0--3,5) + WithKeyword = (3,8--3,12) }), (3,0--4,21))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--4,21), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(4,15)-(4,16) parse error Unexpected symbol ')' in pattern diff --git a/tests/service/data/SyntaxTree/Pattern/Named field 08.fs b/tests/service/data/SyntaxTree/Pattern/Named field 08.fs new file mode 100644 index 00000000000..cad1308ead9 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/Named field 08.fs @@ -0,0 +1,4 @@ +module Module + +match 1 with +| A(a = _, b) -> 2 diff --git a/tests/service/data/SyntaxTree/Pattern/Named field 08.fs.bsl b/tests/service/data/SyntaxTree/Pattern/Named field 08.fs.bsl new file mode 100644 index 00000000000..535db9ccc01 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/Named field 08.fs.bsl @@ -0,0 +1,28 @@ +ImplFile + (ParsedImplFileInput + ("/root/Pattern/Named field 08.fs", false, QualifiedNameOfFile Module, [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Expr + (Match + (Yes (3,0--3,12), Const (Int32 1, (3,6--3,7)), + [SynMatchClause + (LongIdent + (SynLongIdent ([A], [], [None]), None, None, + NamePatPairs + ([(a, Some (4,6--4,7), Wild (4,8--4,9)); + (b, None, + FromParseError (Wild (4,12--4,12), (4,12--4,12)))], + (4,4--4,13), { ParenRange = (4,3--4,13) }), None, + (4,2--4,13)), None, Const (Int32 2, (4,17--4,18)), + (4,2--4,18), Yes, { ArrowRange = Some (4,14--4,16) + BarRange = Some (4,0--4,1) })], + (3,0--4,18), { MatchKeyword = (3,0--3,5) + WithKeyword = (3,8--3,12) }), (3,0--4,18))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--4,18), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(4,12)-(4,13) parse error Unexpected symbol ')' in pattern. Expected '=' or other token. diff --git a/tests/service/data/SyntaxTree/Pattern/Named field 09.fs b/tests/service/data/SyntaxTree/Pattern/Named field 09.fs new file mode 100644 index 00000000000..505049e223d --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/Named field 09.fs @@ -0,0 +1,4 @@ +module Module + +match 1 with +| A(a = _,) -> 2 diff --git a/tests/service/data/SyntaxTree/Pattern/Named field 09.fs.bsl b/tests/service/data/SyntaxTree/Pattern/Named field 09.fs.bsl new file mode 100644 index 00000000000..aeb03467c47 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/Named field 09.fs.bsl @@ -0,0 +1,24 @@ +ImplFile + (ParsedImplFileInput + ("/root/Pattern/Named field 09.fs", false, QualifiedNameOfFile Module, [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Expr + (Match + (Yes (3,0--3,12), Const (Int32 1, (3,6--3,7)), + [SynMatchClause + (LongIdent + (SynLongIdent ([A], [], [None]), None, None, + NamePatPairs + ([(a, Some (4,6--4,7), Wild (4,8--4,9))], (4,4--4,10), + { ParenRange = (4,3--4,11) }), None, (4,2--4,11)), + None, Const (Int32 2, (4,15--4,16)), (4,2--4,16), Yes, + { ArrowRange = Some (4,12--4,14) + BarRange = Some (4,0--4,1) })], (3,0--4,16), + { MatchKeyword = (3,0--3,5) + WithKeyword = (3,8--3,12) }), (3,0--4,16))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--4,16), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Pattern/Named field 10.fs b/tests/service/data/SyntaxTree/Pattern/Named field 10.fs new file mode 100644 index 00000000000..55e7893670b --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/Named field 10.fs @@ -0,0 +1,4 @@ +module Module + +match 1 with +| A(a = _, , c = _) -> 2 \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/Pattern/Named field 10.fs.bsl b/tests/service/data/SyntaxTree/Pattern/Named field 10.fs.bsl new file mode 100644 index 00000000000..d3b5409b216 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/Named field 10.fs.bsl @@ -0,0 +1,27 @@ +ImplFile + (ParsedImplFileInput + ("/root/Pattern/Named field 10.fs", false, QualifiedNameOfFile Module, [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Expr + (Match + (Yes (3,0--3,12), Const (Int32 1, (3,6--3,7)), + [SynMatchClause + (LongIdent + (SynLongIdent ([A], [], [None]), None, None, + NamePatPairs + ([(a, Some (4,6--4,7), Wild (4,8--4,9)); + (c, Some (4,15--4,16), Wild (4,17--4,18))], + (4,4--4,19), { ParenRange = (4,3--4,19) }), None, + (4,2--4,19)), None, Const (Int32 2, (4,23--4,24)), + (4,2--4,24), Yes, { ArrowRange = Some (4,20--4,22) + BarRange = Some (4,0--4,1) })], + (3,0--4,24), { MatchKeyword = (3,0--3,5) + WithKeyword = (3,8--3,12) }), (3,0--4,24))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--4,24), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(4,11)-(4,12) parse error Expecting pattern diff --git a/tests/service/data/SyntaxTree/Pattern/Named field 11.fs b/tests/service/data/SyntaxTree/Pattern/Named field 11.fs new file mode 100644 index 00000000000..1fb57e9ba25 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/Named field 11.fs @@ -0,0 +1,6 @@ +module Module + +match shape with +| Rectangle(width = w, length = l) -> w * l +| Circle(radius = r) -> System.Math.PI * r ** 2. +| Prism(width = w, length = l, height = h) -> w * l * h \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/Pattern/Named field 11.fs.bsl b/tests/service/data/SyntaxTree/Pattern/Named field 11.fs.bsl new file mode 100644 index 00000000000..8f54a913f25 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/Named field 11.fs.bsl @@ -0,0 +1,119 @@ +ImplFile + (ParsedImplFileInput + ("/root/Pattern/Named field 11.fs", false, QualifiedNameOfFile Module, [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Expr + (Match + (Yes (3,0--3,16), Ident shape, + [SynMatchClause + (LongIdent + (SynLongIdent ([Rectangle], [], [None]), None, None, + NamePatPairs + ([(width, Some (4,18--4,19), + Named + (SynIdent (w, None), false, None, (4,20--4,21))); + (length, Some (4,30--4,31), + Named + (SynIdent (l, None), false, None, (4,32--4,33)))], + (4,12--4,34), { ParenRange = (4,11--4,34) }), None, + (4,2--4,34)), None, + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Multiply], [], + [Some (OriginalNotation "*")]), None, + (4,40--4,41)), Ident w, (4,38--4,41)), Ident l, + (4,38--4,43)), (4,2--4,43), Yes, + { ArrowRange = Some (4,35--4,37) + BarRange = Some (4,0--4,1) }); + SynMatchClause + (LongIdent + (SynLongIdent ([Circle], [], [None]), None, None, + NamePatPairs + ([(radius, Some (5,16--5,17), + Named + (SynIdent (r, None), false, None, (5,18--5,19)))], + (5,9--5,20), { ParenRange = (5,8--5,20) }), None, + (5,2--5,20)), None, + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Multiply], [], + [Some (OriginalNotation "*")]), None, + (5,39--5,40)), + LongIdent + (false, + SynLongIdent + ([System; Math; PI], + [(5,30--5,31); (5,35--5,36)], + [None; None; None]), None, (5,24--5,38)), + (5,24--5,40)), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Exponentiation], [], + [Some (OriginalNotation "**")]), None, + (5,43--5,45)), Ident r, (5,41--5,45)), + Const (Double 2.0, (5,46--5,48)), (5,41--5,48)), + (5,24--5,48)), (5,2--5,48), Yes, + { ArrowRange = Some (5,21--5,23) + BarRange = Some (5,0--5,1) }); + SynMatchClause + (LongIdent + (SynLongIdent ([Prism], [], [None]), None, None, + NamePatPairs + ([(width, Some (6,14--6,15), + Named + (SynIdent (w, None), false, None, (6,16--6,17))); + (length, Some (6,26--6,27), + Named + (SynIdent (l, None), false, None, (6,28--6,29))); + (height, Some (6,38--6,39), + Named + (SynIdent (h, None), false, None, (6,40--6,41)))], + (6,8--6,42), { ParenRange = (6,7--6,42) }), None, + (6,2--6,42)), None, + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Multiply], [], + [Some (OriginalNotation "*")]), None, + (6,52--6,53)), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Multiply], [], + [Some (OriginalNotation "*")]), None, + (6,48--6,49)), Ident w, (6,46--6,49)), + Ident l, (6,46--6,51)), (6,46--6,53)), Ident h, + (6,46--6,55)), (6,2--6,55), Yes, + { ArrowRange = Some (6,43--6,45) + BarRange = Some (6,0--6,1) })], (3,0--6,55), + { MatchKeyword = (3,0--3,5) + WithKeyword = (3,12--3,16) }), (3,0--6,55))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--6,55), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Pattern/Named field 12.fs b/tests/service/data/SyntaxTree/Pattern/Named field 12.fs new file mode 100644 index 00000000000..46e83e7ca82 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/Named field 12.fs @@ -0,0 +1,6 @@ +module Module + +match shape with +| Rectangle(width = w; length = l) -> w * l +| Circle(radius = r) -> System.Math.PI * r ** 2. +| Prism(width = w; length = l; height = h) -> w * l * h \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/Pattern/Named field 12.fs.bsl b/tests/service/data/SyntaxTree/Pattern/Named field 12.fs.bsl new file mode 100644 index 00000000000..383860c8ae7 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/Named field 12.fs.bsl @@ -0,0 +1,119 @@ +ImplFile + (ParsedImplFileInput + ("/root/Pattern/Named field 12.fs", false, QualifiedNameOfFile Module, [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Expr + (Match + (Yes (3,0--3,16), Ident shape, + [SynMatchClause + (LongIdent + (SynLongIdent ([Rectangle], [], [None]), None, None, + NamePatPairs + ([(width, Some (4,18--4,19), + Named + (SynIdent (w, None), false, None, (4,20--4,21))); + (length, Some (4,30--4,31), + Named + (SynIdent (l, None), false, None, (4,32--4,33)))], + (4,12--4,34), { ParenRange = (4,11--4,34) }), None, + (4,2--4,34)), None, + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Multiply], [], + [Some (OriginalNotation "*")]), None, + (4,40--4,41)), Ident w, (4,38--4,41)), Ident l, + (4,38--4,43)), (4,2--4,43), Yes, + { ArrowRange = Some (4,35--4,37) + BarRange = Some (4,0--4,1) }); + SynMatchClause + (LongIdent + (SynLongIdent ([Circle], [], [None]), None, None, + NamePatPairs + ([(radius, Some (5,16--5,17), + Named + (SynIdent (r, None), false, None, (5,18--5,19)))], + (5,9--5,20), { ParenRange = (5,8--5,20) }), None, + (5,2--5,20)), None, + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Multiply], [], + [Some (OriginalNotation "*")]), None, + (5,39--5,40)), + LongIdent + (false, + SynLongIdent + ([System; Math; PI], + [(5,30--5,31); (5,35--5,36)], + [None; None; None]), None, (5,24--5,38)), + (5,24--5,40)), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Exponentiation], [], + [Some (OriginalNotation "**")]), None, + (5,43--5,45)), Ident r, (5,41--5,45)), + Const (Double 2.0, (5,46--5,48)), (5,41--5,48)), + (5,24--5,48)), (5,2--5,48), Yes, + { ArrowRange = Some (5,21--5,23) + BarRange = Some (5,0--5,1) }); + SynMatchClause + (LongIdent + (SynLongIdent ([Prism], [], [None]), None, None, + NamePatPairs + ([(width, Some (6,14--6,15), + Named + (SynIdent (w, None), false, None, (6,16--6,17))); + (length, Some (6,26--6,27), + Named + (SynIdent (l, None), false, None, (6,28--6,29))); + (height, Some (6,38--6,39), + Named + (SynIdent (h, None), false, None, (6,40--6,41)))], + (6,8--6,42), { ParenRange = (6,7--6,42) }), None, + (6,2--6,42)), None, + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Multiply], [], + [Some (OriginalNotation "*")]), None, + (6,52--6,53)), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Multiply], [], + [Some (OriginalNotation "*")]), None, + (6,48--6,49)), Ident w, (6,46--6,49)), + Ident l, (6,46--6,51)), (6,46--6,53)), Ident h, + (6,46--6,55)), (6,2--6,55), Yes, + { ArrowRange = Some (6,43--6,45) + BarRange = Some (6,0--6,1) })], (3,0--6,55), + { MatchKeyword = (3,0--3,5) + WithKeyword = (3,12--3,16) }), (3,0--6,55))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--6,55), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Pattern/Named field 13.fs b/tests/service/data/SyntaxTree/Pattern/Named field 13.fs new file mode 100644 index 00000000000..83d7be732b0 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/Named field 13.fs @@ -0,0 +1,6 @@ +module Module + +match shape with +| Rectangle(width = w, length = l) -> w * l +| Circle(radius = r) -> System.Math.PI * r ** 2. +| Prism(width = w; length = l, height = h) -> w * l * h \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/Pattern/Named field 13.fs.bsl b/tests/service/data/SyntaxTree/Pattern/Named field 13.fs.bsl new file mode 100644 index 00000000000..c8645371120 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/Named field 13.fs.bsl @@ -0,0 +1,119 @@ +ImplFile + (ParsedImplFileInput + ("/root/Pattern/Named field 13.fs", false, QualifiedNameOfFile Module, [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Expr + (Match + (Yes (3,0--3,16), Ident shape, + [SynMatchClause + (LongIdent + (SynLongIdent ([Rectangle], [], [None]), None, None, + NamePatPairs + ([(width, Some (4,18--4,19), + Named + (SynIdent (w, None), false, None, (4,20--4,21))); + (length, Some (4,30--4,31), + Named + (SynIdent (l, None), false, None, (4,32--4,33)))], + (4,12--4,34), { ParenRange = (4,11--4,34) }), None, + (4,2--4,34)), None, + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Multiply], [], + [Some (OriginalNotation "*")]), None, + (4,40--4,41)), Ident w, (4,38--4,41)), Ident l, + (4,38--4,43)), (4,2--4,43), Yes, + { ArrowRange = Some (4,35--4,37) + BarRange = Some (4,0--4,1) }); + SynMatchClause + (LongIdent + (SynLongIdent ([Circle], [], [None]), None, None, + NamePatPairs + ([(radius, Some (5,16--5,17), + Named + (SynIdent (r, None), false, None, (5,18--5,19)))], + (5,9--5,20), { ParenRange = (5,8--5,20) }), None, + (5,2--5,20)), None, + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Multiply], [], + [Some (OriginalNotation "*")]), None, + (5,39--5,40)), + LongIdent + (false, + SynLongIdent + ([System; Math; PI], + [(5,30--5,31); (5,35--5,36)], + [None; None; None]), None, (5,24--5,38)), + (5,24--5,40)), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Exponentiation], [], + [Some (OriginalNotation "**")]), None, + (5,43--5,45)), Ident r, (5,41--5,45)), + Const (Double 2.0, (5,46--5,48)), (5,41--5,48)), + (5,24--5,48)), (5,2--5,48), Yes, + { ArrowRange = Some (5,21--5,23) + BarRange = Some (5,0--5,1) }); + SynMatchClause + (LongIdent + (SynLongIdent ([Prism], [], [None]), None, None, + NamePatPairs + ([(width, Some (6,14--6,15), + Named + (SynIdent (w, None), false, None, (6,16--6,17))); + (length, Some (6,26--6,27), + Named + (SynIdent (l, None), false, None, (6,28--6,29))); + (height, Some (6,38--6,39), + Named + (SynIdent (h, None), false, None, (6,40--6,41)))], + (6,8--6,42), { ParenRange = (6,7--6,42) }), None, + (6,2--6,42)), None, + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Multiply], [], + [Some (OriginalNotation "*")]), None, + (6,52--6,53)), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Multiply], [], + [Some (OriginalNotation "*")]), None, + (6,48--6,49)), Ident w, (6,46--6,49)), + Ident l, (6,46--6,51)), (6,46--6,53)), Ident h, + (6,46--6,55)), (6,2--6,55), Yes, + { ArrowRange = Some (6,43--6,45) + BarRange = Some (6,0--6,1) })], (3,0--6,55), + { MatchKeyword = (3,0--3,5) + WithKeyword = (3,12--3,16) }), (3,0--6,55))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--6,55), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) From a2ed26af2cf9c74d5f674eb942b4c6594b3825bb Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sun, 10 Aug 2025 23:20:50 +0200 Subject: [PATCH 08/18] fix build --- src/Compiler/Service/ServiceParsedInputOps.fs | 2 +- src/Compiler/Service/SynExpr.fs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Compiler/Service/ServiceParsedInputOps.fs b/src/Compiler/Service/ServiceParsedInputOps.fs index 585d29787fc..decac74226e 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fs +++ b/src/Compiler/Service/ServiceParsedInputOps.fs @@ -1488,7 +1488,7 @@ module ParsedInput = | SyntaxNode.SynExpr(SynExpr.Record(None, _, fields, _)) :: _ -> let isFirstField = match field, fields with - | Some contextLid, SynExprRecordField(fieldName = lid, _) :: _ -> contextLid.Range = lid.Range + | Some contextLid, SynExprRecordField(fieldName = (lid, _)) :: _ -> contextLid.Range = lid.Range | _ -> false RecordContext.New(completionPath, isFirstField) diff --git a/src/Compiler/Service/SynExpr.fs b/src/Compiler/Service/SynExpr.fs index 52c10e8a7a5..e1de5235ca1 100644 --- a/src/Compiler/Service/SynExpr.fs +++ b/src/Compiler/Service/SynExpr.fs @@ -1114,7 +1114,7 @@ module SynExpr = match recordFields with | [] -> false | SynExprRecordField(expr = Some(SynExpr.Paren(expr = Is inner)); blockSeparator = Some _) :: SynExprRecordField( - fieldName = SynLongIdent(id = id :: _), _) :: _ -> problematic inner.Range id.idRange + fieldName = (SynLongIdent(id = id :: _), _)) :: _ -> problematic inner.Range id.idRange | _ :: recordFields -> loop recordFields loop recordFields From 1a9497bdca94940f8bc40301a766e588c33a2f14 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Mon, 11 Aug 2025 00:16:10 +0200 Subject: [PATCH 09/18] Component Tests --- .../NamedPatPairs/NamedPatPairs.fs | 17 +++++++++++++++++ .../NamedPatPairs/NamedPatPairs01.fs | 19 +++++++++++++++++++ .../FSharp.Compiler.ComponentTests.fsproj | 1 + 3 files changed, 37 insertions(+) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs01.fs diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs.fs new file mode 100644 index 00000000000..aaefdc25938 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs.fs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Conformance.PatternMatching + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module NamedPatPairs = + [] + let ``NamedPatPairs - NamedPatPairs01_fs - --test:ErrorRanges`` compilation = + compilation + |> getCompilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs01.fs new file mode 100644 index 00000000000..1710370065f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs01.fs @@ -0,0 +1,19 @@ +// #Conformance #PatternMatching #ActivePatterns +#light + +type Shape = +| Rectangle of width : float * length : float +| Circle of radius : float +| Prism of width : float * float * height : float + +let getShapeWidth shape = + match shape with + | Rectangle(width = w) -> w + | Circle(radius = r) -> 2. * r + | Prism(width = w, height = h) -> w * h + +let result = getShapeWidth (Rectangle(10., 20.)) + +if result <> 10 then exit 1 + +exit 0 \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 9618f9cbcee..74e4738a186 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -111,6 +111,7 @@ + From 8207cba0b0a168ab76af2f3e4de4f9d90a2380a4 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Mon, 11 Aug 2025 00:18:01 +0200 Subject: [PATCH 10/18] Add LanguageFeature --- src/Compiler/FSComp.txt | 1 + src/Compiler/Facilities/LanguageFeatures.fs | 3 +++ src/Compiler/Facilities/LanguageFeatures.fsi | 1 + 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 +++++ 16 files changed, 70 insertions(+) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 1f2dc3cfb3c..2835433d5de 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1614,6 +1614,7 @@ featureWarningWhenMultipleRecdTypeChoice,"Raises warnings when multiple record t featureImprovedImpliedArgumentNames,"Improved implied argument names" featureStrictIndentation,"Raises errors on incorrect indentation, allows better recovery and analysis during editing" featureConstraintIntersectionOnFlexibleTypes,"Constraint intersection on flexible types" +featureCommaInsteadOfSemicolonInPatterns,"Allow comma instead of semicolon in pattern matching field separators" featureChkNotTailRecursive,"Raises warnings if a member or function has the 'TailCall' attribute, but is not being used in a tail recursive way." featureWhileBang,"'while!' expression" featureExtendedFixedBindings,"extended fixed bindings for byref and GetPinnableReference" diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 9e57e5b96af..734db3af413 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -104,6 +104,7 @@ type LanguageFeature = | ScopedNowarn | AllowTypedLetUseAndBang | ReturnFromFinal + | CommaInsteadOfSemicolonInPatterns /// LanguageVersion management type LanguageVersion(versionText) = @@ -243,6 +244,7 @@ type LanguageVersion(versionText) = // F# preview (still preview in 10.0) LanguageFeature.FromEndSlicing, previewVersion // Unfinished features --- needs work + LanguageFeature.CommaInsteadOfSemicolonInPatterns, previewVersion ] static let defaultLanguageVersion = LanguageVersion("default") @@ -412,6 +414,7 @@ type LanguageVersion(versionText) = | LanguageFeature.ScopedNowarn -> FSComp.SR.featureScopedNowarn () | LanguageFeature.AllowTypedLetUseAndBang -> FSComp.SR.featureAllowLetOrUseBangTypeAnnotationWithoutParens () | LanguageFeature.ReturnFromFinal -> FSComp.SR.featureReturnFromFinal () + | LanguageFeature.CommaInsteadOfSemicolonInPatterns -> FSComp.SR.featureCommaInsteadOfSemicolonInPatterns () /// Get a version string associated with the given feature. static member GetFeatureVersionString feature = diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index 2e123eb1593..84cad96669b 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -95,6 +95,7 @@ type LanguageFeature = | ScopedNowarn | AllowTypedLetUseAndBang | ReturnFromFinal + | CommaInsteadOfSemicolonInPatterns /// LanguageVersion management type LanguageVersion = diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 7333400397b..4dfe54606c6 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -342,6 +342,11 @@ Vyvolá upozornění, pokud je atribut TailCall použit u nerekurzivních funkcí. + + Allow comma instead of semicolon in pattern matching field separators + Allow comma instead of semicolon in pattern matching field separators + + Constraint intersection on flexible types Průnik omezení u flexibilních typů diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index ea6271cfbcb..608d9158a16 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -342,6 +342,11 @@ Löst Warnungen aus, wenn das Attribut "TailCall" für nicht rekursive Funktionen verwendet wird. + + Allow comma instead of semicolon in pattern matching field separators + Allow comma instead of semicolon in pattern matching field separators + + Constraint intersection on flexible types Einschränkungsüberschneidung für flexible Typen diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 6abcce332e0..a2d9afcf50f 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -342,6 +342,11 @@ Genera advertencias si el atributo 'TailCall' se usa en funciones no recursivas. + + Allow comma instead of semicolon in pattern matching field separators + Allow comma instead of semicolon in pattern matching field separators + + Constraint intersection on flexible types Intersección de restricciones en tipos flexibles diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 4eb06dccb14..f355f05a225 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -342,6 +342,11 @@ Émet des avertissements si l’attribut « TailCall » est utilisé sur des fonctions non récursives. + + Allow comma instead of semicolon in pattern matching field separators + Allow comma instead of semicolon in pattern matching field separators + + Constraint intersection on flexible types Intersection de contraintes sur les types flexibles diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 4e48e1db287..04964674313 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -342,6 +342,11 @@ Genera avvisi se l'attributo 'TailCall' viene utilizzato in funzioni non ricorsive. + + Allow comma instead of semicolon in pattern matching field separators + Allow comma instead of semicolon in pattern matching field separators + + Constraint intersection on flexible types Intersezione di vincoli su tipi flessibili diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 295256c5cf4..c82f9f632ff 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -342,6 +342,11 @@ 'TailCall' 属性が再帰関数以外で使用されている場合、警告が発せられます。 + + Allow comma instead of semicolon in pattern matching field separators + Allow comma instead of semicolon in pattern matching field separators + + Constraint intersection on flexible types フレキシブル型の制約積集合 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 7ab04d5a12a..881ecf27327 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -342,6 +342,11 @@ 'TailCall' 특성이 비 재귀 함수에 사용되는 경우 경고를 발생합니다. + + Allow comma instead of semicolon in pattern matching field separators + Allow comma instead of semicolon in pattern matching field separators + + Constraint intersection on flexible types 유연한 형식의 제약 조건 교집합 diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index b31f4083071..c04f1ade0c5 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -342,6 +342,11 @@ Zgłasza ostrzeżenia, jeśli atrybut „TailCall” jest używany w funkcjach niekursywnych. + + Allow comma instead of semicolon in pattern matching field separators + Allow comma instead of semicolon in pattern matching field separators + + Constraint intersection on flexible types Przecięcie ograniczenia dla typów elastycznych diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 3e544e2f90c..3dcbc729c5e 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -342,6 +342,11 @@ Gera avisos se o atributo "TailCall" for usado em funções não recursivas. + + Allow comma instead of semicolon in pattern matching field separators + Allow comma instead of semicolon in pattern matching field separators + + Constraint intersection on flexible types Interseção de restrição em tipos flexíveis diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 75f9c8dadc7..041e7132b0c 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -342,6 +342,11 @@ Выдает предупреждения, если атрибут TailCall используется в нерекурсивных функциях. + + Allow comma instead of semicolon in pattern matching field separators + Allow comma instead of semicolon in pattern matching field separators + + Constraint intersection on flexible types Пересечение ограничений на гибких типах diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 66166fd9023..5c45ed04683 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -342,6 +342,11 @@ 'TailCall' özniteliği özyinelemeli olmayan işlevlerde kullanılıyorsa uyarılar oluşturur. + + Allow comma instead of semicolon in pattern matching field separators + Allow comma instead of semicolon in pattern matching field separators + + Constraint intersection on flexible types Esnek türlerde kısıtlama kesişimi diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 50981ab1e98..d3a60c030ec 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -342,6 +342,11 @@ 如果在非递归函数上使用“TailCall”属性,则引发警告。 + + Allow comma instead of semicolon in pattern matching field separators + Allow comma instead of semicolon in pattern matching field separators + + Constraint intersection on flexible types 灵活类型的约束交集 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index aa2c95dbd4b..10be471d75f 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -342,6 +342,11 @@ 如果 'TailCall' 屬性用於非遞迴函數,則引發警告。 + + Allow comma instead of semicolon in pattern matching field separators + Allow comma instead of semicolon in pattern matching field separators + + Constraint intersection on flexible types 彈性類型上的條件約束交集 From db80eafa539230dbf12ee8d5ba1432fe03e2653e Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 13 Aug 2025 22:09:28 +0100 Subject: [PATCH 11/18] Rename LanguageFeature and use it in the parser --- src/Compiler/FSComp.txt | 2 +- src/Compiler/Facilities/LanguageFeatures.fs | 6 +++--- src/Compiler/Facilities/LanguageFeatures.fsi | 2 +- src/Compiler/pars.fsy | 12 +++++++++--- src/Compiler/xlf/FSComp.txt.cs.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.de.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.es.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.fr.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.it.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.ja.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.ko.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.pl.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.ru.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.tr.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 10 +++++----- 17 files changed, 79 insertions(+), 73 deletions(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 2835433d5de..ba2a19d72c6 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1614,7 +1614,7 @@ featureWarningWhenMultipleRecdTypeChoice,"Raises warnings when multiple record t featureImprovedImpliedArgumentNames,"Improved implied argument names" featureStrictIndentation,"Raises errors on incorrect indentation, allows better recovery and analysis during editing" featureConstraintIntersectionOnFlexibleTypes,"Constraint intersection on flexible types" -featureCommaInsteadOfSemicolonInPatterns,"Allow comma instead of semicolon in pattern matching field separators" +featureAllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields,"Allow comma as separator for pattern matching on multiple named discriminated unions fields" featureChkNotTailRecursive,"Raises warnings if a member or function has the 'TailCall' attribute, but is not being used in a tail recursive way." featureWhileBang,"'while!' expression" featureExtendedFixedBindings,"extended fixed bindings for byref and GetPinnableReference" diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 734db3af413..02bdc130cc1 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -104,7 +104,7 @@ type LanguageFeature = | ScopedNowarn | AllowTypedLetUseAndBang | ReturnFromFinal - | CommaInsteadOfSemicolonInPatterns + | AllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields /// LanguageVersion management type LanguageVersion(versionText) = @@ -244,7 +244,7 @@ type LanguageVersion(versionText) = // F# preview (still preview in 10.0) LanguageFeature.FromEndSlicing, previewVersion // Unfinished features --- needs work - LanguageFeature.CommaInsteadOfSemicolonInPatterns, previewVersion + LanguageFeature.AllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields, previewVersion ] static let defaultLanguageVersion = LanguageVersion("default") @@ -414,7 +414,7 @@ type LanguageVersion(versionText) = | LanguageFeature.ScopedNowarn -> FSComp.SR.featureScopedNowarn () | LanguageFeature.AllowTypedLetUseAndBang -> FSComp.SR.featureAllowLetOrUseBangTypeAnnotationWithoutParens () | LanguageFeature.ReturnFromFinal -> FSComp.SR.featureReturnFromFinal () - | LanguageFeature.CommaInsteadOfSemicolonInPatterns -> FSComp.SR.featureCommaInsteadOfSemicolonInPatterns () + | LanguageFeature.AllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields -> FSComp.SR.featureAllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields () /// Get a version string associated with the given feature. static member GetFeatureVersionString feature = diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index 84cad96669b..7c9c0af243d 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -95,7 +95,7 @@ type LanguageFeature = | ScopedNowarn | AllowTypedLetUseAndBang | ReturnFromFinal - | CommaInsteadOfSemicolonInPatterns + | AllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields /// LanguageVersion management type LanguageVersion = diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 95bca996b7c..d5fff52679f 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -7038,11 +7038,17 @@ seps: namePatSepsWithCommas: | OBLOCKSEP { None } | SEMICOLON { Some (rhs parseState 1) } - | COMMA { Some (rhs parseState 1) } + | COMMA + { parseState.LexBuffer.CheckLanguageFeatureAndRecover LanguageFeature.AllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields (rhs parseState 1) + Some (rhs parseState 1) } | OBLOCKSEP SEMICOLON { Some (rhs parseState 2) } - | OBLOCKSEP COMMA { Some (rhs parseState 2) } + | OBLOCKSEP COMMA + { parseState.LexBuffer.CheckLanguageFeatureAndRecover LanguageFeature.AllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields (rhs parseState 2) + Some (rhs parseState 2) } | SEMICOLON OBLOCKSEP { Some (rhs parseState 1) } - | COMMA OBLOCKSEP { Some (rhs parseState 1) } + | COMMA OBLOCKSEP + { parseState.LexBuffer.CheckLanguageFeatureAndRecover LanguageFeature.AllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields (rhs parseState 1) + Some (rhs parseState 1) } opt_namePatSepsWithCommas: | namePatSepsWithCommas { } diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 4dfe54606c6..f08720fae06 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -287,6 +287,11 @@ Allow access modifiers to auto properties getters and setters + + Allow comma as separator for pattern matching on multiple named discriminated unions fields + Allow comma as separator for pattern matching on multiple named discriminated unions fields + + Allow let! and use! type annotations without requiring parentheses Allow let! and use! type annotations without requiring parentheses @@ -342,11 +347,6 @@ Vyvolá upozornění, pokud je atribut TailCall použit u nerekurzivních funkcí. - - Allow comma instead of semicolon in pattern matching field separators - Allow comma instead of semicolon in pattern matching field separators - - Constraint intersection on flexible types Průnik omezení u flexibilních typů diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 608d9158a16..8edbb31f222 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -287,6 +287,11 @@ Allow access modifiers to auto properties getters and setters + + Allow comma as separator for pattern matching on multiple named discriminated unions fields + Allow comma as separator for pattern matching on multiple named discriminated unions fields + + Allow let! and use! type annotations without requiring parentheses Allow let! and use! type annotations without requiring parentheses @@ -342,11 +347,6 @@ Löst Warnungen aus, wenn das Attribut "TailCall" für nicht rekursive Funktionen verwendet wird. - - Allow comma instead of semicolon in pattern matching field separators - Allow comma instead of semicolon in pattern matching field separators - - Constraint intersection on flexible types Einschränkungsüberschneidung für flexible Typen diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index a2d9afcf50f..db224b293f3 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -287,6 +287,11 @@ Allow access modifiers to auto properties getters and setters + + Allow comma as separator for pattern matching on multiple named discriminated unions fields + Allow comma as separator for pattern matching on multiple named discriminated unions fields + + Allow let! and use! type annotations without requiring parentheses Allow let! and use! type annotations without requiring parentheses @@ -342,11 +347,6 @@ Genera advertencias si el atributo 'TailCall' se usa en funciones no recursivas. - - Allow comma instead of semicolon in pattern matching field separators - Allow comma instead of semicolon in pattern matching field separators - - Constraint intersection on flexible types Intersección de restricciones en tipos flexibles diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index f355f05a225..93528f86cbd 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -287,6 +287,11 @@ Allow access modifiers to auto properties getters and setters + + Allow comma as separator for pattern matching on multiple named discriminated unions fields + Allow comma as separator for pattern matching on multiple named discriminated unions fields + + Allow let! and use! type annotations without requiring parentheses Allow let! and use! type annotations without requiring parentheses @@ -342,11 +347,6 @@ Émet des avertissements si l’attribut « TailCall » est utilisé sur des fonctions non récursives. - - Allow comma instead of semicolon in pattern matching field separators - Allow comma instead of semicolon in pattern matching field separators - - Constraint intersection on flexible types Intersection de contraintes sur les types flexibles diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 04964674313..1e2b92437dd 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -287,6 +287,11 @@ Allow access modifiers to auto properties getters and setters + + Allow comma as separator for pattern matching on multiple named discriminated unions fields + Allow comma as separator for pattern matching on multiple named discriminated unions fields + + Allow let! and use! type annotations without requiring parentheses Allow let! and use! type annotations without requiring parentheses @@ -342,11 +347,6 @@ Genera avvisi se l'attributo 'TailCall' viene utilizzato in funzioni non ricorsive. - - Allow comma instead of semicolon in pattern matching field separators - Allow comma instead of semicolon in pattern matching field separators - - Constraint intersection on flexible types Intersezione di vincoli su tipi flessibili diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index c82f9f632ff..2b0d69b3763 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -287,6 +287,11 @@ Allow access modifiers to auto properties getters and setters + + Allow comma as separator for pattern matching on multiple named discriminated unions fields + Allow comma as separator for pattern matching on multiple named discriminated unions fields + + Allow let! and use! type annotations without requiring parentheses Allow let! and use! type annotations without requiring parentheses @@ -342,11 +347,6 @@ 'TailCall' 属性が再帰関数以外で使用されている場合、警告が発せられます。 - - Allow comma instead of semicolon in pattern matching field separators - Allow comma instead of semicolon in pattern matching field separators - - Constraint intersection on flexible types フレキシブル型の制約積集合 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 881ecf27327..ba55f9cd12a 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -287,6 +287,11 @@ Allow access modifiers to auto properties getters and setters + + Allow comma as separator for pattern matching on multiple named discriminated unions fields + Allow comma as separator for pattern matching on multiple named discriminated unions fields + + Allow let! and use! type annotations without requiring parentheses Allow let! and use! type annotations without requiring parentheses @@ -342,11 +347,6 @@ 'TailCall' 특성이 비 재귀 함수에 사용되는 경우 경고를 발생합니다. - - Allow comma instead of semicolon in pattern matching field separators - Allow comma instead of semicolon in pattern matching field separators - - Constraint intersection on flexible types 유연한 형식의 제약 조건 교집합 diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index c04f1ade0c5..184988d775d 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -287,6 +287,11 @@ Allow access modifiers to auto properties getters and setters + + Allow comma as separator for pattern matching on multiple named discriminated unions fields + Allow comma as separator for pattern matching on multiple named discriminated unions fields + + Allow let! and use! type annotations without requiring parentheses Allow let! and use! type annotations without requiring parentheses @@ -342,11 +347,6 @@ Zgłasza ostrzeżenia, jeśli atrybut „TailCall” jest używany w funkcjach niekursywnych. - - Allow comma instead of semicolon in pattern matching field separators - Allow comma instead of semicolon in pattern matching field separators - - Constraint intersection on flexible types Przecięcie ograniczenia dla typów elastycznych diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 3dcbc729c5e..0ec640c107e 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -287,6 +287,11 @@ Allow access modifiers to auto properties getters and setters + + Allow comma as separator for pattern matching on multiple named discriminated unions fields + Allow comma as separator for pattern matching on multiple named discriminated unions fields + + Allow let! and use! type annotations without requiring parentheses Allow let! and use! type annotations without requiring parentheses @@ -342,11 +347,6 @@ Gera avisos se o atributo "TailCall" for usado em funções não recursivas. - - Allow comma instead of semicolon in pattern matching field separators - Allow comma instead of semicolon in pattern matching field separators - - Constraint intersection on flexible types Interseção de restrição em tipos flexíveis diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 041e7132b0c..5b052103fb6 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -287,6 +287,11 @@ Allow access modifiers to auto properties getters and setters + + Allow comma as separator for pattern matching on multiple named discriminated unions fields + Allow comma as separator for pattern matching on multiple named discriminated unions fields + + Allow let! and use! type annotations without requiring parentheses Allow let! and use! type annotations without requiring parentheses @@ -342,11 +347,6 @@ Выдает предупреждения, если атрибут TailCall используется в нерекурсивных функциях. - - Allow comma instead of semicolon in pattern matching field separators - Allow comma instead of semicolon in pattern matching field separators - - Constraint intersection on flexible types Пересечение ограничений на гибких типах diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 5c45ed04683..bd2d5873955 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -287,6 +287,11 @@ Allow access modifiers to auto properties getters and setters + + Allow comma as separator for pattern matching on multiple named discriminated unions fields + Allow comma as separator for pattern matching on multiple named discriminated unions fields + + Allow let! and use! type annotations without requiring parentheses Allow let! and use! type annotations without requiring parentheses @@ -342,11 +347,6 @@ 'TailCall' özniteliği özyinelemeli olmayan işlevlerde kullanılıyorsa uyarılar oluşturur. - - Allow comma instead of semicolon in pattern matching field separators - Allow comma instead of semicolon in pattern matching field separators - - Constraint intersection on flexible types Esnek türlerde kısıtlama kesişimi diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index d3a60c030ec..3729b1282a5 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -287,6 +287,11 @@ Allow access modifiers to auto properties getters and setters + + Allow comma as separator for pattern matching on multiple named discriminated unions fields + Allow comma as separator for pattern matching on multiple named discriminated unions fields + + Allow let! and use! type annotations without requiring parentheses Allow let! and use! type annotations without requiring parentheses @@ -342,11 +347,6 @@ 如果在非递归函数上使用“TailCall”属性,则引发警告。 - - Allow comma instead of semicolon in pattern matching field separators - Allow comma instead of semicolon in pattern matching field separators - - Constraint intersection on flexible types 灵活类型的约束交集 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 10be471d75f..aaa7f3b7b1c 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -287,6 +287,11 @@ Allow access modifiers to auto properties getters and setters + + Allow comma as separator for pattern matching on multiple named discriminated unions fields + Allow comma as separator for pattern matching on multiple named discriminated unions fields + + Allow let! and use! type annotations without requiring parentheses Allow let! and use! type annotations without requiring parentheses @@ -342,11 +347,6 @@ 如果 'TailCall' 屬性用於非遞迴函數,則引發警告。 - - Allow comma instead of semicolon in pattern matching field separators - Allow comma instead of semicolon in pattern matching field separators - - Constraint intersection on flexible types 彈性類型上的條件約束交集 From 62615175af4f374457a3e0088b17ea6c5373fd02 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 13 Aug 2025 22:25:06 +0100 Subject: [PATCH 12/18] update tests --- .../NamedPatPairs/NamedPatPairs.fs | 28 +++++++++++---- .../NamedPatPairs/NamedPatPairs01.fs | 34 ++++++++++--------- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs.fs index aaefdc25938..9d37b6f5278 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs.fs @@ -7,11 +7,27 @@ open FSharp.Test open FSharp.Test.Compiler module NamedPatPairs = - [] - let ``NamedPatPairs - NamedPatPairs01_fs - --test:ErrorRanges`` compilation = + [] + let ``Preview: NamedPatPairs - NamedPatPairs01_fs - --test:ErrorRanges`` compilation = compilation - |> getCompilation - |> asFs - |> withOptions ["--test:ErrorRanges"] + |> ignoreWarnings + |> withLangVersionPreview |> typecheck - |> shouldSucceed \ No newline at end of file + |> shouldSucceed + + + [] + let ``Version9 NamedPatPairs - NamedPatPairs01_fs - --test:ErrorRanges`` compilation = + compilation + |> ignoreWarnings + |> withLangVersion90 + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 3350, Line 8, Col 18, Line 8, Col 19, "Feature 'Allow comma as separator for pattern matching on multiple named discriminated unions fields' is not available in F# 9.0. Please use language version 'PREVIEW' or greater."); + (Error 3350, Line 9, Col 18, Line 9, Col 19, "Feature 'Allow comma as separator for pattern matching on multiple named discriminated unions fields' is not available in F# 9.0. Please use language version 'PREVIEW' or greater."); + (Error 3350, Line 9, Col 25, Line 9, Col 26, "Feature 'Allow comma as separator for pattern matching on multiple named discriminated unions fields' is not available in F# 9.0. Please use language version 'PREVIEW' or greater."); + (Error 3350, Line 19, Col 18, Line 19, Col 19, "Feature 'Allow comma as separator for pattern matching on multiple named discriminated unions fields' is not available in F# 9.0. Please use language version 'PREVIEW' or greater."); + (Error 3350, Line 20, Col 18, Line 20, Col 19, "Feature 'Allow comma as separator for pattern matching on multiple named discriminated unions fields' is not available in F# 9.0. Please use language version 'PREVIEW' or greater."); + (Error 3350, Line 21, Col 25, Line 21, Col 26, "Feature 'Allow comma as separator for pattern matching on multiple named discriminated unions fields' is not available in F# 9.0. Please use language version 'PREVIEW' or greater.") + ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs01.fs index 1710370065f..24c02f7cc99 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs01.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs01.fs @@ -1,19 +1,21 @@ -// #Conformance #PatternMatching #ActivePatterns -#light +// #Conformance #PatternMatching #NamedPatPairs +type MyUnion = + | CaseA of a: int * b: string + | CaseB of x: float * y: bool * z: char -type Shape = -| Rectangle of width : float * length : float -| Circle of radius : float -| Prism of width : float * float * height : float - -let getShapeWidth shape = - match shape with - | Rectangle(width = w) -> w - | Circle(radius = r) -> 2. * r - | Prism(width = w, height = h) -> w * h +let testComma value = + match value with + | CaseA(a = x, b = y) -> sprintf "CaseA: a=%d, b=%s" x y + | CaseB(x = p, y = q, z = r) -> sprintf "CaseB: x=%f, y=%b, z=%c" p q r -let result = getShapeWidth (Rectangle(10., 20.)) +let testSemicolon value = + match value with + | CaseA(a = x; b = y) -> sprintf "CaseA: a=%d, b=%s" x y + | CaseB(x = p; y = q; z = r) -> sprintf "CaseB: x=%f, y=%b, z=%c" p q r -if result <> 10 then exit 1 - -exit 0 \ No newline at end of file +let testMixed value = + match value with + | CaseA(a = x; b = y) -> sprintf "CaseA: a=%d, b=%s" x y + | CaseB(x = p, y = q; z = r) -> sprintf "CaseB: x=%f, y=%b, z=%c" p q r + | CaseA(a = x, b = y) -> sprintf "CaseA: a=%d, b=%s" x y + | CaseB(x = p; y = q, z = r) -> sprintf "CaseB: x=%f, y=%b, z=%c" p q r \ No newline at end of file From d2036e802aade95fc708b16b44aae63ffae5d872 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 13 Aug 2025 22:28:10 +0100 Subject: [PATCH 13/18] release notes --- docs/release-notes/.FSharp.Compiler.Service/10.0.100.md | 1 + docs/release-notes/.Language/preview.md | 1 + 2 files changed, 2 insertions(+) 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 ab9f379f87b..964bd040246 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md @@ -21,6 +21,7 @@ ### Changed * Use `errorR` instead of `error` in `CheckDeclarations.fs` when possible. ([PR #18645](https://github.com/dotnet/fsharp/pull/18645)) +* Allow comma as separator for pattern matching on multiple named discriminated unions fields. ([PR #18833](https://github.com/dotnet/fsharp/pull/18833)) ### Breaking Changes diff --git a/docs/release-notes/.Language/preview.md b/docs/release-notes/.Language/preview.md index b9afee7582e..dd25655d745 100644 --- a/docs/release-notes/.Language/preview.md +++ b/docs/release-notes/.Language/preview.md @@ -11,6 +11,7 @@ * Allow `let!`, `use!`, `and!` type annotations without requiring parentheses (([PR #18508](https://github.com/dotnet/fsharp/pull/18508) and [PR #18682](https://github.com/dotnet/fsharp/pull/18682))) * Exception names are now validated for illegal characters using the same mechanism as types/modules/namespaces ([Issue #18763](https://github.com/dotnet/fsharp/issues/18763)) * Support tail calls in computation expressions ([PR #18804](https://github.com/dotnet/fsharp/pull/18804)) +* Allow comma as separator for pattern matching on multiple named discriminated unions fields. ([PR #18833](https://github.com/dotnet/fsharp/pull/18833)) ### Fixed From b7706c1fe77b9b2c5944c760f80d1e6f460ab0ef Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 13 Aug 2025 22:40:12 +0100 Subject: [PATCH 14/18] format code --- src/Compiler/Facilities/LanguageFeatures.fs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 02bdc130cc1..49c58e3ec5a 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -414,7 +414,8 @@ type LanguageVersion(versionText) = | LanguageFeature.ScopedNowarn -> FSComp.SR.featureScopedNowarn () | LanguageFeature.AllowTypedLetUseAndBang -> FSComp.SR.featureAllowLetOrUseBangTypeAnnotationWithoutParens () | LanguageFeature.ReturnFromFinal -> FSComp.SR.featureReturnFromFinal () - | LanguageFeature.AllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields -> FSComp.SR.featureAllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields () + | LanguageFeature.AllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields -> + FSComp.SR.featureAllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields () /// Get a version string associated with the given feature. static member GetFeatureVersionString feature = From 5fcf4131b8b81eeea94419052a72037d794895fd Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Fri, 15 Aug 2025 13:58:58 +0100 Subject: [PATCH 15/18] remove duplicated rules --- src/Compiler/pars.fsy | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index d5fff52679f..ec8e435b9ac 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -3718,17 +3718,6 @@ constrPattern: let m = unionRanges (rhs2 parseState 1 2) argsM SynPat.LongIdent(lid, None, Some $2, args, vis, m) } - | atomicPatternLongIdent explicitValTyparDecls HIGH_PRECEDENCE_PAREN_APP atomicPatsOrNamePatPairsWithCommas - { let vis, lid = $1 - let args, argsM = $4 - let m = unionRanges (rhs2 parseState 1 2) argsM - SynPat.LongIdent(lid, None, Some $2, args, vis, m) } - - | atomicPatternLongIdent explicitValTyparDecls HIGH_PRECEDENCE_BRACK_APP atomicPatsOrNamePatPairsWithCommas - { let vis, lid = $1 - let args, argsM = $4 - let m = unionRanges (rhs2 parseState 1 2) argsM - SynPat.LongIdent(lid, None, Some $2, args, vis, m) } | atomicPatternLongIdent atomicPatsOrNamePatPairsWithCommas %prec pat_app { let vis, lid = $1 From 0970831ecdc2a690b97afcaa2e3bc5a624b1ea6e Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Fri, 15 Aug 2025 23:23:12 +0100 Subject: [PATCH 16/18] more tests --- .../PatternMatching/NamedPatPairs/NamedPatPairs.fs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs.fs index 9d37b6f5278..a7705686a9d 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/NamedPatPairs/NamedPatPairs.fs @@ -8,16 +8,15 @@ open FSharp.Test.Compiler module NamedPatPairs = [] - let ``Preview: NamedPatPairs - NamedPatPairs01_fs - --test:ErrorRanges`` compilation = + let ``Preview: NamedPatPairs - NamedPatPairs01_fs`` compilation = compilation |> ignoreWarnings |> withLangVersionPreview |> typecheck |> shouldSucceed - - + [] - let ``Version9 NamedPatPairs - NamedPatPairs01_fs - --test:ErrorRanges`` compilation = + let ``Version9 NamedPatPairs - NamedPatPairs01_fs`` compilation = compilation |> ignoreWarnings |> withLangVersion90 From 3287bce394b6b083047f6d48e3da40fe9b1bb575 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Mon, 18 Aug 2025 07:45:57 +0100 Subject: [PATCH 17/18] update pars.fsy --- src/Compiler/pars.fsy | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index ec8e435b9ac..36b3ac19134 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -3774,13 +3774,6 @@ atomicPatsOrNamePatPairsWithCommas: let trivia = { ParenRange = mParen } SynArgPats.NamePatPairs($2, rhs parseState 2, trivia), mParen } - | LPAREN namePatPairsWithCommas namePatSepsWithCommas atomicPattern rparen - { let mParen = rhs2 parseState 1 5 - let trivia = { ParenRange = mParen } - let namedPats = $2 - let wildPat = $4 - SynArgPats.NamePatPairs(namedPats, rhs parseState 2, trivia), mParen } - | atomicPatterns { let mParsed = rhs parseState 1 let mAll = (mParsed.StartRange, $1) ||> unionRangeWithListBy (fun p -> p.Range) From ce845f3e1bb386c2567fda74895b4a13e93d5ce8 Mon Sep 17 00:00:00 2001 From: edgargonzalez Date: Fri, 22 Aug 2025 20:58:39 +0100 Subject: [PATCH 18/18] Simplify rules --- src/Compiler/pars.fsy | 65 +++++++++++-------------------------------- 1 file changed, 17 insertions(+), 48 deletions(-) diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 36b3ac19134..d57b9b31021 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -163,7 +163,6 @@ let parse_error_rich = Some(fun (ctxt: ParseErrorContext<_>) -> %type typ typEOF %type tyconSpfnList %type atomicPatsOrNamePatPairs -%type atomicPatsOrNamePatPairsWithCommas %type atomicPatterns %type patternResult %type declExpr @@ -3656,16 +3655,16 @@ conjPatternElements: { $3 :: $1 :: [] } namePatPairs: - | namePatPair opt_seps + | namePatPair opt_namePatSep { [$1] } - | namePatPair seps namePatPairs + | namePatPair namePatSep namePatPairs { $1 :: $3 } - | namePatPair seps UNDERSCORE + | namePatPair namePatSep UNDERSCORE { [$1] } - | namePatPair seps seps namePatPairs + | namePatPair namePatSep namePatSep namePatPairs { reportParseErrorAt (rhs parseState 3) (FSComp.SR.parsExpectingPattern ()) ($1 :: $4) } @@ -3681,57 +3680,43 @@ namePatPair: | ident recover { $1, None, patFromParseError (SynPat.Wild $1.idRange.EndRange) } -namePatPairsWithCommas: - | namePatPair opt_namePatSepsWithCommas - { [$1] } - - | namePatPair namePatSepsWithCommas UNDERSCORE - { [$1] } - - | namePatPair namePatSepsWithCommas namePatPairsWithCommas - { $1 :: $3 } - - | namePatPair namePatSepsWithCommas namePatSepsWithCommas namePatPairsWithCommas - { reportParseErrorAt (rhs parseState 3) (FSComp.SR.parsExpectingPattern ()) - ($1 :: $4) } - constrPattern: | atomicPatternLongIdent explicitValTyparDecls { let vis, lid = $1 SynPat.LongIdent(lid, None, Some $2, SynArgPats.Pats [], vis, lhs parseState) } - | atomicPatternLongIdent explicitValTyparDecls atomicPatsOrNamePatPairsWithCommas %prec pat_app + | atomicPatternLongIdent explicitValTyparDecls atomicPatsOrNamePatPairs %prec pat_app { let vis, lid = $1 let args, argsM = $3 let m = unionRanges (rhs2 parseState 1 2) argsM SynPat.LongIdent(lid, None, Some $2, args, vis, m) } - | atomicPatternLongIdent explicitValTyparDecls HIGH_PRECEDENCE_PAREN_APP atomicPatsOrNamePatPairsWithCommas + | atomicPatternLongIdent explicitValTyparDecls HIGH_PRECEDENCE_PAREN_APP atomicPatsOrNamePatPairs { let vis, lid = $1 let args, argsM = $4 let m = unionRanges (rhs2 parseState 1 2) argsM SynPat.LongIdent(lid, None, Some $2, args, vis, m) } - | atomicPatternLongIdent explicitValTyparDecls HIGH_PRECEDENCE_BRACK_APP atomicPatsOrNamePatPairsWithCommas + | atomicPatternLongIdent explicitValTyparDecls HIGH_PRECEDENCE_BRACK_APP atomicPatsOrNamePatPairs { let vis, lid = $1 let args, argsM = $4 let m = unionRanges (rhs2 parseState 1 2) argsM SynPat.LongIdent(lid, None, Some $2, args, vis, m) } - | atomicPatternLongIdent atomicPatsOrNamePatPairsWithCommas %prec pat_app + | atomicPatternLongIdent atomicPatsOrNamePatPairs %prec pat_app { let vis, lid = $1 let args, argsM = $2 let m = unionRanges (rhs parseState 1) argsM SynPat.LongIdent(lid, None, None, args, vis, m) } - | atomicPatternLongIdent HIGH_PRECEDENCE_PAREN_APP atomicPatsOrNamePatPairsWithCommas + | atomicPatternLongIdent HIGH_PRECEDENCE_PAREN_APP atomicPatsOrNamePatPairs { let vis, lid = $1 let args, argsM = $3 let m = unionRanges (rhs parseState 1) argsM SynPat.LongIdent(lid, None, None, args, vis, m) } - | atomicPatternLongIdent HIGH_PRECEDENCE_BRACK_APP atomicPatsOrNamePatPairsWithCommas + | atomicPatternLongIdent HIGH_PRECEDENCE_BRACK_APP atomicPatsOrNamePatPairs { let vis, lid = $1 let args, argsM = $3 let m = unionRanges (rhs parseState 1) argsM @@ -3768,17 +3753,6 @@ atomicPatsOrNamePatPairs: let mAll = (mParsed.StartRange, $1) ||> unionRangeWithListBy (fun p -> p.Range) SynArgPats.Pats $1, mAll } -atomicPatsOrNamePatPairsWithCommas: - | LPAREN namePatPairsWithCommas rparen - { let mParen = rhs2 parseState 1 3 - let trivia = { ParenRange = mParen } - SynArgPats.NamePatPairs($2, rhs parseState 2, trivia), mParen } - - | atomicPatterns - { let mParsed = rhs parseState 1 - let mAll = (mParsed.StartRange, $1) ||> unionRangeWithListBy (fun p -> p.Range) - SynArgPats.Pats $1, mAll } - atomicPatterns: | atomicPattern atomicPatterns %prec pat_args { $1 :: $2 } @@ -7017,23 +6991,18 @@ seps: | OBLOCKSEP SEMICOLON { Some (rhs parseState 2) } | SEMICOLON OBLOCKSEP { Some (rhs parseState 1) } -namePatSepsWithCommas: +/* Unified separator for name pattern pairs that handles both semicolon and comma */ +namePatSep: | OBLOCKSEP { None } | SEMICOLON { Some (rhs parseState 1) } - | COMMA - { parseState.LexBuffer.CheckLanguageFeatureAndRecover LanguageFeature.AllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields (rhs parseState 1) - Some (rhs parseState 1) } + | COMMA { Some (rhs parseState 1) } | OBLOCKSEP SEMICOLON { Some (rhs parseState 2) } - | OBLOCKSEP COMMA - { parseState.LexBuffer.CheckLanguageFeatureAndRecover LanguageFeature.AllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields (rhs parseState 2) - Some (rhs parseState 2) } + | OBLOCKSEP COMMA { Some (rhs parseState 2) } | SEMICOLON OBLOCKSEP { Some (rhs parseState 1) } - | COMMA OBLOCKSEP - { parseState.LexBuffer.CheckLanguageFeatureAndRecover LanguageFeature.AllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields (rhs parseState 1) - Some (rhs parseState 1) } + | COMMA OBLOCKSEP { Some (rhs parseState 1) } -opt_namePatSepsWithCommas: - | namePatSepsWithCommas { } +opt_namePatSep: + | namePatSep { } | /* EMPTY */ { } /* An 'end' that's optional only in #light, where an ODECLEND gets inserted, and explicit 'end's get converted to OEND */