From 60127ac36bf822eff55e58a9498ec8feb6654c44 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 16 Aug 2023 16:23:27 +0200 Subject: [PATCH 01/49] Better error for match with a patterns referring to an out of scope identifier --- src/Compiler/Checking/NameResolution.fs | 1 - .../PatternMatching/Union/E_UnionPattern12.fs | 14 +++++ .../PatternMatching/Union/E_UnionPattern13.fs | 12 ++++ .../PatternMatching/Union/E_UnionPattern14.fs | 12 ++++ .../PatternMatching/Union/E_UnionPattern15.fs | 12 ++++ .../PatternMatching/Union/Union.fs | 55 ++++++++++++++++++- 6 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern12.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern13.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern14.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern15.fs diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index 0da7c028eac..a663c765dd6 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -3239,7 +3239,6 @@ let rec ResolvePatternLongIdentPrim sink (ncenv: NameResolver) fullyQualified wa if not newDef && warnOnUpper = WarnOnUpperCase - && id.idText.Length >= 3 && System.Char.ToLowerInvariant id.idText[0] <> id.idText[0] then warning(UpperCaseIdentifierInPattern m) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern12.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern12.fs new file mode 100644 index 00000000000..2b5adefd762 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern12.fs @@ -0,0 +1,14 @@ +module DUs = + type Countries = + | CA + | US + | GB +let x = DUs.CA + +open DUs + +let output = + match x with + | US -> "US" + | CA -> "CA" + | U -> "U" \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern13.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern13.fs new file mode 100644 index 00000000000..90bb18da021 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern13.fs @@ -0,0 +1,12 @@ +module DUs = + type Countries = + | CA + | US + | GB +let x = DUs.CA + +let output = + match x with + | US -> "US" + | CA -> "CA" + | U -> "U" \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern14.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern14.fs new file mode 100644 index 00000000000..1a6d883360e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern14.fs @@ -0,0 +1,12 @@ +module DUs = + type Countries = + | CA + | US + | GB +let x = DUs.CA + +let output = + match x with + | uSA -> "US" + | AAA -> "CA" + | uAA -> "U" \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern15.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern15.fs new file mode 100644 index 00000000000..2156b9c7b86 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern15.fs @@ -0,0 +1,12 @@ +module DUs = + type Countries = + | CA + | US + | GB +let x = DUs.CA + +let output = + match x with + | US -> "US" + | CA -> "CA" + | _ -> "U" \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs index b7330c0acfa..fb128075527 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs @@ -209,4 +209,57 @@ but here has type |> shouldFail |> withDiagnostics [ (Warning 26, Line 8, Col 7, Line 8, Col 55, "This rule will never be matched") - ] \ No newline at end of file + ] + + [] + let ``Union - E_UnionPattern12_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 49, Line 14, Col 7, Line 14, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + ] + + [] + let ``Union - E_UnionPattern13_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 49, Line 10, Col 7, Line 10, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 11, Col 7, Line 11, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 12, Col 7, Line 12, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 26, Line 11, Col 7, Line 11, Col 9, "This rule will never be matched") + (Warning 26, Line 12, Col 7, Line 12, Col 8, "This rule will never be matched") + ] + + [] + let ``Union - E_UnionPattern14_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 49, Line 11, Col 7, Line 11, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 26, Line 11, Col 7, Line 11, Col 10, "This rule will never be matched") + (Warning 26, Line 12, Col 7, Line 12, Col 10, "This rule will never be matched") + ] + + [] + let ``Union - E_UnionPattern15_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 49, Line 10, Col 7, Line 10, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 11, Col 7, Line 11, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 26, Line 11, Col 7, Line 11, Col 9, "This rule will never be matched") + (Warning 26, Line 12, Col 7, Line 12, Col 8, "This rule will never be matched") + ] \ No newline at end of file From b85263442aaf0093bcbbc4c0373513afa3699400 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 16 Aug 2023 19:47:13 +0200 Subject: [PATCH 02/49] Lets find out --- src/FSharp.Core/Query.fs | 44 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/FSharp.Core/Query.fs b/src/FSharp.Core/Query.fs index 28a460619f6..a8f3f877391 100644 --- a/src/FSharp.Core/Query.fs +++ b/src/FSharp.Core/Query.fs @@ -452,14 +452,14 @@ module Query = let FuncExprToLinqFunc2 (srcTy, targetTy, v, body) = FuncExprToDelegateExpr(srcTy, targetTy, v, body) |> LeafExpressionConverter.EvaluateQuotation - let MakersCallers F = CallGenericStaticMethod F, MakeGenericStaticMethod F + let MakersCallers f = CallGenericStaticMethod f, MakeGenericStaticMethod f - let MakersCallersInstance F = CallGenericInstanceMethod F, MakeGenericInstanceMethod F + let MakersCallersInstance f = CallGenericInstanceMethod f, MakeGenericInstanceMethod f - let MakersCallers2 FQ FE = MakersCallers FQ, MakersCallers FE + let MakersCallers2 fQ fE = MakersCallers fQ, MakersCallers fE - let MakeOrCallContainsOrElementAt FQ FE = - let (CQ, MQ), (CE, ME) = MakersCallers2 FQ FE + let MakeOrCallContainsOrElementAt fQ fE = + let (CQ, MQ), (CE, ME) = MakersCallers2 fQ fE let Make (isIQ, srcItemTy: Type, src: Expr, key: Expr) = if isIQ then //let key = MakeImplicitExpressionConversion key @@ -483,8 +483,8 @@ module Query = let FE = methodhandleof (fun (x, y) -> Enumerable.ElementAt(x, y)) MakeOrCallContainsOrElementAt FQ FE - let MakeOrCallMinByOrMaxBy FQ FE = - let (CQ, MQ), (CE, ME) = MakersCallers2 FQ FE + let MakeOrCallMinByOrMaxBy fQ fE = + let (CQ, MQ), (CE, ME) = MakersCallers2 fQ fE let Make (isIQ, src: Expr, v: Var, valSelector: Expr) = let srcItemTy = v.Type let keyElemTy = valSelector.Type @@ -527,8 +527,8 @@ module Query = let FE = methodhandleof (fun (x, y: Func<_, 'Result>) -> Enumerable.Max(x, y)) MakeOrCallMinByOrMaxBy FQ FE - let MakeOrCallAnyOrAllOrFirstFind FQ FE = - let (CQ, MQ), (CE, ME) = MakersCallers2 FQ FE + let MakeOrCallAnyOrAllOrFirstFind fQ fE = + let (CQ, MQ), (CE, ME) = MakersCallers2 fQ fE let Make (isIQ, src: Expr, v: Var, predicate: Expr) = let srcItemTy= v.Type let predicate = FuncExprToDelegateExpr (srcItemTy, boolTy, v, predicate) @@ -563,14 +563,14 @@ module Query = let FE = methodhandleof (fun (x, y: Func<_, _>) -> Enumerable.First(x, y)) MakeOrCallAnyOrAllOrFirstFind FQ FE - let MakeOrCallAverageByOrSumByGeneric (isNullable, fq_double, fq_single, fq_decimal, fq_int32, fq_int64, fe_double, fe_single, fe_decimal, fe_int32, fe_int64, FE) = + let MakeOrCallAverageByOrSumByGeneric (isNullable, fq_double, fq_single, fq_decimal, fq_int32, fq_int64, fe_double, fe_single, fe_decimal, fe_int32, fe_int64, fE) = let (cq_double, mq_double), (ce_double, me_double) = MakersCallers2 fq_double fe_double let (cq_single, mq_single), (ce_single, me_single) = MakersCallers2 fq_single fe_single let (cq_decimal, mq_decimal), (ce_decimal, me_decimal) = MakersCallers2 fq_decimal fe_decimal let (cq_int32, mq_int32), (ce_int32, me_int32) = MakersCallers2 fq_int32 fe_int32 let (cq_int64, mq_int64), (ce_int64, me_int64) = MakersCallers2 fq_int64 fe_int64 // The F# implementation is an instance method on QueryBuilder - let (CE, ME) = MakersCallersInstance FE + let (CE, ME) = MakersCallersInstance fE let failDueToUnsupportedInputTypeInSumByOrAverageBy() = invalidOp (SR.GetString(SR.failDueToUnsupportedInputTypeInSumByOrAverageBy)) let Make (qb: Expr, isIQ, src: Expr, v: Var, res: Expr) = @@ -711,8 +711,8 @@ module Query = let FE = methodhandleof (fun (query:QueryBuilder, arg1: QuerySource<_, _>, arg2:_->Nullable) -> query.SumByNullable(arg1, arg2)) MakeOrCallAverageByOrSumByGeneric (true, FQ_double, FQ_single, FQ_decimal, FQ_int32, FQ_int64, FE_double, FE_single, FE_decimal, FE_int32, FE_int64, FE) - let MakeOrCallSimpleOp FQ FE = - let (CQ, MQ), (CE, ME) = MakersCallers2 FQ FE + let MakeOrCallSimpleOp fQ fE = + let (CQ, MQ), (CE, ME) = MakersCallers2 fQ fE let Make (isIQ, srcItemTy, src: Expr) = if isIQ then MQ ([srcItemTy], [src]) @@ -816,16 +816,16 @@ module Query = else FE ([v.Type], [src; selector]) - let MakeOrderByOrThenBy FQ FE = + let MakeOrderByOrThenBy fQ fE = fun (isIQ, src: Expr, v: Var, keySelector: Expr) -> let srcItemTy = v.Type let keyItemTy = keySelector.Type let selector = Expr.NewDelegate (MakeQueryFuncTy(srcItemTy, keyItemTy), [v], keySelector) if isIQ then let selector = MakeImplicitExpressionConversion selector - FQ ([srcItemTy; keyItemTy], [src; selector]) + fQ ([srcItemTy; keyItemTy], [src; selector]) else - FE ([srcItemTy; keyItemTy], [src; selector]) + fE ([srcItemTy; keyItemTy], [src; selector]) let MakeOrderBy = let FQ = MakeGenericStaticMethod (methodhandleof (fun (x, y: Expression>) -> System.Linq.Queryable.OrderBy(x, y))) @@ -856,9 +856,9 @@ module Query = let MakeThenByNullableDescending = MakeThenByDescending - let GenMakeSkipWhileOrTakeWhile FQ FE = - let FQ = MakeGenericStaticMethod FQ - let FE = MakeGenericStaticMethod FE + let GenMakeSkipWhileOrTakeWhile fQ fE = + let FQ = MakeGenericStaticMethod fQ + let FE = MakeGenericStaticMethod fE fun (isIQ, src: Expr, v: Var, predicate) -> let srcItemTy = v.Type let selector = Expr.NewDelegate (MakeQueryFuncTy(srcItemTy, boolTy), [v], predicate) @@ -868,9 +868,9 @@ module Query = else FE ([srcItemTy], [src; selector]) - let MakeSkipOrTake FQ FE = - let FQ = MakeGenericStaticMethod FQ - let FE = MakeGenericStaticMethod FE + let MakeSkipOrTake fQ fE = + let FQ = MakeGenericStaticMethod fQ + let FE = MakeGenericStaticMethod fE fun (isIQ, srcItemTy, src: Expr, count) -> if isIQ then FQ ([srcItemTy], [src; count]) From f599bcaa0318a22720d17b121c67a3f8ef66a901 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 16 Aug 2023 21:06:43 +0200 Subject: [PATCH 03/49] Ok now I wish I did not know about this --- tests/fsharp/core/auto-widen/5.0/test.fsx | 2 +- .../core/auto-widen/preview-default-warns/test.fsx | 10 +++++----- tests/fsharp/core/auto-widen/preview/test.fsx | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/fsharp/core/auto-widen/5.0/test.fsx b/tests/fsharp/core/auto-widen/5.0/test.fsx index c5ec8bf854d..13e9aa65ab7 100644 --- a/tests/fsharp/core/auto-widen/5.0/test.fsx +++ b/tests/fsharp/core/auto-widen/5.0/test.fsx @@ -131,7 +131,7 @@ module ConvertToSealedViaOpImplicit = [] type C() = static member op_Implicit(x:int) = C() - static member M1(C:C) = 1 + static member M1(c:C) = 1 let x = C.M1(2) module ConvertNoOverloadin = diff --git a/tests/fsharp/core/auto-widen/preview-default-warns/test.fsx b/tests/fsharp/core/auto-widen/preview-default-warns/test.fsx index a7165743955..6caf7da4a60 100644 --- a/tests/fsharp/core/auto-widen/preview-default-warns/test.fsx +++ b/tests/fsharp/core/auto-widen/preview-default-warns/test.fsx @@ -131,7 +131,7 @@ module ConvertToSealedViaOpImplicit = [] type C() = static member op_Implicit(x:int) = C() - static member M1(C:C) = 1 + static member M1(c:C) = 1 let x = C.M1(2) module ConvertNoOverloadin = @@ -161,7 +161,7 @@ module ConvertViaOpImplicit3 = module ConvertViaOpImplicit4 = type C() = static member op_Implicit(x:int) = C() - static member M1(C:C) = 1 + static member M1(c:C) = 1 let x = C.M1(2) module ConvertViaOpImplicit5 = @@ -459,7 +459,7 @@ module TestAcessibilityOfOpImplicit = [] type C() = static member private op_Implicit(x:int) = C() - static member M1(C:C) = 1 + static member M1(c:C) = 1 let x = C.M1(2) module TestObsoleteOfOpImplicit = @@ -467,7 +467,7 @@ module TestObsoleteOfOpImplicit = type C() = [] static member op_Implicit(x:int) = C() - static member M1(C:C) = 1 + static member M1(c:C) = 1 let x = C.M1(2) module TestAmbiguousOpImplicit = @@ -477,7 +477,7 @@ module TestAmbiguousOpImplicit = and [] C(x:int) = static member op_Implicit(x:B) = C(1) - static member M1(C:C) = 1 + static member M1(c:C) = 1 member _.Value = x let x = C.M1(B()) diff --git a/tests/fsharp/core/auto-widen/preview/test.fsx b/tests/fsharp/core/auto-widen/preview/test.fsx index bd484c4b347..b464bc22df2 100644 --- a/tests/fsharp/core/auto-widen/preview/test.fsx +++ b/tests/fsharp/core/auto-widen/preview/test.fsx @@ -131,7 +131,7 @@ module ConvertToSealedViaOpImplicit = [] type C() = static member op_Implicit(x:int) = C() - static member M1(C:C) = 1 + static member M1(c:C) = 1 let x = C.M1(2) module ConvertNoOverloadin = @@ -161,7 +161,7 @@ module ConvertViaOpImplicit3 = module ConvertViaOpImplicit4 = type C() = static member op_Implicit(x:int) = C() - static member M1(C:C) = 1 + static member M1(c:C) = 1 let x = C.M1(2) module ConvertViaOpImplicit5 = @@ -459,7 +459,7 @@ module TestAcessibilityOfOpImplicit = [] type C() = static member private op_Implicit(x:int) = C() - static member M1(C:C) = 1 + static member M1(c:C) = 1 let x = C.M1(2) module TestObsoleteOfOpImplicit = @@ -467,7 +467,7 @@ module TestObsoleteOfOpImplicit = type C() = [] static member op_Implicit(x:int) = C() - static member M1(C:C) = 1 + static member M1(c:C) = 1 let x = C.M1(2) module TestAmbiguousOpImplicit = @@ -477,7 +477,7 @@ module TestAmbiguousOpImplicit = and [] C(x:int) = static member op_Implicit(x:B) = C(1) - static member M1(C:C) = 1 + static member M1(c:C) = 1 member _.Value = x let x = C.M1(B()) From 27f2a3c3e9f4c4a50c67ddee4362fd4f3a46f6ed Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 16 Aug 2023 22:00:46 +0200 Subject: [PATCH 04/49] update test --- tests/fsharp/core/auto-widen/5.0/test.fsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fsharp/core/auto-widen/5.0/test.fsx b/tests/fsharp/core/auto-widen/5.0/test.fsx index 13e9aa65ab7..7eb3d494590 100644 --- a/tests/fsharp/core/auto-widen/5.0/test.fsx +++ b/tests/fsharp/core/auto-widen/5.0/test.fsx @@ -161,7 +161,7 @@ module ConvertViaOpImplicit3 = module ConvertViaOpImplicit4 = type C() = static member op_Implicit(x:int) = C() - static member M1(C:C) = 1 + static member M1(c:C) = 1 let x = C.M1(2) module ConvertViaOpImplicit5 = From c8294ecb66c01f299d8fb8fe9d23a502a3247b8a Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 16 Aug 2023 22:52:05 +0200 Subject: [PATCH 05/49] last one ? --- .../QueryExpressions/UppercaseIdentifier04.fs | Bin 1066 -> 1066 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/UppercaseIdentifier04.fs b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/UppercaseIdentifier04.fs index de1f4a7ecdce806a86a29b19a0755f8e805aeb06..ca2c823d157474ea878b119f82b8252581335410 100644 GIT binary patch delta 50 zcmZ3*v5I4Z5)*48gAPN| Date: Fri, 18 Aug 2023 21:24:56 +0200 Subject: [PATCH 06/49] Update error message to clarify the details of the historical hack. --- src/Compiler/FSStrings.resx | 2 +- src/Compiler/xlf/FSStrings.cs.xlf | 4 ++-- src/Compiler/xlf/FSStrings.de.xlf | 4 ++-- src/Compiler/xlf/FSStrings.es.xlf | 4 ++-- src/Compiler/xlf/FSStrings.fr.xlf | 4 ++-- src/Compiler/xlf/FSStrings.it.xlf | 4 ++-- src/Compiler/xlf/FSStrings.ja.xlf | 4 ++-- src/Compiler/xlf/FSStrings.ko.xlf | 4 ++-- src/Compiler/xlf/FSStrings.pl.xlf | 4 ++-- src/Compiler/xlf/FSStrings.pt-BR.xlf | 4 ++-- src/Compiler/xlf/FSStrings.ru.xlf | 4 ++-- src/Compiler/xlf/FSStrings.tr.xlf | 4 ++-- src/Compiler/xlf/FSStrings.zh-Hans.xlf | 4 ++-- src/Compiler/xlf/FSStrings.zh-Hant.xlf | 4 ++-- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Compiler/FSStrings.resx b/src/Compiler/FSStrings.resx index da3829dbc5c..eb4dd520149 100644 --- a/src/Compiler/FSStrings.resx +++ b/src/Compiler/FSStrings.resx @@ -154,7 +154,7 @@ Type constraint mismatch. The type \n '{0}' \nis not compatible with type\n '{1}' {2}\n - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. + Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. Discriminated union cases and exception labels must be uppercase identifiers diff --git a/src/Compiler/xlf/FSStrings.cs.xlf b/src/Compiler/xlf/FSStrings.cs.xlf index 4676ded7083..da1cddc188c 100644 --- a/src/Compiler/xlf/FSStrings.cs.xlf +++ b/src/Compiler/xlf/FSStrings.cs.xlf @@ -108,8 +108,8 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. - Identifikátory proměnných psané velkými písmeny se ve vzorech obecně nedoporučují. Můžou označovat chybějící otevřenou deklaraci nebo špatně napsaný název vzoru. + Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Identifikátory proměnných psané velkými písmeny se ve vzorech obecně nedoporučují. Můžou označovat chybějící otevřenou deklaraci nebo špatně napsaný název vzoru. diff --git a/src/Compiler/xlf/FSStrings.de.xlf b/src/Compiler/xlf/FSStrings.de.xlf index 0b386bdd064..8666dd99ea2 100644 --- a/src/Compiler/xlf/FSStrings.de.xlf +++ b/src/Compiler/xlf/FSStrings.de.xlf @@ -108,8 +108,8 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. - Variablenbezeichner in Großbuchstaben sollten im Allgemeinen nicht in Mustern verwendet werden und können ein Hinweis auf eine fehlende open-Deklaration oder einen falsch geschriebenen Musternamen sein. + Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Variablenbezeichner in Großbuchstaben sollten im Allgemeinen nicht in Mustern verwendet werden und können ein Hinweis auf eine fehlende open-Deklaration oder einen falsch geschriebenen Musternamen sein. diff --git a/src/Compiler/xlf/FSStrings.es.xlf b/src/Compiler/xlf/FSStrings.es.xlf index a5008e7c476..145b410e89f 100644 --- a/src/Compiler/xlf/FSStrings.es.xlf +++ b/src/Compiler/xlf/FSStrings.es.xlf @@ -108,8 +108,8 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. - En general, los identificadores de variables en mayúscula no deben usarse en patrones y pueden indicar una declaración abierta que falta o un nombre de patrón mal escrito. + Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + En general, los identificadores de variables en mayúscula no deben usarse en patrones y pueden indicar una declaración abierta que falta o un nombre de patrón mal escrito. diff --git a/src/Compiler/xlf/FSStrings.fr.xlf b/src/Compiler/xlf/FSStrings.fr.xlf index a8ffac1edb2..a9b6178d478 100644 --- a/src/Compiler/xlf/FSStrings.fr.xlf +++ b/src/Compiler/xlf/FSStrings.fr.xlf @@ -108,8 +108,8 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. - Les identificateurs de variables en majuscules ne doivent généralement pas être utilisés dans les modèles. Ils peuvent indiquer une absence de déclaration open ou un nom de modèle mal orthographié. + Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Les identificateurs de variables en majuscules ne doivent généralement pas être utilisés dans les modèles. Ils peuvent indiquer une absence de déclaration open ou un nom de modèle mal orthographié. diff --git a/src/Compiler/xlf/FSStrings.it.xlf b/src/Compiler/xlf/FSStrings.it.xlf index 9654664e86b..10bb7fd11b9 100644 --- a/src/Compiler/xlf/FSStrings.it.xlf +++ b/src/Compiler/xlf/FSStrings.it.xlf @@ -108,8 +108,8 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. - In genere è consigliabile non usare identificatori di variabili scritti in maiuscolo nei criteri perché potrebbero indicare una dichiarazione OPEN mancante o un nome di criterio con ortografia errata. + Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + In genere è consigliabile non usare identificatori di variabili scritti in maiuscolo nei criteri perché potrebbero indicare una dichiarazione OPEN mancante o un nome di criterio con ortografia errata. diff --git a/src/Compiler/xlf/FSStrings.ja.xlf b/src/Compiler/xlf/FSStrings.ja.xlf index d5ec4d91da6..e067f7fec61 100644 --- a/src/Compiler/xlf/FSStrings.ja.xlf +++ b/src/Compiler/xlf/FSStrings.ja.xlf @@ -108,8 +108,8 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. - 通常、大文字の変数識別子はパターンに使用できません。また、欠落している open 宣言か、つづりが間違っているパターン名を示す可能性があります。 + Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + 通常、大文字の変数識別子はパターンに使用できません。また、欠落している open 宣言か、つづりが間違っているパターン名を示す可能性があります。 diff --git a/src/Compiler/xlf/FSStrings.ko.xlf b/src/Compiler/xlf/FSStrings.ko.xlf index b4ee40c250c..eb161d9842a 100644 --- a/src/Compiler/xlf/FSStrings.ko.xlf +++ b/src/Compiler/xlf/FSStrings.ko.xlf @@ -108,8 +108,8 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. - 일반적으로 대문자 변수 식별자는 패턴에 사용하지 말아야 합니다. 이러한 식별자는 열려 있는 선언이 없거나 철자가 잘못된 패턴 이름을 나타낼 수 있습니다. + Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + 일반적으로 대문자 변수 식별자는 패턴에 사용하지 말아야 합니다. 이러한 식별자는 열려 있는 선언이 없거나 철자가 잘못된 패턴 이름을 나타낼 수 있습니다. diff --git a/src/Compiler/xlf/FSStrings.pl.xlf b/src/Compiler/xlf/FSStrings.pl.xlf index b01d8256e3e..6af1b03d599 100644 --- a/src/Compiler/xlf/FSStrings.pl.xlf +++ b/src/Compiler/xlf/FSStrings.pl.xlf @@ -108,8 +108,8 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. - Identyfikatory zmiennych pisane wielkimi literami nie powinny być na ogół używane we wzorcach i mogą oznaczać brak deklaracji otwierającej lub błąd pisowni w nazwie wzorca. + Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Identyfikatory zmiennych pisane wielkimi literami nie powinny być na ogół używane we wzorcach i mogą oznaczać brak deklaracji otwierającej lub błąd pisowni w nazwie wzorca. diff --git a/src/Compiler/xlf/FSStrings.pt-BR.xlf b/src/Compiler/xlf/FSStrings.pt-BR.xlf index 44b24e76174..b3120d257ea 100644 --- a/src/Compiler/xlf/FSStrings.pt-BR.xlf +++ b/src/Compiler/xlf/FSStrings.pt-BR.xlf @@ -108,8 +108,8 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. - Identificadores de variáveis em maiúsculas geralmente não devem ser usados em padrões, podendo indicar uma declaração aberta ausente ou um nome de padrão escrito incorretamente. + Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Identificadores de variáveis em maiúsculas geralmente não devem ser usados em padrões, podendo indicar uma declaração aberta ausente ou um nome de padrão escrito incorretamente. diff --git a/src/Compiler/xlf/FSStrings.ru.xlf b/src/Compiler/xlf/FSStrings.ru.xlf index 6d0c1b1d517..5454ef343fb 100644 --- a/src/Compiler/xlf/FSStrings.ru.xlf +++ b/src/Compiler/xlf/FSStrings.ru.xlf @@ -108,8 +108,8 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. - Идентификаторы переменных в верхнем регистре обычно не должны использоваться в шаблонах, и могут указывать на отсутствующую открытую декларацию или неправильно написанное имя шаблона. + Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Идентификаторы переменных в верхнем регистре обычно не должны использоваться в шаблонах, и могут указывать на отсутствующую открытую декларацию или неправильно написанное имя шаблона. diff --git a/src/Compiler/xlf/FSStrings.tr.xlf b/src/Compiler/xlf/FSStrings.tr.xlf index 8758b001581..efce15ab823 100644 --- a/src/Compiler/xlf/FSStrings.tr.xlf +++ b/src/Compiler/xlf/FSStrings.tr.xlf @@ -108,8 +108,8 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. - Büyük harfli değişken tanımlayıcıları desenlerde genel olarak kullanılmamalıdır. Bunlar, eksik bir açık bildirimin veya yanlış yazılmış bir desen adının göstergesi olabilirler. + Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Büyük harfli değişken tanımlayıcıları desenlerde genel olarak kullanılmamalıdır. Bunlar, eksik bir açık bildirimin veya yanlış yazılmış bir desen adının göstergesi olabilirler. diff --git a/src/Compiler/xlf/FSStrings.zh-Hans.xlf b/src/Compiler/xlf/FSStrings.zh-Hans.xlf index e21e73e60f7..0564ec386ff 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hans.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hans.xlf @@ -108,8 +108,8 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. - 通常不得在模式中使用大写的变量标识符,存在它们可能表示缺少某个开放声明或某个模式名称拼写错误。 + Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + 通常不得在模式中使用大写的变量标识符,存在它们可能表示缺少某个开放声明或某个模式名称拼写错误。 diff --git a/src/Compiler/xlf/FSStrings.zh-Hant.xlf b/src/Compiler/xlf/FSStrings.zh-Hant.xlf index 5d294f8b58a..8a99400952d 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hant.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hant.xlf @@ -108,8 +108,8 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. - 通常不應在樣式中使用大寫的變數識別碼。這可能表示缺少公開宣告或樣式名稱拼字錯誤。 + Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + 通常不應在樣式中使用大寫的變數識別碼。這可能表示缺少公開宣告或樣式名稱拼字錯誤。 From bef94a22dd0a0eaa83ad0d033865c7c182e6cc0b Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Fri, 18 Aug 2023 21:25:36 +0200 Subject: [PATCH 07/49] Update more tests --- src/Compiler/Checking/NameResolution.fs | 3 ++ .../BindingExpressions/BindingExpressions.fs | 17 ++++++++++ .../E_UpperBindingPattern.fs | 6 ++++ .../PatternMatching/Simple/Simple.fs | 3 +- .../PatternMatching/Union/E_UnionPattern13.fs | 4 ++- .../PatternMatching/Union/E_UnionPattern14.fs | 2 +- .../PatternMatching/Union/E_UnionPattern15.fs | 2 +- .../PatternMatching/Union/E_UnionPattern16.fs | 12 +++++++ .../PatternMatching/Union/Union.fs | 32 ++++++++++--------- .../ErrorMessages/ClassesTests.fs | 31 +++++++++++++++++- 10 files changed, 91 insertions(+), 21 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern16.fs diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index a663c765dd6..11ada92a979 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -3239,6 +3239,9 @@ let rec ResolvePatternLongIdentPrim sink (ncenv: NameResolver) fullyQualified wa if not newDef && warnOnUpper = WarnOnUpperCase + // HACK: This is an historical hack that seems to related the use country and language codes, which are very common in codebases + // Removing this check will cause a lot of new warnings/errors in existing codebases. + && id.idText.Length >= 3 && System.Char.ToLowerInvariant id.idText[0] <> id.idText[0] then warning(UpperCaseIdentifierInPattern m) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs index 4aa7ff3999a..8c1c1d22d0e 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs @@ -140,4 +140,21 @@ module BindingExpressions = |> withDiagnostics [ (Warning 64, Line 10, Col 32, Line 10, Col 33, "This construct causes code to be less generic than indicated by the type annotations. The type variable 'b has been constrained to be type ''a'.") ] + + [] + let ``E_UpperBindingPattern_fs`` compilation = + compilation + |> asExe + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 49, Line 6, Col 23, Line 6, Col 26, "Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name.") + (Error 30, Line 2, Col 9, Line 2, Col 32, "Value restriction. The value 'CallGenericStaticMethod' has been inferred to have generic type + val CallGenericStaticMethod: ('_a -> '_b) +Either make the arguments to 'CallGenericStaticMethod' explicit or, if you do not intend for it to be generic, add a type annotation.") + (Error 30, Line 4, Col 9, Line 4, Col 32, "Value restriction. The value 'MakeGenericStaticMethod' has been inferred to have generic type + val MakeGenericStaticMethod: ('_a -> '_b) +Either make the arguments to 'MakeGenericStaticMethod' explicit or, if you do not intend for it to be generic, add a type annotation.") + ] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern.fs new file mode 100644 index 00000000000..01a6fe5e539 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern.fs @@ -0,0 +1,6 @@ +module One = + let CallGenericStaticMethod = failwithf "CallGenericStaticMethod" + + let MakeGenericStaticMethod = failwithf "MakeGenericStaticMethod" + + let MakersCallers FSS = CallGenericStaticMethod FSS, MakeGenericStaticMethod FSS \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs index 7ddf43cf235..de81340077c 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs @@ -357,5 +357,4 @@ match CaseA with |> shouldFail |> withDiagnostics [ Warning 104, Line 10, Col 7, Line 10, Col 12, "Enums may take values outside known cases. For example, the value 'CaseB (enum (0))' may indicate a case not covered by the pattern(s)." - Warning 25, Line 10, Col 7, Line 10, Col 12, "Incomplete pattern matches on this expression. For example, the value 'CaseA' may indicate a case not covered by the pattern(s)."] - \ No newline at end of file + Warning 25, Line 10, Col 7, Line 10, Col 12, "Incomplete pattern matches on this expression. For example, the value 'CaseA' may indicate a case not covered by the pattern(s)."] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern13.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern13.fs index 90bb18da021..5cae82bd391 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern13.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern13.fs @@ -5,8 +5,10 @@ module DUs = | GB let x = DUs.CA +open DUs + let output = match x with | US -> "US" | CA -> "CA" - | U -> "U" \ No newline at end of file + | UUU -> "U" \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern14.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern14.fs index 1a6d883360e..f1302481c7e 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern14.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern14.fs @@ -9,4 +9,4 @@ let output = match x with | uSA -> "US" | AAA -> "CA" - | uAA -> "U" \ No newline at end of file + | uuu -> "U" \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern15.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern15.fs index 2156b9c7b86..343f84f4a66 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern15.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern15.fs @@ -9,4 +9,4 @@ let output = match x with | US -> "US" | CA -> "CA" - | _ -> "U" \ No newline at end of file + | UUU -> "U" \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern16.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern16.fs new file mode 100644 index 00000000000..11c9c43f144 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern16.fs @@ -0,0 +1,12 @@ +module DUs = + type Countries = + | CA + | US + | GB +let x = DUs.CA + +let output = + match x with + | US -> "US" + | CA -> "CA" + | uuu -> "U" \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs index fb128075527..ba009627c06 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs @@ -217,10 +217,7 @@ but here has type |> asFs |> withOptions ["--test:ErrorRanges"] |> typecheck - |> shouldFail - |> withDiagnostics [ - (Warning 49, Line 14, Col 7, Line 14, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - ] + |> shouldSucceed [] let ``Union - E_UnionPattern13_fs - --test:ErrorRanges`` compilation = @@ -229,13 +226,7 @@ but here has type |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldFail - |> withDiagnostics [ - (Warning 49, Line 10, Col 7, Line 10, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 11, Col 7, Line 11, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 12, Col 7, Line 12, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 26, Line 11, Col 7, Line 11, Col 9, "This rule will never be matched") - (Warning 26, Line 12, Col 7, Line 12, Col 8, "This rule will never be matched") - ] + |> withSingleDiagnostic (Warning 49, Line 14, Col 7, Line 14, Col 10, "Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name.") [] let ``Union - E_UnionPattern14_fs - --test:ErrorRanges`` compilation = @@ -245,7 +236,7 @@ but here has type |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 11, Col 7, Line 11, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 11, Col 7, Line 11, Col 10, "Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name.") (Warning 26, Line 11, Col 7, Line 11, Col 10, "This rule will never be matched") (Warning 26, Line 12, Col 7, Line 12, Col 10, "This rule will never be matched") ] @@ -258,8 +249,19 @@ but here has type |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 10, Col 7, Line 10, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 11, Col 7, Line 11, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 12, Col 7, Line 12, Col 10, "Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name.") + (Warning 26, Line 11, Col 7, Line 11, Col 9, "This rule will never be matched") + (Warning 26, Line 12, Col 7, Line 12, Col 10, "This rule will never be matched") + ] + + [] + let ``Union - E_UnionPattern16_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ (Warning 26, Line 11, Col 7, Line 11, Col 9, "This rule will never be matched") - (Warning 26, Line 12, Col 7, Line 12, Col 8, "This rule will never be matched") + (Warning 26, Line 12, Col 7, Line 12, Col 10, "This rule will never be matched") ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs index a1dbbe9f135..a2ed6048205 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs @@ -686,4 +686,33 @@ type X = app |> withLangVersionPreview |> compile - |> shouldSucceed \ No newline at end of file + |> shouldSucceed + + [] + let ``Class with static member with uppercase function parameter`` () = + Fsx """ + [] + type C() = + static member op_Implicit(x:int) = C() + static member M1(CCC:C) = 1 + let x = C.M1(2) + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 49, Line 5, Col 26, Line 5, Col 29, "Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name.") + ] + + [] + let ``Class with member with uppercase function parameter`` () = + Fsx """ + [] + type C() = + static member op_Implicit(x:int) = C() + member this.M1(CCC:C) = 1 + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 49, Line 5, Col 24, Line 5, Col 27, "Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name.") + ] \ No newline at end of file From 58834dca8855847afd495eae8237fa47eb65abc5 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Fri, 18 Aug 2023 21:33:33 +0200 Subject: [PATCH 08/49] update tests --- .../Conformance/PatternMatching/Named/Named.fs | 2 +- .../Conformance/PatternMatching/Simple/Simple.fs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/Named.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/Named.fs index 1b181272a08..dab7ceefa61 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/Named.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/Named.fs @@ -358,7 +358,7 @@ but here has type (Error 72, Line 20, Col 25, Line 20, Col 37, "Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.") (Error 39, Line 21, Col 7, Line 21, Col 11, "The pattern discriminator 'Word' is not defined.") (Error 72, Line 21, Col 20, Line 21, Col 31, "Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.") - (Warning 49, Line 22, Col 7, Line 22, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 22, Col 7, Line 22, Col 17, "Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name.") (Error 39, Line 23, Col 7, Line 23, Col 18, "The pattern discriminator 'Punctuation' is not defined.") (Warning 26, Line 23, Col 7, Line 23, Col 20, "This rule will never be matched") (Warning 26, Line 24, Col 7, Line 24, Col 8, "This rule will never be matched") diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs index de81340077c..0ecd570824a 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs @@ -45,8 +45,8 @@ module Simple = |> compile |> shouldFail |> withDiagnostics [ - (Warning 49, Line 9, Col 16, Line 9, Col 19, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 10, Col 16, Line 10, Col 19, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 9, Col 16, Line 9, Col 19, "Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name.") + (Warning 49, Line 10, Col 16, Line 10, Col 19, "Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name.") ] // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) From 48fb2ff912fb1221788e013260d78870548b0664 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sat, 19 Aug 2023 15:18:31 +0200 Subject: [PATCH 09/49] more tests --- tests/fsharp/typecheck/sigs/neg07.bsl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/fsharp/typecheck/sigs/neg07.bsl b/tests/fsharp/typecheck/sigs/neg07.bsl index 5b28d3e7afb..27ace91ebd9 100644 --- a/tests/fsharp/typecheck/sigs/neg07.bsl +++ b/tests/fsharp/typecheck/sigs/neg07.bsl @@ -1,23 +1,23 @@ -neg07.fs(7,10,7,29): typecheck error FS0049: Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. +neg07.fs(7,10,7,29): typecheck error FS0049: Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. -neg07.fs(7,10,7,29): typecheck error FS0049: Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. +neg07.fs(7,10,7,29): typecheck error FS0049: Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. neg07.fs(24,13,24,23): typecheck error FS0039: The value or constructor 'UnionCase1' is not defined. Maybe you want one of the following: X.UnionCase1 -neg07.fs(27,11,27,21): typecheck error FS0049: Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. +neg07.fs(27,11,27,21): typecheck error FS0049: Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. -neg07.fs(28,11,28,21): typecheck error FS0049: Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. +neg07.fs(28,11,28,21): typecheck error FS0049: Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. neg07.fs(28,11,28,21): typecheck error FS0026: This rule will never be matched neg07.fs(31,18,31,28): typecheck error FS0039: The value or constructor 'UnionCase1' is not defined. Maybe you want one of the following: X.UnionCase1 -neg07.fs(35,11,35,21): typecheck error FS0049: Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. +neg07.fs(35,11,35,21): typecheck error FS0049: Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. -neg07.fs(36,11,36,21): typecheck error FS0049: Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. +neg07.fs(36,11,36,21): typecheck error FS0049: Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. neg07.fs(36,11,36,21): typecheck error FS0026: This rule will never be matched From fea45d578d8d8e40b1b221be20cdb886800a520c Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 17 Oct 2024 09:16:10 +0100 Subject: [PATCH 10/49] comment id.idText.Length >= 3 to see what breaks --- src/Compiler/Checking/NameResolution.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index 1ebbf6cb5bf..5b400513fad 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -3394,7 +3394,7 @@ let rec ResolvePatternLongIdentPrim sink (ncenv: NameResolver) fullyQualified wa && warnOnUpper = WarnOnUpperCase // HACK: This is an historical hack that seems to related the use country and language codes, which are very common in codebases // Removing this check will cause a lot of new warnings/errors in existing codebases. - && id.idText.Length >= 3 + // && id.idText.Length >= 3 && System.Char.ToLowerInvariant id.idText[0] <> id.idText[0] then warning(UpperCaseIdentifierInPattern m) From 47c287e01342a5a85ff0275ca422c8b886ddbb52 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 17 Oct 2024 10:48:54 +0100 Subject: [PATCH 11/49] revert back the error message --- src/Compiler/FSStrings.resx | 2 +- src/Compiler/xlf/FSStrings.cs.xlf | 2 +- src/Compiler/xlf/FSStrings.de.xlf | 2 +- src/Compiler/xlf/FSStrings.es.xlf | 2 +- src/Compiler/xlf/FSStrings.fr.xlf | 2 +- src/Compiler/xlf/FSStrings.it.xlf | 2 +- src/Compiler/xlf/FSStrings.ja.xlf | 2 +- src/Compiler/xlf/FSStrings.ko.xlf | 2 +- src/Compiler/xlf/FSStrings.pl.xlf | 2 +- src/Compiler/xlf/FSStrings.pt-BR.xlf | 2 +- src/Compiler/xlf/FSStrings.ru.xlf | 2 +- src/Compiler/xlf/FSStrings.tr.xlf | 2 +- src/Compiler/xlf/FSStrings.zh-Hans.xlf | 2 +- src/Compiler/xlf/FSStrings.zh-Hant.xlf | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Compiler/FSStrings.resx b/src/Compiler/FSStrings.resx index 1a13a5b0d83..383b4991105 100644 --- a/src/Compiler/FSStrings.resx +++ b/src/Compiler/FSStrings.resx @@ -166,7 +166,7 @@ Type constraint mismatch. The type \n '{0}' \nis not compatible with type\n '{1}' {2}\n - Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. Discriminated union cases and exception labels must be uppercase identifiers diff --git a/src/Compiler/xlf/FSStrings.cs.xlf b/src/Compiler/xlf/FSStrings.cs.xlf index 0a6d8986d86..20b53f76f45 100644 --- a/src/Compiler/xlf/FSStrings.cs.xlf +++ b/src/Compiler/xlf/FSStrings.cs.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. Identifikátory proměnných psané velkými písmeny se ve vzorech obecně nedoporučují. Můžou označovat chybějící otevřenou deklaraci nebo špatně napsaný název vzoru. diff --git a/src/Compiler/xlf/FSStrings.de.xlf b/src/Compiler/xlf/FSStrings.de.xlf index 8659a200bf3..f58d3a4711d 100644 --- a/src/Compiler/xlf/FSStrings.de.xlf +++ b/src/Compiler/xlf/FSStrings.de.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. Variablenbezeichner in Großbuchstaben sollten im Allgemeinen nicht in Mustern verwendet werden und können ein Hinweis auf eine fehlende open-Deklaration oder einen falsch geschriebenen Musternamen sein. diff --git a/src/Compiler/xlf/FSStrings.es.xlf b/src/Compiler/xlf/FSStrings.es.xlf index 39f65153fe2..88a130d699d 100644 --- a/src/Compiler/xlf/FSStrings.es.xlf +++ b/src/Compiler/xlf/FSStrings.es.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. En general, los identificadores de variables en mayúscula no deben usarse en patrones y pueden indicar una declaración abierta que falta o un nombre de patrón mal escrito. diff --git a/src/Compiler/xlf/FSStrings.fr.xlf b/src/Compiler/xlf/FSStrings.fr.xlf index e16203f001e..7d7badde4ed 100644 --- a/src/Compiler/xlf/FSStrings.fr.xlf +++ b/src/Compiler/xlf/FSStrings.fr.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. Les identificateurs de variables en majuscules ne doivent généralement pas être utilisés dans les modèles. Ils peuvent indiquer une absence de déclaration open ou un nom de modèle mal orthographié. diff --git a/src/Compiler/xlf/FSStrings.it.xlf b/src/Compiler/xlf/FSStrings.it.xlf index 62b359aea5a..f43c8e77851 100644 --- a/src/Compiler/xlf/FSStrings.it.xlf +++ b/src/Compiler/xlf/FSStrings.it.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. In genere è consigliabile non usare identificatori di variabili scritti in maiuscolo nei criteri perché potrebbero indicare una dichiarazione OPEN mancante o un nome di criterio con ortografia errata. diff --git a/src/Compiler/xlf/FSStrings.ja.xlf b/src/Compiler/xlf/FSStrings.ja.xlf index 540ee8c1c60..6f0a3a978e9 100644 --- a/src/Compiler/xlf/FSStrings.ja.xlf +++ b/src/Compiler/xlf/FSStrings.ja.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. 通常、大文字の変数識別子はパターンに使用できません。また、欠落している open 宣言か、つづりが間違っているパターン名を示す可能性があります。 diff --git a/src/Compiler/xlf/FSStrings.ko.xlf b/src/Compiler/xlf/FSStrings.ko.xlf index 1a3c33e09a6..43e0a0f1739 100644 --- a/src/Compiler/xlf/FSStrings.ko.xlf +++ b/src/Compiler/xlf/FSStrings.ko.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. 일반적으로 대문자 변수 식별자는 패턴에 사용하지 말아야 합니다. 이러한 식별자는 열려 있는 선언이 없거나 철자가 잘못된 패턴 이름을 나타낼 수 있습니다. diff --git a/src/Compiler/xlf/FSStrings.pl.xlf b/src/Compiler/xlf/FSStrings.pl.xlf index 68e3372e849..3096fca8dbf 100644 --- a/src/Compiler/xlf/FSStrings.pl.xlf +++ b/src/Compiler/xlf/FSStrings.pl.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. Identyfikatory zmiennych pisane wielkimi literami nie powinny być na ogół używane we wzorcach i mogą oznaczać brak deklaracji otwierającej lub błąd pisowni w nazwie wzorca. diff --git a/src/Compiler/xlf/FSStrings.pt-BR.xlf b/src/Compiler/xlf/FSStrings.pt-BR.xlf index 4ef7ff5191a..ea48f4c3545 100644 --- a/src/Compiler/xlf/FSStrings.pt-BR.xlf +++ b/src/Compiler/xlf/FSStrings.pt-BR.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. Identificadores de variáveis em maiúsculas geralmente não devem ser usados em padrões, podendo indicar uma declaração aberta ausente ou um nome de padrão escrito incorretamente. diff --git a/src/Compiler/xlf/FSStrings.ru.xlf b/src/Compiler/xlf/FSStrings.ru.xlf index 59157c19176..7cb20b5e8de 100644 --- a/src/Compiler/xlf/FSStrings.ru.xlf +++ b/src/Compiler/xlf/FSStrings.ru.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. Идентификаторы переменных в верхнем регистре обычно не должны использоваться в шаблонах, и могут указывать на отсутствующую открытую декларацию или неправильно написанное имя шаблона. diff --git a/src/Compiler/xlf/FSStrings.tr.xlf b/src/Compiler/xlf/FSStrings.tr.xlf index c31daa04a7d..9c65fabe248 100644 --- a/src/Compiler/xlf/FSStrings.tr.xlf +++ b/src/Compiler/xlf/FSStrings.tr.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. Büyük harfli değişken tanımlayıcıları desenlerde genel olarak kullanılmamalıdır. Bunlar, eksik bir açık bildirimin veya yanlış yazılmış bir desen adının göstergesi olabilirler. diff --git a/src/Compiler/xlf/FSStrings.zh-Hans.xlf b/src/Compiler/xlf/FSStrings.zh-Hans.xlf index 2ed587848a9..c895f08ec60 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hans.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hans.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. 通常不得在模式中使用大写的变量标识符,存在它们可能表示缺少某个开放声明或某个模式名称拼写错误。 diff --git a/src/Compiler/xlf/FSStrings.zh-Hant.xlf b/src/Compiler/xlf/FSStrings.zh-Hant.xlf index 9a33caffe94..d81a539866e 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hant.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hant.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name. + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. 通常不應在樣式中使用大寫的變數識別碼。這可能表示缺少公開宣告或樣式名稱拼字錯誤。 From 885b5abf0f2541272262a7de7d598407756e574c Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 17 Oct 2024 18:56:15 +0100 Subject: [PATCH 12/49] update tests --- .../BindingExpressions/BindingExpressions.fs | 8 +------- .../E_UpperBindingPattern.fs | 4 ++-- .../PatternMatching/Simple/Simple.fs | 4 ++-- .../PatternMatching/Union/Union.fs | 19 +++++++++++++------ 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs index 0ac8a7d28d4..ff2b193df4c 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs @@ -153,12 +153,6 @@ module BindingExpressions = |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 6, Col 23, Line 6, Col 26, "Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name.") - (Error 30, Line 2, Col 9, Line 2, Col 32, "Value restriction. The value 'CallGenericStaticMethod' has been inferred to have generic type - val CallGenericStaticMethod: ('_a -> '_b) -Either make the arguments to 'CallGenericStaticMethod' explicit or, if you do not intend for it to be generic, add a type annotation.") - (Error 30, Line 4, Col 9, Line 4, Col 32, "Value restriction. The value 'MakeGenericStaticMethod' has been inferred to have generic type - val MakeGenericStaticMethod: ('_a -> '_b) -Either make the arguments to 'MakeGenericStaticMethod' explicit or, if you do not intend for it to be generic, add a type annotation.") + (Warning 49, Line 6, Col 23, Line 6, Col 26, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern.fs index 01a6fe5e539..04e2fae4e0c 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern.fs @@ -1,6 +1,6 @@ module One = - let CallGenericStaticMethod = failwithf "CallGenericStaticMethod" + let CallGenericStaticMethod x = failwithf "CallGenericStaticMethod" - let MakeGenericStaticMethod = failwithf "MakeGenericStaticMethod" + let MakeGenericStaticMethod x = failwithf "MakeGenericStaticMethod" let MakersCallers FSS = CallGenericStaticMethod FSS, MakeGenericStaticMethod FSS \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs index de3dea01a9c..0345a41a4dc 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs @@ -45,8 +45,8 @@ module Simple = |> compile |> shouldFail |> withDiagnostics [ - (Warning 49, Line 9, Col 16, Line 9, Col 19, "Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name.") - (Warning 49, Line 10, Col 16, Line 10, Col 19, "Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name.") + (Warning 49, Line 9, Col 16, Line 9, Col 19, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 10, Col 16, Line 10, Col 19, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs index ba009627c06..9d247bb6ab6 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs @@ -217,7 +217,10 @@ but here has type |> asFs |> withOptions ["--test:ErrorRanges"] |> typecheck - |> shouldSucceed + |> shouldFail + |> withDiagnostics [ + (Warning 49, Line 14, Col 7, Line 14, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + ] [] let ``Union - E_UnionPattern13_fs - --test:ErrorRanges`` compilation = @@ -226,7 +229,7 @@ but here has type |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldFail - |> withSingleDiagnostic (Warning 49, Line 14, Col 7, Line 14, Col 10, "Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name.") + |> withSingleDiagnostic (Warning 49, Line 14, Col 7, Line 14, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") [] let ``Union - E_UnionPattern14_fs - --test:ErrorRanges`` compilation = @@ -236,7 +239,7 @@ but here has type |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 11, Col 7, Line 11, Col 10, "Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name.") + (Warning 49, Line 11, Col 7, Line 11, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") (Warning 26, Line 11, Col 7, Line 11, Col 10, "This rule will never be matched") (Warning 26, Line 12, Col 7, Line 12, Col 10, "This rule will never be matched") ] @@ -249,8 +252,10 @@ but here has type |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 12, Col 7, Line 12, Col 10, "Uppercase variable identifiers with 3 or more characters should not generally be used in patterns, and may indicate a missing open declaration, require qualified access or a misspelt pattern name.") - (Warning 26, Line 11, Col 7, Line 11, Col 9, "This rule will never be matched") + (Warning 49, Line 10, Col 7, Line 10, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 11, Col 7, Line 11, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 12, Col 7, Line 12, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 26, Line 11, Col 7, Line 11, Col 9, "This rule will never be matched"); (Warning 26, Line 12, Col 7, Line 12, Col 10, "This rule will never be matched") ] @@ -262,6 +267,8 @@ but here has type |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 26, Line 11, Col 7, Line 11, Col 9, "This rule will never be matched") + (Warning 49, Line 10, Col 7, Line 10, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 11, Col 7, Line 11, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 26, Line 11, Col 7, Line 11, Col 9, "This rule will never be matched"); (Warning 26, Line 12, Col 7, Line 12, Col 10, "This rule will never be matched") ] \ No newline at end of file From bd76c9d3f32c7a750cf27762996c59044c102a1c Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 17 Oct 2024 19:28:12 +0100 Subject: [PATCH 13/49] release notes --- docs/release-notes/.FSharp.Compiler.Service/9.0.200.md | 1 + docs/release-notes/.FSharp.Core/9.0.200.md | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 docs/release-notes/.FSharp.Core/9.0.200.md diff --git a/docs/release-notes/.FSharp.Compiler.Service/9.0.200.md b/docs/release-notes/.FSharp.Compiler.Service/9.0.200.md index a7d549b23bd..89629240756 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/9.0.200.md +++ b/docs/release-notes/.FSharp.Compiler.Service/9.0.200.md @@ -22,5 +22,6 @@ * Better ranges for CE `use` error reporting. ([PR #17811](https://github.com/dotnet/fsharp/pull/17811)) * Better ranges for `inherit` error reporting. ([PR #17879](https://github.com/dotnet/fsharp/pull/17879)) * Better ranges for `inherit` `struct` error reporting. ([PR #17886](https://github.com/dotnet/fsharp/pull/17886)) +* Warn on uppercase identifiers in patterns. ([PR #15816](https://github.com/dotnet/fsharp/pull/15816)) ### Breaking Changes diff --git a/docs/release-notes/.FSharp.Core/9.0.200.md b/docs/release-notes/.FSharp.Core/9.0.200.md new file mode 100644 index 00000000000..07d2454340e --- /dev/null +++ b/docs/release-notes/.FSharp.Core/9.0.200.md @@ -0,0 +1,9 @@ +### Fixed + +### Added + +### Fixed +* Warn on uppercase identifiers in patterns. ([PR #15816](https://github.com/dotnet/fsharp/pull/15816)) + +### Breaking Changes + From d68843e460ae86db0fc11eab095786fe7c2ef7d4 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 17 Oct 2024 19:28:45 +0100 Subject: [PATCH 14/49] Add LanguageFeature flag --- src/Compiler/FSComp.txt | 3 ++- src/Compiler/Facilities/LanguageFeatures.fs | 4 +++- 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, 71 insertions(+), 2 deletions(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index b5a50afc7c0..b23c81ff4f5 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1783,4 +1783,5 @@ featureEmptyBodiedComputationExpressions,"Support for computation expressions wi featureAllowAccessModifiersToAutoPropertiesGettersAndSetters,"Allow access modifiers to auto properties getters and setters" 3871,tcAccessModifiersNotAllowedInSRTPConstraint,"Access modifiers cannot be applied to an SRTP constraint." featureAllowObjectExpressionWithoutOverrides,"Allow object expressions without overrides" -3872,tcPartialActivePattern,"Multi-case partial active patterns are not supported. Consider using a single-case partial active pattern or a full active pattern." \ No newline at end of file +3872,tcPartialActivePattern,"Multi-case partial active patterns are not supported. Consider using a single-case partial active pattern or a full active pattern." +featureWarnOnUppercaseIdentifiersInPatterns,"Warn on uppercase identifiers in patterns" \ No newline at end of file diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 5c311237594..32d1328ac2b 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -94,6 +94,7 @@ type LanguageFeature = | ParsedHashDirectiveArgumentNonQuotes | EmptyBodiedComputationExpressions | AllowObjectExpressionWithoutOverrides + | WarnOnUppercaseIdentifiersInPatterns /// LanguageVersion management type LanguageVersion(versionText) = @@ -219,6 +220,7 @@ type LanguageVersion(versionText) = LanguageFeature.FromEndSlicing, previewVersion // Unfinished features --- needs work LanguageFeature.AllowAccessModifiersToAutoPropertiesGettersAndSetters, previewVersion LanguageFeature.AllowObjectExpressionWithoutOverrides, previewVersion + LanguageFeature.WarnOnUppercaseIdentifiersInPatterns, previewVersion ] static let defaultLanguageVersion = LanguageVersion("default") @@ -375,7 +377,7 @@ type LanguageVersion(versionText) = | LanguageFeature.ParsedHashDirectiveArgumentNonQuotes -> FSComp.SR.featureParsedHashDirectiveArgumentNonString () | LanguageFeature.EmptyBodiedComputationExpressions -> FSComp.SR.featureEmptyBodiedComputationExpressions () | LanguageFeature.AllowObjectExpressionWithoutOverrides -> FSComp.SR.featureAllowObjectExpressionWithoutOverrides () - + | LanguageFeature.WarnOnUppercaseIdentifiersInPatterns -> FSComp.SR.featureWarnOnUppercaseIdentifiersInPatterns () /// Get a version string associated with the given feature. static member GetFeatureVersionString feature = match features.TryGetValue feature with diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index 7408300b943..a458a185985 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -85,6 +85,7 @@ type LanguageFeature = | ParsedHashDirectiveArgumentNonQuotes | EmptyBodiedComputationExpressions | AllowObjectExpressionWithoutOverrides + | WarnOnUppercaseIdentifiersInPatterns /// LanguageVersion management type LanguageVersion = diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 958a1357ac9..08ac9534d4e 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -612,6 +612,11 @@ Interoperabilita mezi neřízeným obecným omezením jazyka C# a F# (emitovat další modreq) + + Warn on uppercase identifiers in patterns + Warn on uppercase identifiers in patterns + + Indexed properties getter and setter must have the same type Metoda getter a setter indexované vlastnosti musí mít stejný typ. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index d7233a5d2fc..b131e235c04 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -612,6 +612,11 @@ Interop zwischen nicht verwalteter generischer Einschränkung in C# und F# (zusätzlicher ModReq ausgeben) + + Warn on uppercase identifiers in patterns + Warn on uppercase identifiers in patterns + + Indexed properties getter and setter must have the same type Getter und Setter für indizierte Eigenschaften müssen denselben Typ aufweisen. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 1b3205ffa53..59739194825 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -612,6 +612,11 @@ Interoperabilidad entre la restricción genérica no administrada de C# y F# (emitir modreq adicional) + + Warn on uppercase identifiers in patterns + Warn on uppercase identifiers in patterns + + Indexed properties getter and setter must have the same type El captador y el establecedor de propiedades indexadas deben tener el mismo tipo. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 018180a8fb6..4916d372d3d 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -612,6 +612,11 @@ Interopérabilité entre les contraintes génériques non gérées de C# et F# (émettre un modreq supplémentaire) + + Warn on uppercase identifiers in patterns + Warn on uppercase identifiers in patterns + + Indexed properties getter and setter must have the same type Les propriétés indexées getter et setter doivent avoir le même type diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 7cc3f46259b..e1dc63bb73c 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -612,6 +612,11 @@ Interoperabilità tra il vincolo generico non gestito di C# e di F# (crea un modreq aggiuntivo) + + Warn on uppercase identifiers in patterns + Warn on uppercase identifiers in patterns + + Indexed properties getter and setter must have the same type Il getter e il setter delle proprietà indicizzate devono avere lo stesso tipo diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 10c5f06f4ff..8949d642ec0 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -612,6 +612,11 @@ C# と F# のアンマネージド ジェネリック制約の間の相互運用 (追加の modreq を出力) + + Warn on uppercase identifiers in patterns + Warn on uppercase identifiers in patterns + + Indexed properties getter and setter must have the same type インデックス付きプロパティのゲッターとセッターの型は同じである必要があります diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 94cd344f052..90262567050 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -612,6 +612,11 @@ C#과 F#의 관리되지 않는 제네릭 제약 조건 간의 Interop(추가 modreq 내보내기) + + Warn on uppercase identifiers in patterns + Warn on uppercase identifiers in patterns + + Indexed properties getter and setter must have the same type 인덱싱된 속성 getter와 setter의 형식이 같아야 합니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 01f2ff1d5e3..c075c3eaca3 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -612,6 +612,11 @@ Międzyoperacyjnie między niezarządzanym ograniczeniem ogólnym języka C# i F# (emituj dodatkowe modreq) + + Warn on uppercase identifiers in patterns + Warn on uppercase identifiers in patterns + + Indexed properties getter and setter must have the same type Metoda pobierająca i metoda ustawiająca właściwości indeksowanych muszą mieć taki sam typ. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 63da6a667b1..590bcc7eefa 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -612,6 +612,11 @@ Interoperabilidade entre a restrição genérica não gerenciada de C# e F# (emitir modreq adicional) + + Warn on uppercase identifiers in patterns + Warn on uppercase identifiers in patterns + + Indexed properties getter and setter must have the same type As propriedades indexadas getter e setter devem ter o mesmo tipo diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 231bc83103b..f91ad4076c1 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -612,6 +612,11 @@ Взаимодействие между универсальным ограничением "unmanaged" C# и F#(создание дополнительного modreq) + + Warn on uppercase identifiers in patterns + Warn on uppercase identifiers in patterns + + Indexed properties getter and setter must have the same type Методы получения и установки индексированных свойств должны иметь один и тот же тип. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index a3bab7e5a92..eb9c4063a48 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -612,6 +612,11 @@ C# ile F#' arasında yönetilmeyen genel kısıtlama (ek modreq yayın) + + Warn on uppercase identifiers in patterns + Warn on uppercase identifiers in patterns + + Indexed properties getter and setter must have the same type Dizini oluşturulmuş özelliklerin alıcısı ve ayarlayıcısı aynı türde olmalıdır diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 579ac9b79c3..788f2e161b2 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -612,6 +612,11 @@ C# 和 F# 的非托管泛型约束之间的互操作(发出额外的 modreq) + + Warn on uppercase identifiers in patterns + Warn on uppercase identifiers in patterns + + Indexed properties getter and setter must have the same type 索引属性 getter 和 setter 必须具有相同的类型 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 09818a7487b..14b127d417e 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -612,6 +612,11 @@ C# 與 F# 的非受控泛型條件約束之間的 Interop (發出額外的 modreq) + + Warn on uppercase identifiers in patterns + Warn on uppercase identifiers in patterns + + Indexed properties getter and setter must have the same type 索引屬性 getter 和 setter 必須具有相同的類型 From 110d41762b5e1e7f131efa164cb6aa34c4fb1924 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 17 Oct 2024 19:29:02 +0100 Subject: [PATCH 15/49] release notes --- docs/release-notes/.Language/preview.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/.Language/preview.md b/docs/release-notes/.Language/preview.md index b18d08e30c3..b5e8582c341 100644 --- a/docs/release-notes/.Language/preview.md +++ b/docs/release-notes/.Language/preview.md @@ -3,5 +3,6 @@ * Better generic unmanaged structs handling. ([Language suggestion #692](https://github.com/fsharp/fslang-suggestions/issues/692), [PR #12154](https://github.com/dotnet/fsharp/pull/12154)) ### Fixed +* Warn on uppercase identifiers in patterns. ([PR #15816](https://github.com/dotnet/fsharp/pull/15816)) ### Changed From 7bf51635531be1e9d2f84bc7b1b7a2dd832bd6aa Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 17 Oct 2024 20:41:54 +0100 Subject: [PATCH 16/49] format code --- src/Compiler/Facilities/LanguageFeatures.fs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 32d1328ac2b..f22d5b9a60b 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -378,6 +378,7 @@ type LanguageVersion(versionText) = | LanguageFeature.EmptyBodiedComputationExpressions -> FSComp.SR.featureEmptyBodiedComputationExpressions () | LanguageFeature.AllowObjectExpressionWithoutOverrides -> FSComp.SR.featureAllowObjectExpressionWithoutOverrides () | LanguageFeature.WarnOnUppercaseIdentifiersInPatterns -> FSComp.SR.featureWarnOnUppercaseIdentifiersInPatterns () + /// Get a version string associated with the given feature. static member GetFeatureVersionString feature = match features.TryGetValue feature with From 7934bf3a6bbea8d6f06a75cba98e977a43166baf Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 17 Oct 2024 22:21:46 +0100 Subject: [PATCH 17/49] reduce diff --- .../Conformance/PatternMatching/Simple/Simple.fs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs index 0345a41a4dc..3cd93d8c562 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs @@ -357,4 +357,5 @@ match CaseA with |> shouldFail |> withDiagnostics [ Warning 104, Line 10, Col 7, Line 10, Col 12, "Enums may take values outside known cases. For example, the value 'CaseB (enum (0))' may indicate a case not covered by the pattern(s)." - Warning 25, Line 10, Col 7, Line 10, Col 12, "Incomplete pattern matches on this expression. For example, the value 'CaseA' may indicate a case not covered by the pattern(s)."] \ No newline at end of file + Warning 25, Line 10, Col 7, Line 10, Col 12, "Incomplete pattern matches on this expression. For example, the value 'CaseA' may indicate a case not covered by the pattern(s)."] + \ No newline at end of file From 1554db9f5db39e8f6e2fc329a41f2078d7b09278 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 17 Oct 2024 23:33:57 +0100 Subject: [PATCH 18/49] LanguageFeature.WarnOnUppercaseIdentifiersInPatterns --- .../Checking/Expressions/CheckExpressions.fs | 8 +- src/Compiler/Checking/NameResolution.fs | 17 +-- .../BindingExpressions/BindingExpressions.fs | 113 +++++++++++++++++- .../E_UpperBindingPattern.fs | 9 +- .../E_UpperBindingPattern02.fs | 5 + .../E_UpperBindingPattern03.fs | 13 ++ .../E_UpperBindingPattern04.fs | 9 ++ .../PatternMatching/Union/E_UnionPattern12.fs | 23 ++-- .../PatternMatching/Union/E_UnionPattern13.fs | 21 ++-- .../PatternMatching/Union/E_UnionPattern14.fs | 12 -- .../PatternMatching/Union/E_UnionPattern15.fs | 12 -- .../PatternMatching/Union/E_UnionPattern16.fs | 12 -- .../PatternMatching/Union/Union.fs | 64 +++++----- 13 files changed, 213 insertions(+), 105 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern03.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern04.fs delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern14.fs delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern15.fs delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern16.fs diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index 30375d047f4..2fd36d124ab 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -2515,8 +2515,12 @@ module BindingNormalization = match memberFlagsOpt with | None -> let extraDot = if synLongId.ThereIsAnExtraDotAtTheEnd then ExtraDotAfterIdentifier.Yes else ExtraDotAfterIdentifier.No - - match ResolvePatternLongIdent cenv.tcSink nameResolver AllIdsOK true m ad env.NameEnv TypeNameResolutionInfo.Default longId extraDot with + let warnOnUpper = + if not args.IsEmpty then + WarnOnUpperCase + else AllIdsOK + + match ResolvePatternLongIdent cenv.tcSink nameResolver warnOnUpper true m ad env.NameEnv TypeNameResolutionInfo.Default longId extraDot with | Item.NewDef id -> if id.idText = opNameCons then NormalizedBindingPat(pat, rhsExpr, valSynData, typars) diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index 5b400513fad..c7fece074ea 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -3389,15 +3389,18 @@ let rec ResolvePatternLongIdentPrim sink (ncenv: NameResolver) fullyQualified wa | true, res when not newDef -> ResolveUnqualifiedItem ncenv nenv m res | _ -> // Single identifiers in patterns - variable bindings - if - not newDef - && warnOnUpper = WarnOnUpperCase - // HACK: This is an historical hack that seems to related the use country and language codes, which are very common in codebases - // Removing this check will cause a lot of new warnings/errors in existing codebases. - // && id.idText.Length >= 3 - && System.Char.ToLowerInvariant id.idText[0] <> id.idText[0] + let supportsWarnOnUpperIdentifiersInPatterns = ncenv.g.langVersion.SupportsFeature(LanguageFeature.WarnOnUppercaseIdentifiersInPatterns) && warnOnUpper = WarnOnUpperCase + if (supportsWarnOnUpperIdentifiersInPatterns && not newDef && System.Char.ToLowerInvariant id.idText[0] <> id.idText[0]) then warning(UpperCaseIdentifierInPattern m) + else + if not newDef + && warnOnUpper = WarnOnUpperCase + // HACK: This is an historical hack that seems to related the use country and language codes, which are very common in codebases + && id.idText.Length >= 3 + && System.Char.ToLowerInvariant id.idText[0] <> id.idText[0] + then + warning(UpperCaseIdentifierInPattern m) // If there's an extra dot, we check whether the single identifier is a union, module or namespace and report it to the sink for the sake of tooling match extraDotAtTheEnd with diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs index ff2b193df4c..4ed504872df 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs @@ -147,12 +147,123 @@ module BindingExpressions = [] let ``E_UpperBindingPattern_fs`` compilation = + compilation + |> asExe + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + [] + let ``E_UpperBindingPattern_fs preview`` compilation = + compilation + |> asExe + |> withLangVersionPreview + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 49, Line 3, Col 7, Line 3, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 3, Col 10, Line 3, Col 12, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 5, Col 8, Line 5, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 5, Col 11, Line 5, Col 13, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 7, Col 8, Line 7, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 7, Col 10, Line 7, Col 11, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + ] + + + [] + let ``E_UpperBindingPattern02_fs`` compilation = compilation |> asExe |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 6, Col 23, Line 6, Col 26, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 3, Col 7, Line 3, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 3, Col 11, Line 3, Col 14, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 5, Col 8, Line 5, Col 11, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 5, Col 12, Line 5, Col 15, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + ] + + [] + let ``E_UpperBindingPattern02_fs preview`` compilation = + compilation + |> withLangVersionPreview + |> asExe + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 49, Line 3, Col 7, Line 3, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 3, Col 11, Line 3, Col 14, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 5, Col 8, Line 5, Col 11, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 5, Col 12, Line 5, Col 15, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] + [] + let ``E_UpperBindingPattern03_fs`` compilation = + compilation + |> asExe + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + [] + let ``E_UpperBindingPattern03_fs preview`` compilation = + compilation + |> withLangVersionPreview + |> asExe + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 49, Line 2, Col 21, Line 2, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 2, Col 25, Line 2, Col 27, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 4, Col 22, Line 4, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 4, Col 25, Line 4, Col 27, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 6, Col 22, Line 6, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 6, Col 24, Line 6, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 9, Col 19, Line 9, Col 21, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 9, Col 23, Line 9, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 11, Col 20, Line 11, Col 22, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 11, Col 23, Line 11, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 13, Col 20, Line 13, Col 21, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 13, Col 22, Line 13, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + ] + + [] + let ``E_UpperBindingPattern04_fs`` compilation = + compilation + |> asExe + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 49, Line 2, Col 21, Line 2, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 2, Col 26, Line 2, Col 29, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 4, Col 22, Line 4, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 4, Col 26, Line 4, Col 29, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 7, Col 19, Line 7, Col 22, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 7, Col 24, Line 7, Col 27, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 9, Col 20, Line 9, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 9, Col 24, Line 9, Col 27, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + ] + + [] + let ``E_UpperBindingPattern04_fs preview`` compilation = + compilation + |> withLangVersionPreview + |> asExe + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 49, Line 2, Col 21, Line 2, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 2, Col 26, Line 2, Col 29, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 4, Col 22, Line 4, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 4, Col 26, Line 4, Col 29, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 7, Col 19, Line 7, Col 22, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 7, Col 24, Line 7, Col 27, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 9, Col 20, Line 9, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 9, Col 24, Line 9, Col 27, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern.fs index 04e2fae4e0c..a1a009db8e1 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern.fs @@ -1,6 +1,7 @@ -module One = - let CallGenericStaticMethod x = failwithf "CallGenericStaticMethod" +let Aaa = () - let MakeGenericStaticMethod x = failwithf "MakeGenericStaticMethod" +let f Us Uk = () - let MakersCallers FSS = CallGenericStaticMethod FSS, MakeGenericStaticMethod FSS \ No newline at end of file +let f2 US CA = () + +let f3 U A = () \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern02.fs new file mode 100644 index 00000000000..3fe517cea70 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern02.fs @@ -0,0 +1,5 @@ +let AAA = () + +let f USA CAN = () + +let f3 Usa Can = () \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern03.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern03.fs new file mode 100644 index 00000000000..1b313e9eb56 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern03.fs @@ -0,0 +1,13 @@ +type Class() = + static member f(Us, Uk) = () + + static member f2 US CA = () + + static member f3 U A = () + +type Class2() = + member this.f(Us, Uk) = () + + member this.f2 US CA = () + + member this.f3 U A = () \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern04.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern04.fs new file mode 100644 index 00000000000..d161cc773cb --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern04.fs @@ -0,0 +1,9 @@ +type Class() = + static member f(USA, CAN) = () + + static member f2 Usa Can = () + +type Class2() = + member this.f(USA, CAN) = () + + member this.f2 Usa Can = () \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern12.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern12.fs index 2b5adefd762..aab6e2e0ac0 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern12.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern12.fs @@ -1,14 +1,11 @@ -module DUs = - type Countries = - | CA - | US - | GB -let x = DUs.CA - -open DUs - -let output = - match x with +let x = + match 1 with | US -> "US" - | CA -> "CA" - | U -> "U" \ No newline at end of file + | UK -> "UK" + | U -> "U" + +let y = + match 2 with + | Us -> "Us" + | Uk -> "Uk" + | U -> "u" \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern13.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern13.fs index 5cae82bd391..ed92b3e2951 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern13.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern13.fs @@ -1,14 +1,9 @@ -module DUs = - type Countries = - | CA - | US - | GB -let x = DUs.CA +let x = + match 1 with + | USA -> "USA" + | CAN -> "CAN" -open DUs - -let output = - match x with - | US -> "US" - | CA -> "CA" - | UUU -> "U" \ No newline at end of file +let y = + match 2 with + | Usa -> "Usa" + | Can -> "Can" diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern14.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern14.fs deleted file mode 100644 index f1302481c7e..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern14.fs +++ /dev/null @@ -1,12 +0,0 @@ -module DUs = - type Countries = - | CA - | US - | GB -let x = DUs.CA - -let output = - match x with - | uSA -> "US" - | AAA -> "CA" - | uuu -> "U" \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern15.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern15.fs deleted file mode 100644 index 343f84f4a66..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern15.fs +++ /dev/null @@ -1,12 +0,0 @@ -module DUs = - type Countries = - | CA - | US - | GB -let x = DUs.CA - -let output = - match x with - | US -> "US" - | CA -> "CA" - | UUU -> "U" \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern16.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern16.fs deleted file mode 100644 index 11c9c43f144..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern16.fs +++ /dev/null @@ -1,12 +0,0 @@ -module DUs = - type Countries = - | CA - | US - | GB -let x = DUs.CA - -let output = - match x with - | US -> "US" - | CA -> "CA" - | uuu -> "U" \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs index 9d247bb6ab6..b0ae835be98 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs @@ -219,56 +219,62 @@ but here has type |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 14, Col 7, Line 14, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 26, Line 4, Col 7, Line 4, Col 9, "This rule will never be matched") + (Warning 26, Line 5, Col 7, Line 5, Col 8, "This rule will never be matched") + (Warning 26, Line 10, Col 7, Line 10, Col 9, "This rule will never be matched") + (Warning 26, Line 11, Col 7, Line 11, Col 8, "This rule will never be matched") ] - [] - let ``Union - E_UnionPattern13_fs - --test:ErrorRanges`` compilation = - compilation - |> asFs - |> withOptions ["--test:ErrorRanges"] - |> typecheck - |> shouldFail - |> withSingleDiagnostic (Warning 49, Line 14, Col 7, Line 14, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - - [] - let ``Union - E_UnionPattern14_fs - --test:ErrorRanges`` compilation = + [] + let ``Union - E_UnionPattern12_fs preview - --test:ErrorRanges`` compilation = compilation + |> withLangVersionPreview |> asFs |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 11, Col 7, Line 11, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 26, Line 11, Col 7, Line 11, Col 10, "This rule will never be matched") - (Warning 26, Line 12, Col 7, Line 12, Col 10, "This rule will never be matched") + (Warning 49, Line 3, Col 7, Line 3, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 4, Col 7, Line 4, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 5, Col 7, Line 5, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 26, Line 4, Col 7, Line 4, Col 9, "This rule will never be matched") + (Warning 26, Line 5, Col 7, Line 5, Col 8, "This rule will never be matched") + (Warning 49, Line 9, Col 7, Line 9, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 10, Col 7, Line 10, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 11, Col 7, Line 11, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 26, Line 10, Col 7, Line 10, Col 9, "This rule will never be matched") + (Warning 26, Line 11, Col 7, Line 11, Col 8, "This rule will never be matched") ] - [] - let ``Union - E_UnionPattern15_fs - --test:ErrorRanges`` compilation = + [] + let ``Union - E_UnionPattern13_fs - --test:ErrorRanges`` compilation = compilation |> asFs |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 10, Col 7, Line 10, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 11, Col 7, Line 11, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 12, Col 7, Line 12, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 26, Line 11, Col 7, Line 11, Col 9, "This rule will never be matched"); - (Warning 26, Line 12, Col 7, Line 12, Col 10, "This rule will never be matched") + (Warning 49, Line 3, Col 7, Line 3, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 4, Col 7, Line 4, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 26, Line 4, Col 7, Line 4, Col 10, "This rule will never be matched") + (Warning 49, Line 8, Col 7, Line 8, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 9, Col 7, Line 9, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 26, Line 9, Col 7, Line 9, Col 10, "This rule will never be matched") ] - [] - let ``Union - E_UnionPattern16_fs - --test:ErrorRanges`` compilation = + [] + let ``Union - E_UnionPattern13_fs preview- --test:ErrorRanges`` compilation = compilation + |> withLangVersionPreview |> asFs |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 10, Col 7, Line 10, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 11, Col 7, Line 11, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 26, Line 11, Col 7, Line 11, Col 9, "This rule will never be matched"); - (Warning 26, Line 12, Col 7, Line 12, Col 10, "This rule will never be matched") - ] \ No newline at end of file + (Warning 49, Line 3, Col 7, Line 3, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 4, Col 7, Line 4, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 26, Line 4, Col 7, Line 4, Col 10, "This rule will never be matched") + (Warning 49, Line 8, Col 7, Line 8, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 9, Col 7, Line 9, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 26, Line 9, Col 7, Line 9, Col 10, "This rule will never be matched") + ] From b01b95737f671ab81ffb297b1f9b111a142f770e Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Fri, 25 Oct 2024 10:18:04 +0100 Subject: [PATCH 19/49] simplify tests --- .../BindingExpressions/BindingExpressions.fs | 154 ++++++------------ .../E_UpperBindingPattern.fs | 7 - .../E_UpperBindingPattern02.fs | 5 - .../E_UpperBindingPattern03.fs | 13 -- .../E_UpperBindingPattern04.fs | 9 - .../BindingExpressions/UpperBindingPattern.fs | 34 ++++ .../PatternMatching/Union/E_UnionPattern12.fs | 11 -- .../PatternMatching/Union/E_UnionPattern13.fs | 9 - .../PatternMatching/Union/Union.fs | 51 ++---- .../Union/UpperUnionCasePattern.fs | 20 +++ 10 files changed, 114 insertions(+), 199 deletions(-) delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern.fs delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern02.fs delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern03.fs delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern04.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern12.fs delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern13.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs index 4ed504872df..e1264fd0a12 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs @@ -144,126 +144,66 @@ module BindingExpressions = |> withDiagnostics [ (Warning 64, Line 10, Col 32, Line 10, Col 33, "This construct causes code to be less generic than indicated by the type annotations. The type variable 'b has been constrained to be type ''a'.") ] - - [] - let ``E_UpperBindingPattern_fs`` compilation = + + [] + let ``UpperBindingPattern_fs`` compilation = compilation |> asExe |> withOptions ["--test:ErrorRanges"] |> typecheck - |> shouldSucceed - - [] - let ``E_UpperBindingPattern_fs preview`` compilation = - compilation - |> asExe - |> withLangVersionPreview - |> withOptions ["--test:ErrorRanges"] - |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 3, Col 7, Line 3, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 3, Col 10, Line 3, Col 12, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 5, Col 8, Line 5, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 5, Col 11, Line 5, Col 13, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 7, Col 8, Line 7, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 7, Col 10, Line 7, Col 11, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 11, Col 8, Line 11, Col 11, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 11, Col 12, Line 11, Col 15, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 13, Col 8, Line 13, Col 11, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 13, Col 12, Line 13, Col 15, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 22, Col 22, Line 22, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 22, Col 27, Line 22, Col 30, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 24, Col 22, Line 24, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 24, Col 26, Line 24, Col 29, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 32, Col 20, Line 32, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 32, Col 25, Line 32, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 34, Col 21, Line 34, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 34, Col 25, Line 34, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] - - [] - let ``E_UpperBindingPattern02_fs`` compilation = + [] + let ``UpperBindingPattern_fs preview`` compilation = compilation |> asExe - |> withOptions ["--test:ErrorRanges"] - |> typecheck - |> shouldFail - |> withDiagnostics [ - (Warning 49, Line 3, Col 7, Line 3, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 3, Col 11, Line 3, Col 14, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 5, Col 8, Line 5, Col 11, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 5, Col 12, Line 5, Col 15, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - ] - - [] - let ``E_UpperBindingPattern02_fs preview`` compilation = - compilation |> withLangVersionPreview - |> asExe |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 3, Col 7, Line 3, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 3, Col 11, Line 3, Col 14, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 5, Col 8, Line 5, Col 11, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 5, Col 12, Line 5, Col 15, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - ] - - [] - let ``E_UpperBindingPattern03_fs`` compilation = - compilation - |> asExe - |> withOptions ["--test:ErrorRanges"] - |> typecheck - |> shouldSucceed - - [] - let ``E_UpperBindingPattern03_fs preview`` compilation = - compilation - |> withLangVersionPreview - |> asExe - |> withOptions ["--test:ErrorRanges"] - |> typecheck - |> shouldFail - |> withDiagnostics [ - (Warning 49, Line 2, Col 21, Line 2, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 2, Col 25, Line 2, Col 27, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 4, Col 22, Line 4, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 4, Col 25, Line 4, Col 27, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 6, Col 22, Line 6, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 6, Col 24, Line 6, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 9, Col 19, Line 9, Col 21, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 9, Col 23, Line 9, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 11, Col 20, Line 11, Col 22, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 11, Col 23, Line 11, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 13, Col 20, Line 13, Col 21, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 13, Col 22, Line 13, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - ] - - [] - let ``E_UpperBindingPattern04_fs`` compilation = - compilation - |> asExe - |> withOptions ["--test:ErrorRanges"] - |> typecheck - |> shouldFail - |> withDiagnostics [ - (Warning 49, Line 2, Col 21, Line 2, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 2, Col 26, Line 2, Col 29, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 4, Col 22, Line 4, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 4, Col 26, Line 4, Col 29, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 7, Col 19, Line 7, Col 22, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 7, Col 24, Line 7, Col 27, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 9, Col 20, Line 9, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 9, Col 24, Line 9, Col 27, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - ] - - [] - let ``E_UpperBindingPattern04_fs preview`` compilation = - compilation - |> withLangVersionPreview - |> asExe - |> withOptions ["--test:ErrorRanges"] - |> typecheck - |> shouldFail - |> withDiagnostics [ - (Warning 49, Line 2, Col 21, Line 2, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 2, Col 26, Line 2, Col 29, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 4, Col 22, Line 4, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 4, Col 26, Line 4, Col 29, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 7, Col 19, Line 7, Col 22, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 7, Col 24, Line 7, Col 27, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 9, Col 20, Line 9, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 9, Col 24, Line 9, Col 27, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 3, Col 8, Line 3, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 3, Col 11, Line 3, Col 13, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 5, Col 8, Line 5, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 5, Col 11, Line 5, Col 13, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 7, Col 8, Line 7, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 7, Col 10, Line 7, Col 11, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 11, Col 8, Line 11, Col 11, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 11, Col 12, Line 11, Col 15, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 13, Col 8, Line 13, Col 11, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 13, Col 12, Line 13, Col 15, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 16, Col 22, Line 16, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 16, Col 26, Line 16, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 18, Col 22, Line 18, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 18, Col 25, Line 18, Col 27, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 20, Col 22, Line 20, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 20, Col 24, Line 20, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 22, Col 22, Line 22, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 22, Col 27, Line 22, Col 30, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 24, Col 22, Line 24, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 24, Col 26, Line 24, Col 29, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 26, Col 20, Line 26, Col 22, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 26, Col 24, Line 26, Col 26, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 28, Col 20, Line 28, Col 22, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 28, Col 23, Line 28, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 30, Col 20, Line 30, Col 21, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 30, Col 22, Line 30, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 32, Col 20, Line 32, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 32, Col 25, Line 32, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 34, Col 21, Line 34, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 34, Col 25, Line 34, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern.fs deleted file mode 100644 index a1a009db8e1..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern.fs +++ /dev/null @@ -1,7 +0,0 @@ -let Aaa = () - -let f Us Uk = () - -let f2 US CA = () - -let f3 U A = () \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern02.fs deleted file mode 100644 index 3fe517cea70..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern02.fs +++ /dev/null @@ -1,5 +0,0 @@ -let AAA = () - -let f USA CAN = () - -let f3 Usa Can = () \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern03.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern03.fs deleted file mode 100644 index 1b313e9eb56..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern03.fs +++ /dev/null @@ -1,13 +0,0 @@ -type Class() = - static member f(Us, Uk) = () - - static member f2 US CA = () - - static member f3 U A = () - -type Class2() = - member this.f(Us, Uk) = () - - member this.f2 US CA = () - - member this.f3 U A = () \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern04.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern04.fs deleted file mode 100644 index d161cc773cb..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/E_UpperBindingPattern04.fs +++ /dev/null @@ -1,9 +0,0 @@ -type Class() = - static member f(USA, CAN) = () - - static member f2 Usa Can = () - -type Class2() = - member this.f(USA, CAN) = () - - member this.f2 Usa Can = () \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs new file mode 100644 index 00000000000..f07acb6f725 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs @@ -0,0 +1,34 @@ +let Aaa = () + +let f1 Us Uk = () + +let f2 US CA = () + +let f3 U A = () + +let AAA = () + +let f4 USA CAN = () + +let f5 Usa Can = () + +type Class() = + static member f1(Us, Uk) = () + + static member f2 US CA = () + + static member f3 U A = () + + static member f4(USA, CAN) = () + + static member f5 Usa Can = () + + member this.f6(Us, Uk) = () + + member this.f7 US CA = () + + member this.f8 U A = () + + member this.f9(USA, CAN) = () + + member this.f10 Usa Can = () \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern12.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern12.fs deleted file mode 100644 index aab6e2e0ac0..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern12.fs +++ /dev/null @@ -1,11 +0,0 @@ -let x = - match 1 with - | US -> "US" - | UK -> "UK" - | U -> "U" - -let y = - match 2 with - | Us -> "Us" - | Uk -> "Uk" - | U -> "u" \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern13.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern13.fs deleted file mode 100644 index ed92b3e2951..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionPattern13.fs +++ /dev/null @@ -1,9 +0,0 @@ -let x = - match 1 with - | USA -> "USA" - | CAN -> "CAN" - -let y = - match 2 with - | Usa -> "Usa" - | Can -> "Can" diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs index b0ae835be98..a6201f0e559 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs @@ -211,8 +211,8 @@ but here has type (Warning 26, Line 8, Col 7, Line 8, Col 55, "This rule will never be matched") ] - [] - let ``Union - E_UnionPattern12_fs - --test:ErrorRanges`` compilation = + [] + let ``Union - UpperUnionCasePattern_fs - --test:ErrorRanges`` compilation = compilation |> asFs |> withOptions ["--test:ErrorRanges"] @@ -223,10 +223,14 @@ but here has type (Warning 26, Line 5, Col 7, Line 5, Col 8, "This rule will never be matched") (Warning 26, Line 10, Col 7, Line 10, Col 9, "This rule will never be matched") (Warning 26, Line 11, Col 7, Line 11, Col 8, "This rule will never be matched") + (Warning 49, Line 15, Col 7, Line 15, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 16, Col 7, Line 16, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 26, Line 16, Col 7, Line 16, Col 10, "This rule will never be matched") + (Warning 49, Line 20, Col 7, Line 20, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] - [] - let ``Union - E_UnionPattern12_fs preview - --test:ErrorRanges`` compilation = + [] + let ``Union - UpperUnionCasePattern_fs preview - --test:ErrorRanges`` compilation = compilation |> withLangVersionPreview |> asFs @@ -244,37 +248,8 @@ but here has type (Warning 49, Line 11, Col 7, Line 11, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") (Warning 26, Line 10, Col 7, Line 10, Col 9, "This rule will never be matched") (Warning 26, Line 11, Col 7, Line 11, Col 8, "This rule will never be matched") - ] - - [] - let ``Union - E_UnionPattern13_fs - --test:ErrorRanges`` compilation = - compilation - |> asFs - |> withOptions ["--test:ErrorRanges"] - |> typecheck - |> shouldFail - |> withDiagnostics [ - (Warning 49, Line 3, Col 7, Line 3, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 4, Col 7, Line 4, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 26, Line 4, Col 7, Line 4, Col 10, "This rule will never be matched") - (Warning 49, Line 8, Col 7, Line 8, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 9, Col 7, Line 9, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 26, Line 9, Col 7, Line 9, Col 10, "This rule will never be matched") - ] - - [] - let ``Union - E_UnionPattern13_fs preview- --test:ErrorRanges`` compilation = - compilation - |> withLangVersionPreview - |> asFs - |> withOptions ["--test:ErrorRanges"] - |> typecheck - |> shouldFail - |> withDiagnostics [ - (Warning 49, Line 3, Col 7, Line 3, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 4, Col 7, Line 4, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 26, Line 4, Col 7, Line 4, Col 10, "This rule will never be matched") - (Warning 49, Line 8, Col 7, Line 8, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 9, Col 7, Line 9, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 26, Line 9, Col 7, Line 9, Col 10, "This rule will never be matched") - ] + (Warning 49, Line 15, Col 7, Line 15, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 16, Col 7, Line 16, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 26, Line 16, Col 7, Line 16, Col 10, "This rule will never be matched") + (Warning 49, Line 20, Col 7, Line 20, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs new file mode 100644 index 00000000000..b684a964994 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs @@ -0,0 +1,20 @@ +let a = + match 1 with + | US -> "US" + | UK -> "UK" + | U -> "U" + +let b = + match 2 with + | Us -> "Us" + | Uk -> "Uk" + | U -> "u" + +let c = + match 1 with + | USA -> "USA" + | CAN -> "CAN" + +let d = + match 2 with + | Usa -> "Usa" \ No newline at end of file From 0183998d82d3fe8f78d89926dc47d403aec5a92b Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Fri, 25 Oct 2024 12:34:53 +0100 Subject: [PATCH 20/49] more tests --- .../BindingExpressions/BindingExpressions.fs | 9 +++++++ .../BindingExpressions/UpperBindingPattern.fs | 26 ++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs index e1264fd0a12..29d0dfc9ec8 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs @@ -165,6 +165,9 @@ module BindingExpressions = (Warning 49, Line 32, Col 25, Line 32, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") (Warning 49, Line 34, Col 21, Line 34, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") (Warning 49, Line 34, Col 25, Line 34, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 42, Col 31, Line 42, Col 34, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 46, Col 5, Line 46, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 53, Col 18, Line 53, Col 21, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); ] [] @@ -206,4 +209,10 @@ module BindingExpressions = (Warning 49, Line 32, Col 25, Line 32, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") (Warning 49, Line 34, Col 21, Line 34, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") (Warning 49, Line 34, Col 25, Line 34, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 42, Col 31, Line 42, Col 34, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 44, Col 32, Line 44, Col 34, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 46, Col 5, Line 46, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 49, Col 5, Line 49, Col 7, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 53, Col 18, Line 53, Col 21, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 57, Col 18, Line 57, Col 20, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs index f07acb6f725..be16b3ceba9 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs @@ -31,4 +31,28 @@ type Class() = member this.f9(USA, CAN) = () - member this.f10 Usa Can = () \ No newline at end of file + member this.f10 Usa Can = () + +type CustomerId = CustomerId of string + +let customerId = CustomerId("123") + +let (CustomerId BBB) = customerId + +let getCustomerId (CustomerId CCC) = id + +let getCustomerId2 (CustomerId CC) = id + +for III in [1..10] do + () + +for II in [1..10] do + () + +[ 1; 3; 5 ] +|> List.map (fun DDD -> DDD + 1) +|> ignore + +[ 1; 3; 5 ] +|> List.map (fun DD -> DD + 1) +|> ignore From 5236633ad766c7b99bb4fa3fd959cea5c9da4be2 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Fri, 25 Oct 2024 21:27:28 +0100 Subject: [PATCH 21/49] 3874,chkVariablePatternUppercase,"Variable patterns should be lowercase." --- src/Compiler/Checking/CheckPatterns.fs | 8 +- .../CheckComputationExpressions.fs | 18 +-- .../Checking/Expressions/CheckExpressions.fs | 15 ++- .../Checking/Expressions/CheckExpressions.fsi | 1 + .../Expressions/CheckSequenceExpressions.fs | 16 ++- src/Compiler/Checking/NameResolution.fs | 18 ++- src/Compiler/Checking/NameResolution.fsi | 3 +- src/Compiler/FSComp.txt | 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 + .../BindingExpressions/BindingExpressions.fs | 103 +++++++++--------- .../BindingExpressions/UpperBindingPattern.fs | 3 + .../PatternMatching/Union/Union.fs | 35 +++--- .../Union/UpperUnionCasePattern.fs | 10 +- 25 files changed, 193 insertions(+), 103 deletions(-) diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index 54419016859..e594763919f 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -58,10 +58,12 @@ let UnifyRefTupleType contextInfo (cenv: cenv) denv m ty ps = AddCxTypeEqualsType contextInfo denv cenv.css m ty (TType_tuple (tupInfoRef, ptys)) ptys -let rec TryAdjustHiddenVarNameToCompGenName cenv env (id: Ident) altNameRefCellOpt = +let rec TryAdjustHiddenVarNameToCompGenName (cenv: cenv) env (id: Ident) altNameRefCellOpt = match altNameRefCellOpt with | Some ({contents = SynSimplePatAlternativeIdInfo.Undecided altId } as altNameRefCell) -> - match ResolvePatternLongIdent cenv.tcSink cenv.nameResolver AllIdsOK false id.idRange env.eAccessRights env.eNameResEnv TypeNameResolutionInfo.Default [id] ExtraDotAfterIdentifier.No with + let supportsWarnOnUpperIdentifiersInPatterns = cenv.g.langVersion.SupportsFeature(LanguageFeature.WarnOnUppercaseIdentifiersInPatterns) + let warnOnUpperFlag = if supportsWarnOnUpperIdentifiersInPatterns then WarnOnUpperVariablePatterns else AllIdsOK + match ResolvePatternLongIdent cenv.tcSink cenv.nameResolver warnOnUpperFlag false id.idRange env.eAccessRights env.eNameResEnv TypeNameResolutionInfo.Default [id] ExtraDotAfterIdentifier.No with | Item.NewDef _ -> // The name is not in scope as a pattern identifier (e.g. union case), so do not use the alternate ID None @@ -81,7 +83,7 @@ and TcSimplePat optionalArgsOK checkConstraints (cenv: cenv) ty env patEnv p = | SynSimplePat.Id (id, altNameRefCellOpt, isCompGen, isMemberThis, isOpt, m) -> // Check to see if pattern translation decides to use an alternative identifier. - match TryAdjustHiddenVarNameToCompGenName cenv env id altNameRefCellOpt with + match TryAdjustHiddenVarNameToCompGenName (cenv: cenv) env id altNameRefCellOpt with | Some altId -> TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv (SynSimplePat.Id (altId, None, isCompGen, isMemberThis, isOpt, m) ) | None -> diff --git a/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs b/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs index 645897a6793..6b6c8ab4472 100644 --- a/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs @@ -982,7 +982,7 @@ let rec TryTranslateComputationExpression use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink let _, _, vspecs, envinner, _ = - TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv firstSourcePat None + TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv firstSourcePat None false vspecs, envinner) @@ -991,7 +991,7 @@ let rec TryTranslateComputationExpression use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink let _, _, vspecs, envinner, _ = - TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv secondSourcePat None + TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv secondSourcePat None false vspecs, envinner) @@ -1002,7 +1002,7 @@ let rec TryTranslateComputationExpression use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink let _, _, vspecs, envinner, _ = - TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv pat3 None + TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv pat3 None false vspecs, envinner) | None -> varSpace @@ -1231,7 +1231,7 @@ let rec TryTranslateComputationExpression use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink let _, _, vspecs, envinner, _ = - TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv pat None + TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv pat None false vspecs, envinner) @@ -1789,7 +1789,7 @@ let rec TryTranslateComputationExpression use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink let _, _, vspecs, envinner, _ = - TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv pat None + TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv pat None false vspecs, envinner | _ -> @@ -1873,7 +1873,7 @@ let rec TryTranslateComputationExpression use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink let _, _, vspecs, envinner, _ = - TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv pat None + TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv pat None false vspecs, envinner) @@ -2066,7 +2066,7 @@ let rec TryTranslateComputationExpression use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink let _, _, vspecs, envinner, _ = - TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv consumePat None + TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv consumePat None false vspecs, envinner) @@ -2111,7 +2111,7 @@ let rec TryTranslateComputationExpression use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink let _, _, vspecs, envinner, _ = - TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv consumePat None + TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv consumePat None false vspecs, envinner) @@ -2239,7 +2239,7 @@ let rec TryTranslateComputationExpression use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink let _, _, vspecs, envinner, _ = - TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv consumePat None + TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv consumePat None false vspecs, envinner) diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index f9cc041a1be..77759de838d 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -2517,7 +2517,7 @@ module BindingNormalization = let extraDot = if synLongId.ThereIsAnExtraDotAtTheEnd then ExtraDotAfterIdentifier.Yes else ExtraDotAfterIdentifier.No let warnOnUpper = if not args.IsEmpty then - WarnOnUpperCase + WarnOnUpperUnionCaseLabel else AllIdsOK match ResolvePatternLongIdent cenv.tcSink nameResolver warnOnUpper true m ad env.NameEnv TypeNameResolutionInfo.Default longId extraDot with @@ -8075,7 +8075,7 @@ and TcForEachExpr cenv overallTy env tpenv (seqExprOnly, isFromSource, synPat, s let pat, _, vspecs, envinner, tpenv = let env = { env with eIsControlFlow = false } - TcMatchPattern cenv enumElemTy env tpenv synPat None + TcMatchPattern cenv enumElemTy env tpenv synPat None false let elemVar, pat = // nice: don't introduce awful temporary for r.h.s. in the 99% case where we know what we're binding it to @@ -10605,10 +10605,11 @@ and TcAndPatternCompileMatchClauses mExpr mMatch actionOnFailure cenv inputExprO let matchVal, expr = CompilePatternForMatchClauses cenv env mExpr mMatch true actionOnFailure inputExprOpt inputTy resultTy.Commit clauses matchVal, expr, tpenv -and TcMatchPattern cenv inputTy env tpenv (synPat: SynPat) (synWhenExprOpt: SynExpr option) = +and TcMatchPattern (cenv: cenv) inputTy env tpenv (synPat: SynPat) (synWhenExprOpt: SynExpr option) (isTrueMatchClause: bool) = let g = cenv.g let m = synPat.Range - let patf', (TcPatLinearEnv (tpenv, names, _)) = cenv.TcPat WarnOnUpperCase cenv env None (TcPatValFlags (ValInline.Optional, permitInferTypars, noArgOrRetAttribs, false, None, false)) (TcPatLinearEnv (tpenv, Map.empty, Set.empty)) inputTy synPat + let warnOnUpperFlag = if isTrueMatchClause then WarnOnUpperUnionCaseLabel else WarnOnUpperVariablePatterns + let patf', (TcPatLinearEnv (tpenv, names, _)) = cenv.TcPat warnOnUpperFlag cenv env None (TcPatValFlags (ValInline.Optional, permitInferTypars, noArgOrRetAttribs, false, None, false)) (TcPatLinearEnv (tpenv, Map.empty, Set.empty)) inputTy synPat let envinner, values, vspecMap = MakeAndPublishSimpleValsForMergedScope cenv env m names let whenExprOpt, tpenv = @@ -10629,9 +10630,11 @@ and TcMatchClauses cenv inputTy (resultTy: OverallTy) env tpenv clauses = resultList,tpEnv and TcMatchClause cenv inputTy (resultTy: OverallTy) env isFirst tpenv synMatchClause = - let (SynMatchClause(synPat, synWhenExprOpt, synResultExpr, patm, spTgt, _)) = synMatchClause + let (SynMatchClause(synPat, synWhenExprOpt, synResultExpr, patm, spTgt, trivia)) = synMatchClause - let pat, whenExprOpt, vspecs, envinner, tpenv = TcMatchPattern cenv inputTy env tpenv synPat synWhenExprOpt + let isTrueMatchClause = trivia.BarRange.IsSome && trivia.ArrowRange.IsSome + + let pat, whenExprOpt, vspecs, envinner, tpenv = TcMatchPattern cenv inputTy env tpenv synPat synWhenExprOpt isTrueMatchClause let resultEnv = if isFirst then envinner diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fsi b/src/Compiler/Checking/Expressions/CheckExpressions.fsi index cccb19f8abf..2ebda98c746 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fsi +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fsi @@ -703,6 +703,7 @@ val TcMatchPattern: tpenv: UnscopedTyparEnv -> synPat: SynPat -> synWhenExprOpt: SynExpr option -> + isTrueMatchClause: bool -> Pattern * Expr option * Val list * TcEnv * UnscopedTyparEnv [] diff --git a/src/Compiler/Checking/Expressions/CheckSequenceExpressions.fs b/src/Compiler/Checking/Expressions/CheckSequenceExpressions.fs index 3154d3e1e74..93c860dbd33 100644 --- a/src/Compiler/Checking/Expressions/CheckSequenceExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckSequenceExpressions.fs @@ -59,7 +59,7 @@ let TcSequenceExpression (cenv: TcFileState) env tpenv comp (overallTy: OverallT ConvertArbitraryExprToEnumerable cenv arbitraryTy env pseudoEnumExpr let patR, _, vspecs, envinner, tpenv = - TcMatchPattern cenv enumElemTy env tpenv pat None + TcMatchPattern cenv enumElemTy env tpenv pat None false let innerExpr, tpenv = let envinner = { envinner with eIsControlFlow = true } @@ -241,7 +241,7 @@ let TcSequenceExpression (cenv: TcFileState) env tpenv comp (overallTy: OverallT let inputExprTy = NewInferenceType g let pat', _, vspecs, envinner, tpenv = - TcMatchPattern cenv bindPatTy env tpenv pat None + TcMatchPattern cenv bindPatTy env tpenv pat None false UnifyTypes cenv env m inputExprTy bindPatTy @@ -270,9 +270,11 @@ let TcSequenceExpression (cenv: TcFileState) env tpenv comp (overallTy: OverallT let tclauses, tpenv = (tpenv, clauses) - ||> List.mapFold (fun tpenv (SynMatchClause(pat, cond, innerComp, _, sp, _)) -> + ||> List.mapFold (fun tpenv (SynMatchClause(pat, cond, innerComp, _, sp, trivia)) -> + let isTrueMatchClause = trivia.BarRange.IsSome && trivia.ArrowRange.IsSome + let patR, condR, vspecs, envinner, tpenv = - TcMatchPattern cenv inputTy env tpenv pat cond + TcMatchPattern cenv inputTy env tpenv pat cond isTrueMatchClause let envinner = match sp with @@ -313,9 +315,11 @@ let TcSequenceExpression (cenv: TcFileState) env tpenv comp (overallTy: OverallT // Compile the pattern twice, once as a filter with all succeeding targets returning "1", and once as a proper catch block. let clauses, tpenv = (tpenv, withList) - ||> List.mapFold (fun tpenv (SynMatchClause(pat, cond, innerComp, m, sp, _)) -> + ||> List.mapFold (fun tpenv (SynMatchClause(pat, cond, innerComp, m, sp, trivia)) -> + let isTrueMatchClause = trivia.BarRange.IsSome && trivia.ArrowRange.IsSome + let patR, condR, vspecs, envinner, tpenv = - TcMatchPattern cenv g.exn_ty env tpenv pat cond + TcMatchPattern cenv g.exn_ty env tpenv pat cond isTrueMatchClause let envinner = match sp with diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index c7fece074ea..845ed98e360 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -3369,7 +3369,10 @@ let rec ResolvePatternLongIdentInModuleOrNamespace (ncenv: NameResolver) nenv nu exception UpperCaseIdentifierInPattern of range /// Indicates if a warning should be given for the use of upper-case identifiers in patterns -type WarnOnUpperFlag = WarnOnUpperCase | AllIdsOK +type WarnOnUpperFlag = + | WarnOnUpperUnionCaseLabel + | WarnOnUpperVariablePatterns + | AllIdsOK // Long ID in a pattern let rec ResolvePatternLongIdentPrim sink (ncenv: NameResolver) fullyQualified warnOnUpper newDef m ad nenv numTyArgsOpt (id: Ident) (rest: Ident list) extraDotAtTheEnd = @@ -3389,18 +3392,23 @@ let rec ResolvePatternLongIdentPrim sink (ncenv: NameResolver) fullyQualified wa | true, res when not newDef -> ResolveUnqualifiedItem ncenv nenv m res | _ -> // Single identifiers in patterns - variable bindings - let supportsWarnOnUpperIdentifiersInPatterns = ncenv.g.langVersion.SupportsFeature(LanguageFeature.WarnOnUppercaseIdentifiersInPatterns) && warnOnUpper = WarnOnUpperCase + let supportsWarnOnUpperIdentifiersInPatterns = ncenv.g.langVersion.SupportsFeature(LanguageFeature.WarnOnUppercaseIdentifiersInPatterns) if (supportsWarnOnUpperIdentifiersInPatterns && not newDef && System.Char.ToLowerInvariant id.idText[0] <> id.idText[0]) then - warning(UpperCaseIdentifierInPattern m) + match warnOnUpper with + | WarnOnUpperUnionCaseLabel -> warning(UpperCaseIdentifierInPattern m) + | WarnOnUpperVariablePatterns -> warning(Error(FSComp.SR.chkVariablePatternUppercase(), m)) + | AllIdsOK -> () else if not newDef - && warnOnUpper = WarnOnUpperCase // HACK: This is an historical hack that seems to related the use country and language codes, which are very common in codebases && id.idText.Length >= 3 && System.Char.ToLowerInvariant id.idText[0] <> id.idText[0] then - warning(UpperCaseIdentifierInPattern m) + match warnOnUpper with + | WarnOnUpperUnionCaseLabel -> warning(UpperCaseIdentifierInPattern m) + | WarnOnUpperVariablePatterns -> warning(Error(FSComp.SR.chkVariablePatternUppercase(), m)) + | AllIdsOK -> () // If there's an extra dot, we check whether the single identifier is a union, module or namespace and report it to the sink for the sake of tooling match extraDotAtTheEnd with diff --git a/src/Compiler/Checking/NameResolution.fsi b/src/Compiler/Checking/NameResolution.fsi index d3870b251c8..693c9ec16de 100755 --- a/src/Compiler/Checking/NameResolution.fsi +++ b/src/Compiler/Checking/NameResolution.fsi @@ -565,7 +565,8 @@ type LookupKind = /// Indicates if a warning should be given for the use of upper-case identifiers in patterns type WarnOnUpperFlag = - | WarnOnUpperCase + | WarnOnUpperUnionCaseLabel + | WarnOnUpperVariablePatterns | AllIdsOK /// Indicates whether we permit a direct reference to a type generator. Only set when resolving the diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index c5c16131817..b50626371ca 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1787,3 +1787,4 @@ featureAllowObjectExpressionWithoutOverrides,"Allow object expressions without o featureWarnOnUppercaseIdentifiersInPatterns,"Warn on uppercase identifiers in patterns" 3873,chkDeprecatePlacesWhereSeqCanBeOmitted,"This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'" featureDeprecatePlacesWhereSeqCanBeOmitted,"Deprecate places where 'seq' can be omitted" +3874,chkVariablePatternUppercase,"Variable patterns should be lowercase." diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 99bc12f43e8..5d0fab260ff 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -147,6 +147,11 @@ Atribut TailCall by se měl použít jenom pro rekurzivní funkce. + + Variable patterns should be lowercase. + Variable patterns should be lowercase. + + The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. Atribut AssemblyKeyNameAttribute je zastaralý. Použijte místo něj AssemblyKeyFileAttribute. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 339fc6e66f4..3d54e03ee47 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -147,6 +147,11 @@ Das Attribut "TailCall" darf nur auf rekursive Funktionen angewendet werden. + + Variable patterns should be lowercase. + Variable patterns should be lowercase. + + The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. "AssemblyKeyNameAttribute" gilt als veraltet. Verwenden Sie stattdessen "AssemblyKeyFileAttribute". diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index f0b55298fd1..7b8a7835840 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -147,6 +147,11 @@ El atributo TailCall solo se debe aplicar a funciones recursivas. + + Variable patterns should be lowercase. + Variable patterns should be lowercase. + + The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. El elemento "AssemblyKeyNameAttribute" está en desuso. Use "AssemblyKeyFileAttribute" en su lugar. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index d5e3c520e1f..213f44fc1d8 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -147,6 +147,11 @@ L’attribut TailCall ne doit être appliqué qu’aux fonctions récursives. + + Variable patterns should be lowercase. + Variable patterns should be lowercase. + + The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. 'AssemblyKeyNameAttribute' a été déprécié. Utilisez 'AssemblyKeyFileAttribute' à la place. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 802c5c95f2a..ad3be72a7a7 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -147,6 +147,11 @@ L'attributo TailCall deve essere applicato solo a funzioni ricorsive. + + Variable patterns should be lowercase. + Variable patterns should be lowercase. + + The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. L'attributo 'AssemblyKeyNameAttribute' è deprecato. In alternativa, usare 'AssemblyKeyFileAttribute'. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 6da7ef9148a..9336ca2b53d 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -147,6 +147,11 @@ TailCall 属性は再帰関数にのみ適用する必要があります。 + + Variable patterns should be lowercase. + Variable patterns should be lowercase. + + The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. 'AssemblyKeyNameAttribute' は非推奨になりました。代わりに 'AssemblyKeyFileAttribute' を使用してください。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index fc696d4e7a5..9089b287d4b 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -147,6 +147,11 @@ TailCall 특성은 재귀 함수에만 적용해야 합니다. + + Variable patterns should be lowercase. + Variable patterns should be lowercase. + + The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. 'AssemblyKeyNameAttribute'는 사용되지 않습니다. 대신 'AssemblyKeyFileAttribute'를 사용하세요. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index e17fbf1515c..22528692d8c 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -147,6 +147,11 @@ Atrybut TailCall powinien być stosowany tylko do funkcji rekursywnych. + + Variable patterns should be lowercase. + Variable patterns should be lowercase. + + The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. Element „AssemblyKeyNameAttribute” jest przestarzały. Zamiast niego użyj elementu „AssemblyKeyFileAttribute”. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 98265792bb7..bd06ff5a471 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -147,6 +147,11 @@ O atributo TailCall só deve ser aplicado a funções recursivas. + + Variable patterns should be lowercase. + Variable patterns should be lowercase. + + The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. O 'AssemblyKeyNameAttribute' foi preterido. Use o 'AssemblyKeyFileAttribute'. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 272a31d7329..8938011cafc 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -147,6 +147,11 @@ Атрибут TailCall следует применять только к рекурсивным функциям. + + Variable patterns should be lowercase. + Variable patterns should be lowercase. + + The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. Атрибут "AssemblyKeyNameAttribute" является устаревшим. Используйте вместо него атрибут "AssemblyKeyFileAttribute". diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 43d8b371206..e83826e9293 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -147,6 +147,11 @@ TailCall özniteliği yalnızca özyinelemeli işlevlere uygulanmalıdır. + + Variable patterns should be lowercase. + Variable patterns should be lowercase. + + The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. 'AssemblyKeyNameAttribute' kullanım dışı bırakıldı. Bunun yerine 'AssemblyKeyFileAttribute' kullanın. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 8e435be8f97..62d5d929eda 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -147,6 +147,11 @@ TailCall 属性应仅应用于递归函数。 + + Variable patterns should be lowercase. + Variable patterns should be lowercase. + + The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. "AssemblyKeyNameAttribute" 已被弃用。请改为使用 "AssemblyKeyFileAttribute"。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 0354bc8d14e..f119c38c57b 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -147,6 +147,11 @@ TailCall 屬性只應套用至遞迴函數。 + + Variable patterns should be lowercase. + Variable patterns should be lowercase. + + The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. 'AssemblyKeyNameAttribute' 已淘汰。請改用 'AssemblyKeyFileAttribute'。 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs index 29d0dfc9ec8..79f83b0f52c 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs @@ -153,21 +153,21 @@ module BindingExpressions = |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 11, Col 8, Line 11, Col 11, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 11, Col 12, Line 11, Col 15, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 13, Col 8, Line 13, Col 11, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 13, Col 12, Line 13, Col 15, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 22, Col 22, Line 22, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 22, Col 27, Line 22, Col 30, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 24, Col 22, Line 24, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 24, Col 26, Line 24, Col 29, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 32, Col 20, Line 32, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 32, Col 25, Line 32, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 34, Col 21, Line 34, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 34, Col 25, Line 34, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 42, Col 31, Line 42, Col 34, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 46, Col 5, Line 46, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 53, Col 18, Line 53, Col 21, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 3874, Line 11, Col 8, Line 11, Col 11, "Variable patterns should be lowercase.") + (Warning 3874, Line 11, Col 12, Line 11, Col 15, "Variable patterns should be lowercase.") + (Warning 3874, Line 13, Col 8, Line 13, Col 11, "Variable patterns should be lowercase.") + (Warning 3874, Line 13, Col 12, Line 13, Col 15, "Variable patterns should be lowercase.") + (Warning 3874, Line 22, Col 22, Line 22, Col 25, "Variable patterns should be lowercase.") + (Warning 3874, Line 22, Col 27, Line 22, Col 30, "Variable patterns should be lowercase.") + (Warning 3874, Line 24, Col 22, Line 24, Col 25, "Variable patterns should be lowercase.") + (Warning 3874, Line 24, Col 26, Line 24, Col 29, "Variable patterns should be lowercase.") + (Warning 3874, Line 32, Col 20, Line 32, Col 23, "Variable patterns should be lowercase.") + (Warning 3874, Line 32, Col 25, Line 32, Col 28, "Variable patterns should be lowercase.") + (Warning 3874, Line 34, Col 21, Line 34, Col 24, "Variable patterns should be lowercase.") + (Warning 3874, Line 34, Col 25, Line 34, Col 28, "Variable patterns should be lowercase.") + (Warning 3874, Line 42, Col 31, Line 42, Col 34, "Variable patterns should be lowercase.") + (Warning 3874, Line 46, Col 5, Line 46, Col 8, "Variable patterns should be lowercase.") + (Warning 3874, Line 53, Col 18, Line 53, Col 21, "Variable patterns should be lowercase.") ] [] @@ -179,40 +179,41 @@ module BindingExpressions = |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 3, Col 8, Line 3, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 3, Col 11, Line 3, Col 13, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 5, Col 8, Line 5, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 5, Col 11, Line 5, Col 13, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 7, Col 8, Line 7, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 7, Col 10, Line 7, Col 11, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 11, Col 8, Line 11, Col 11, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 11, Col 12, Line 11, Col 15, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 13, Col 8, Line 13, Col 11, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 13, Col 12, Line 13, Col 15, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 16, Col 22, Line 16, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 16, Col 26, Line 16, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 18, Col 22, Line 18, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 18, Col 25, Line 18, Col 27, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 20, Col 22, Line 20, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 20, Col 24, Line 20, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 22, Col 22, Line 22, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 22, Col 27, Line 22, Col 30, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 24, Col 22, Line 24, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 24, Col 26, Line 24, Col 29, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 26, Col 20, Line 26, Col 22, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 26, Col 24, Line 26, Col 26, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 28, Col 20, Line 28, Col 22, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 28, Col 23, Line 28, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 30, Col 20, Line 30, Col 21, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 30, Col 22, Line 30, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 32, Col 20, Line 32, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 32, Col 25, Line 32, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 34, Col 21, Line 34, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 34, Col 25, Line 34, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 42, Col 31, Line 42, Col 34, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 44, Col 32, Line 44, Col 34, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 46, Col 5, Line 46, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 49, Col 5, Line 49, Col 7, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 53, Col 18, Line 53, Col 21, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 57, Col 18, Line 57, Col 20, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 3874, Line 3, Col 8, Line 3, Col 10, "Variable patterns should be lowercase.") + (Warning 3874, Line 3, Col 11, Line 3, Col 13, "Variable patterns should be lowercase.") + (Warning 3874, Line 5, Col 8, Line 5, Col 10, "Variable patterns should be lowercase.") + (Warning 3874, Line 5, Col 11, Line 5, Col 13, "Variable patterns should be lowercase.") + (Warning 3874, Line 7, Col 8, Line 7, Col 9, "Variable patterns should be lowercase.") + (Warning 3874, Line 7, Col 10, Line 7, Col 11, "Variable patterns should be lowercase.") + (Warning 3874, Line 11, Col 8, Line 11, Col 11, "Variable patterns should be lowercase.") + (Warning 3874, Line 11, Col 12, Line 11, Col 15, "Variable patterns should be lowercase.") + (Warning 3874, Line 13, Col 8, Line 13, Col 11, "Variable patterns should be lowercase.") + (Warning 3874, Line 13, Col 12, Line 13, Col 15, "Variable patterns should be lowercase.") + (Warning 3874, Line 16, Col 22, Line 16, Col 24, "Variable patterns should be lowercase.") + (Warning 3874, Line 16, Col 26, Line 16, Col 28, "Variable patterns should be lowercase.") + (Warning 3874, Line 18, Col 22, Line 18, Col 24, "Variable patterns should be lowercase.") + (Warning 3874, Line 18, Col 25, Line 18, Col 27, "Variable patterns should be lowercase.") + (Warning 3874, Line 20, Col 22, Line 20, Col 23, "Variable patterns should be lowercase.") + (Warning 3874, Line 20, Col 24, Line 20, Col 25, "Variable patterns should be lowercase.") + (Warning 3874, Line 22, Col 22, Line 22, Col 25, "Variable patterns should be lowercase.") + (Warning 3874, Line 22, Col 27, Line 22, Col 30, "Variable patterns should be lowercase.") + (Warning 3874, Line 24, Col 22, Line 24, Col 25, "Variable patterns should be lowercase.") + (Warning 3874, Line 24, Col 26, Line 24, Col 29, "Variable patterns should be lowercase.") + (Warning 3874, Line 26, Col 20, Line 26, Col 22, "Variable patterns should be lowercase.") + (Warning 3874, Line 26, Col 24, Line 26, Col 26, "Variable patterns should be lowercase.") + (Warning 3874, Line 28, Col 20, Line 28, Col 22, "Variable patterns should be lowercase.") + (Warning 3874, Line 28, Col 23, Line 28, Col 25, "Variable patterns should be lowercase.") + (Warning 3874, Line 30, Col 20, Line 30, Col 21, "Variable patterns should be lowercase.") + (Warning 3874, Line 30, Col 22, Line 30, Col 23, "Variable patterns should be lowercase.") + (Warning 3874, Line 32, Col 20, Line 32, Col 23, "Variable patterns should be lowercase.") + (Warning 3874, Line 32, Col 25, Line 32, Col 28, "Variable patterns should be lowercase.") + (Warning 3874, Line 34, Col 21, Line 34, Col 24, "Variable patterns should be lowercase.") + (Warning 3874, Line 34, Col 25, Line 34, Col 28, "Variable patterns should be lowercase.") + (Warning 3874, Line 42, Col 31, Line 42, Col 34, "Variable patterns should be lowercase.") + (Warning 3874, Line 44, Col 32, Line 44, Col 34, "Variable patterns should be lowercase.") + (Warning 3874, Line 46, Col 5, Line 46, Col 8, "Variable patterns should be lowercase.") + (Warning 3874, Line 49, Col 5, Line 49, Col 7, "Variable patterns should be lowercase.") + (Warning 3874, Line 53, Col 18, Line 53, Col 21, "Variable patterns should be lowercase.") + (Warning 3874, Line 57, Col 18, Line 57, Col 20, "Variable patterns should be lowercase.") + (Warning 3874, Line 61, Col 6, Line 61, Col 8, "Variable patterns should be lowercase.") ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs index be16b3ceba9..268d677b86b 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs @@ -56,3 +56,6 @@ for II in [1..10] do [ 1; 3; 5 ] |> List.map (fun DD -> DD + 1) |> ignore + +try () +with Ex -> () \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs index a6201f0e559..a073d1ab934 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs @@ -215,18 +215,14 @@ but here has type let ``Union - UpperUnionCasePattern_fs - --test:ErrorRanges`` compilation = compilation |> asFs - |> withOptions ["--test:ErrorRanges"] + |> withOptions ["--test:ErrorRanges"; "--nowarn:026"] |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 26, Line 4, Col 7, Line 4, Col 9, "This rule will never be matched") - (Warning 26, Line 5, Col 7, Line 5, Col 8, "This rule will never be matched") - (Warning 26, Line 10, Col 7, Line 10, Col 9, "This rule will never be matched") - (Warning 26, Line 11, Col 7, Line 11, Col 8, "This rule will never be matched") (Warning 49, Line 15, Col 7, Line 15, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") (Warning 49, Line 16, Col 7, Line 16, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 26, Line 16, Col 7, Line 16, Col 10, "This rule will never be matched") (Warning 49, Line 20, Col 7, Line 20, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 24, Col 3, Line 24, Col 6, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] [] @@ -234,22 +230,19 @@ but here has type compilation |> withLangVersionPreview |> asFs - |> withOptions ["--test:ErrorRanges"] + |> withOptions ["--test:ErrorRanges"; "--nowarn:026"] |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 3, Col 7, Line 3, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 4, Col 7, Line 4, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 5, Col 7, Line 5, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 26, Line 4, Col 7, Line 4, Col 9, "This rule will never be matched") - (Warning 26, Line 5, Col 7, Line 5, Col 8, "This rule will never be matched") - (Warning 49, Line 9, Col 7, Line 9, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 10, Col 7, Line 10, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 11, Col 7, Line 11, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 26, Line 10, Col 7, Line 10, Col 9, "This rule will never be matched") - (Warning 26, Line 11, Col 7, Line 11, Col 8, "This rule will never be matched") - (Warning 49, Line 15, Col 7, Line 15, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 16, Col 7, Line 16, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 26, Line 16, Col 7, Line 16, Col 10, "This rule will never be matched") - (Warning 49, Line 20, Col 7, Line 20, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 3, Col 7, Line 3, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 4, Col 7, Line 4, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 5, Col 7, Line 5, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 9, Col 7, Line 9, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 10, Col 7, Line 10, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 11, Col 7, Line 11, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 15, Col 7, Line 15, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 16, Col 7, Line 16, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 20, Col 7, Line 20, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 24, Col 3, Line 24, Col 6, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 28, Col 3, Line 28, Col 5, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs index b684a964994..dd94a1c50ea 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs @@ -17,4 +17,12 @@ let c = let d = match 2 with - | Usa -> "Usa" \ No newline at end of file + | Usa -> "Usa" + +try () +with +| Exn -> () + +try () +with +| Ex -> () \ No newline at end of file From 68039fa143e9a5e71aac55d79d092b9d918da9b2 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Fri, 25 Oct 2024 22:17:29 +0100 Subject: [PATCH 22/49] hasConstructorShape --- src/Compiler/Checking/CheckBasics.fs | 2 +- src/Compiler/Checking/CheckBasics.fsi | 2 + src/Compiler/Checking/CheckPatterns.fs | 23 ++-- src/Compiler/Checking/CheckPatterns.fsi | 1 + .../Checking/Expressions/CheckExpressions.fs | 22 +++- src/Compiler/Service/FSharpProjectSnapshot.fs | 118 +++++++++--------- src/Compiler/Service/TransparentCompiler.fs | 10 +- src/FSharp.Core/MutableTuple.fs | 82 ++++++------ .../BindingExpressions/BindingExpressions.fs | 1 + .../BindingExpressions/UpperBindingPattern.fs | 8 +- tests/FSharp.Test.Utilities/CompilerAssert.fs | 6 +- .../ProjectGeneration.fs | 12 +- .../LanguageService/WorkspaceExtensions.fs | 4 +- .../Refactors/RefactorTestFramework.fs | 6 +- 14 files changed, 159 insertions(+), 138 deletions(-) diff --git a/src/Compiler/Checking/CheckBasics.fs b/src/Compiler/Checking/CheckBasics.fs index 7cbca970cc3..79320899ebf 100644 --- a/src/Compiler/Checking/CheckBasics.fs +++ b/src/Compiler/Checking/CheckBasics.fs @@ -325,7 +325,7 @@ type TcFileState = TcPat: WarnOnUpperFlag -> TcFileState -> TcEnv -> PrelimValReprInfo option -> TcPatValFlags -> TcPatLinearEnv -> TType -> SynPat -> (TcPatPhase2Input -> Pattern) * TcPatLinearEnv // forward call - TcSimplePats: TcFileState -> bool -> CheckConstraints -> TType -> TcEnv -> TcPatLinearEnv -> SynSimplePats -> string list * TcPatLinearEnv + TcSimplePats: TcFileState -> bool -> CheckConstraints -> TType -> TcEnv -> TcPatLinearEnv -> SynSimplePats -> bool -> string list * TcPatLinearEnv // forward call TcSequenceExpressionEntry: TcFileState -> TcEnv -> OverallTy -> UnscopedTyparEnv -> bool * SynExpr -> range -> Expr * UnscopedTyparEnv diff --git a/src/Compiler/Checking/CheckBasics.fsi b/src/Compiler/Checking/CheckBasics.fsi index 179752c394c..d8928638107 100644 --- a/src/Compiler/Checking/CheckBasics.fsi +++ b/src/Compiler/Checking/CheckBasics.fsi @@ -295,6 +295,7 @@ type TcFileState = -> TcEnv -> TcPatLinearEnv -> SynSimplePats + -> bool -> string list * TcPatLinearEnv // forward call @@ -345,6 +346,7 @@ type TcFileState = -> TcEnv -> TcPatLinearEnv -> SynSimplePats + -> bool -> string list * TcPatLinearEnv) * tcSequenceExpressionEntry: (TcFileState -> TcEnv -> OverallTy -> UnscopedTyparEnv -> bool * SynExpr -> range -> Expr * UnscopedTyparEnv) * diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index e594763919f..daee08106ce 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -58,11 +58,11 @@ let UnifyRefTupleType contextInfo (cenv: cenv) denv m ty ps = AddCxTypeEqualsType contextInfo denv cenv.css m ty (TType_tuple (tupInfoRef, ptys)) ptys -let rec TryAdjustHiddenVarNameToCompGenName (cenv: cenv) env (id: Ident) altNameRefCellOpt = +let rec TryAdjustHiddenVarNameToCompGenName (cenv: cenv) env (id: Ident) altNameRefCellOpt (isConstructor: bool) = match altNameRefCellOpt with | Some ({contents = SynSimplePatAlternativeIdInfo.Undecided altId } as altNameRefCell) -> let supportsWarnOnUpperIdentifiersInPatterns = cenv.g.langVersion.SupportsFeature(LanguageFeature.WarnOnUppercaseIdentifiersInPatterns) - let warnOnUpperFlag = if supportsWarnOnUpperIdentifiersInPatterns then WarnOnUpperVariablePatterns else AllIdsOK + let warnOnUpperFlag = if supportsWarnOnUpperIdentifiersInPatterns && not isConstructor then WarnOnUpperVariablePatterns else AllIdsOK match ResolvePatternLongIdent cenv.tcSink cenv.nameResolver warnOnUpperFlag false id.idRange env.eAccessRights env.eNameResEnv TypeNameResolutionInfo.Default [id] ExtraDotAfterIdentifier.No with | Item.NewDef _ -> // The name is not in scope as a pattern identifier (e.g. union case), so do not use the alternate ID @@ -75,7 +75,7 @@ let rec TryAdjustHiddenVarNameToCompGenName (cenv: cenv) env (id: Ident) altName | None -> None /// Bind the patterns used in a lambda. Not clear why we don't use TcPat. -and TcSimplePat optionalArgsOK checkConstraints (cenv: cenv) ty env patEnv p = +and TcSimplePat optionalArgsOK checkConstraints (cenv: cenv) ty env patEnv p (isConstructor: bool) = let g = cenv.g let (TcPatLinearEnv(tpenv, names, takenNames)) = patEnv @@ -83,9 +83,9 @@ and TcSimplePat optionalArgsOK checkConstraints (cenv: cenv) ty env patEnv p = | SynSimplePat.Id (id, altNameRefCellOpt, isCompGen, isMemberThis, isOpt, m) -> // Check to see if pattern translation decides to use an alternative identifier. - match TryAdjustHiddenVarNameToCompGenName (cenv: cenv) env id altNameRefCellOpt with + match TryAdjustHiddenVarNameToCompGenName (cenv: cenv) env id altNameRefCellOpt isConstructor with | Some altId -> - TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv (SynSimplePat.Id (altId, None, isCompGen, isMemberThis, isOpt, m) ) + TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv (SynSimplePat.Id (altId, None, isCompGen, isMemberThis, isOpt, m) ) isConstructor | None -> if isOpt then if not optionalArgsOK then @@ -114,10 +114,10 @@ and TcSimplePat optionalArgsOK checkConstraints (cenv: cenv) ty env patEnv p = | SynType.Var(typar = SynTypar(ident = untypedIdent)), TType_var(typar = typedTp) -> typedTp.SetIdent(untypedIdent) | _ -> () - TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnvR p + TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnvR p isConstructor | SynSimplePat.Attrib (p, _, _) -> - TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv p + TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv p isConstructor // raise an error if any optional args precede any non-optional args and ValidateOptArgOrder (synSimplePats: SynSimplePats) = @@ -140,8 +140,7 @@ and ValidateOptArgOrder (synSimplePats: SynSimplePats) = /// Bind the patterns used in argument position for a function, method or lambda. -and TcSimplePats (cenv: cenv) optionalArgsOK checkConstraints ty env patEnv synSimplePats = - +and TcSimplePats (cenv: cenv) optionalArgsOK checkConstraints ty env patEnv synSimplePats (isConstructor: bool) = let g = cenv.g let (TcPatLinearEnv(tpenv, names, takenNames)) = patEnv @@ -166,12 +165,12 @@ and TcSimplePats (cenv: cenv) optionalArgsOK checkConstraints ty env patEnv synS [id.idText], patEnvR | SynSimplePats.SimplePats (pats = [synSimplePat]) -> - let v, patEnv = TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv synSimplePat + let v, patEnv = TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv synSimplePat isConstructor [v], patEnv | SynSimplePats.SimplePats (ps, _, m) -> let ptys = UnifyRefTupleType env.eContextInfo cenv env.DisplayEnv m ty ps - let ps', patEnvR = (patEnv, List.zip ptys ps) ||> List.mapFold (fun patEnv (ty, pat) -> TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv pat) + let ps', patEnvR = (patEnv, List.zip ptys ps) ||> List.mapFold (fun patEnv (ty, pat) -> TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv pat isConstructor) ps', patEnvR and TcSimplePatsOfUnknownType (cenv: cenv) optionalArgsOK checkConstraints env tpenv (pat: SynPat) = @@ -179,7 +178,7 @@ and TcSimplePatsOfUnknownType (cenv: cenv) optionalArgsOK checkConstraints env t let argTy = NewInferenceType g let patEnv = TcPatLinearEnv (tpenv, NameMap.empty, Set.empty) let spats, _ = SimplePatsOfPat cenv.synArgNameGenerator pat - let names, patEnv = TcSimplePats cenv optionalArgsOK checkConstraints argTy env patEnv spats + let names, patEnv = TcSimplePats cenv optionalArgsOK checkConstraints argTy env patEnv spats false names, patEnv, spats and TcPatBindingName cenv env id ty isMemberThis vis1 valReprInfo (vFlags: TcPatValFlags) (names, takenNames: Set) = diff --git a/src/Compiler/Checking/CheckPatterns.fsi b/src/Compiler/Checking/CheckPatterns.fsi index da797b35a88..02e34208c65 100644 --- a/src/Compiler/Checking/CheckPatterns.fsi +++ b/src/Compiler/Checking/CheckPatterns.fsi @@ -39,4 +39,5 @@ val TcSimplePats: env: TcEnv -> patEnv: TcPatLinearEnv -> synSimplePats: SynSimplePats -> + isConstructor: bool -> string list * TcPatLinearEnv diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index 77759de838d..433b0293ac2 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -6426,12 +6426,15 @@ and TcExprILAssembly (cenv: cenv) overallTy env tpenv (ilInstrs, synTyArgs, synA and TcIteratedLambdas (cenv: cenv) isFirst (env: TcEnv) overallTy takenNames tpenv e = let g = cenv.g match e with - | SynExpr.Lambda (isMember, isSubsequent, synSimplePats, bodyExpr, _, m, _) when isMember || isFirst || isSubsequent -> - + | SynExpr.Lambda (isMember, isSubsequent, synSimplePats, bodyExpr, _parsedData, m, _trivia) when isMember || isFirst || isSubsequent -> let domainTy, resultTy = UnifyFunctionType None cenv env.DisplayEnv m overallTy.Commit + let isConstructor = + env.eCtorInfo + |> Option.map (fun ctorInfo -> ctorInfo.ctorIsImplicit) + |> Option.defaultValue false let vs, (TcPatLinearEnv (tpenv, names, takenNames)) = - cenv.TcSimplePats cenv isMember CheckCxs domainTy env (TcPatLinearEnv (tpenv, Map.empty, takenNames)) synSimplePats + cenv.TcSimplePats cenv isMember CheckCxs domainTy env (TcPatLinearEnv (tpenv, Map.empty, takenNames)) synSimplePats isConstructor let envinner, _, vspecMap = MakeAndPublishSimpleValsForMergedScope cenv env m names let byrefs = vspecMap |> Map.map (fun _ v -> isByrefTy g v.Type, v) @@ -10608,7 +10611,15 @@ and TcAndPatternCompileMatchClauses mExpr mMatch actionOnFailure cenv inputExprO and TcMatchPattern (cenv: cenv) inputTy env tpenv (synPat: SynPat) (synWhenExprOpt: SynExpr option) (isTrueMatchClause: bool) = let g = cenv.g let m = synPat.Range - let warnOnUpperFlag = if isTrueMatchClause then WarnOnUpperUnionCaseLabel else WarnOnUpperVariablePatterns + let hasConstructorShape = AreWithinCtorShape env + let warnOnUpperFlag = + if isTrueMatchClause && not hasConstructorShape then + WarnOnUpperUnionCaseLabel + elif hasConstructorShape then + AllIdsOK + else + WarnOnUpperVariablePatterns + let patf', (TcPatLinearEnv (tpenv, names, _)) = cenv.TcPat warnOnUpperFlag cenv env None (TcPatValFlags (ValInline.Optional, permitInferTypars, noArgOrRetAttribs, false, None, false)) (TcPatLinearEnv (tpenv, Map.empty, Set.empty)) inputTy synPat let envinner, values, vspecMap = MakeAndPublishSimpleValsForMergedScope cenv env m names @@ -11629,7 +11640,8 @@ and ApplyTypesFromArgumentPatterns (cenv: cenv, env, optionalArgsOK, ty, m, tpen let domainTy, resultTy = UnifyFunctionType None cenv env.DisplayEnv m ty // We apply the type information from the patterns by type checking the // "simple" patterns against 'domainTyR'. They get re-typechecked later. - ignore (cenv.TcSimplePats cenv optionalArgsOK CheckCxs domainTy env (TcPatLinearEnv (tpenv, Map.empty, Set.empty)) pushedPat) + let isConstructor = memberFlagsOpt |> Option.map (fun flags -> flags.MemberKind = SynMemberKind.Constructor) |> Option.defaultValue false + ignore (cenv.TcSimplePats cenv optionalArgsOK CheckCxs domainTy env (TcPatLinearEnv (tpenv, Map.empty, Set.empty)) pushedPat isConstructor) ApplyTypesFromArgumentPatterns (cenv, env, optionalArgsOK, resultTy, m, tpenv, NormalizedBindingRhs (morePushedPats, retInfoOpt, e), memberFlagsOpt) /// Check if the type annotations and inferred type information in a value give a diff --git a/src/Compiler/Service/FSharpProjectSnapshot.fs b/src/Compiler/Service/FSharpProjectSnapshot.fs index fbff9619b88..db3b3e7022f 100644 --- a/src/Compiler/Service/FSharpProjectSnapshot.fs +++ b/src/Compiler/Service/FSharpProjectSnapshot.fs @@ -67,7 +67,7 @@ module internal Helpers = /// A snapshot of an F# source file. [] -type FSharpFileSnapshot(FileName: string, Version: string, GetSource: unit -> Task) = +type FSharpFileSnapshot(fileName: string, version: string, getSource: unit -> Task) = static member Create(fileName: string, version: string, getSource: unit -> Task) = FSharpFileSnapshot(fileName, version, getSource) @@ -101,13 +101,13 @@ type FSharpFileSnapshot(FileName: string, Version: string, GetSource: unit -> Ta | DocumentSource.FileSystem -> FSharpFileSnapshot.CreateFromFileSystem fileName - member public _.FileName = FileName - member _.Version = Version - member _.GetSource() = GetSource() + member public _.FileName = fileName + member _.Version = version + member _.GetSource() = getSource () - member val IsSignatureFile = FileName |> isSignatureFile + member val IsSignatureFile = fileName |> isSignatureFile - member _.GetFileName() = FileName + member _.GetFileName() = fileName override this.Equals(o) = match o with @@ -124,19 +124,19 @@ type FSharpFileSnapshot(FileName: string, Version: string, GetSource: unit -> Ta /// A source file snapshot with loaded source text. type internal FSharpFileSnapshotWithSource - (FileName: string, SourceHash: ImmutableArray, Source: ISourceTextNew, IsLastCompiland: bool, IsExe: bool) = + (fileName: string, sourceHash: ImmutableArray, source: ISourceTextNew, isLastCompiland: bool, isExe: bool) = - let version = lazy (SourceHash.ToBuilder().ToArray()) + let version = lazy (sourceHash.ToBuilder().ToArray()) let stringVersion = lazy (version.Value |> BitConverter.ToString) member val Version = version.Value member val StringVersion = stringVersion.Value - member val IsSignatureFile = FileName |> isSignatureFile + member val IsSignatureFile = fileName |> isSignatureFile - member _.FileName = FileName - member _.Source = Source - member _.IsLastCompiland = IsLastCompiland - member _.IsExe = IsExe + member _.FileName = fileName + member _.Source = source + member _.IsLastCompiland = isLastCompiland + member _.IsExe = isExe interface IFileSnapshot with member this.FileName = this.FileName @@ -146,23 +146,23 @@ type internal FSharpFileSnapshotWithSource /// A source file snapshot with parsed syntax tree type internal FSharpParsedFile ( - FileName: string, - SyntaxTreeHash: byte array, - SourceText: ISourceText, - ParsedInput: ParsedInput, - ParseDiagnostics: (PhasedDiagnostic * FSharpDiagnosticSeverity)[] + fileName: string, + syntaxTreeHash: byte array, + sourceText: ISourceText, + parsedInput: ParsedInput, + parseDiagnostics: (PhasedDiagnostic * FSharpDiagnosticSeverity)[] ) = - member _.FileName = FileName - member _.SourceText = SourceText - member _.ParsedInput = ParsedInput - member _.ParseDiagnostics = ParseDiagnostics + member _.FileName = fileName + member _.SourceText = sourceText + member _.ParsedInput = parsedInput + member _.ParseDiagnostics = parseDiagnostics - member val IsSignatureFile = FileName |> isSignatureFile + member val IsSignatureFile = fileName |> isSignatureFile interface IFileSnapshot with member this.FileName = this.FileName - member this.Version = SyntaxTreeHash + member this.Version = syntaxTreeHash member this.IsSignatureFile = this.IsSignatureFile /// An on-disk reference needed for project compilation. @@ -362,34 +362,34 @@ and internal ProjectSnapshotWithSources = ProjectSnapshotBase Md5Hasher.addString ProjectFileName - |> Md5Hasher.addStrings OtherOptions - |> Md5Hasher.addBool IsIncompleteTypeCheckEnvironment - |> Md5Hasher.addBool UseScriptResolutionRules) + |> Md5Hasher.addString projectFileName + |> Md5Hasher.addStrings otherOptions + |> Md5Hasher.addBool isIncompleteTypeCheckEnvironment + |> Md5Hasher.addBool useScriptResolutionRules) let fullHash = lazy (hashForParsing.Value - |> Md5Hasher.addStrings (ReferencesOnDisk |> Seq.map (fun r -> r.Path)) - |> Md5Hasher.addDateTimes (ReferencesOnDisk |> Seq.map (fun r -> r.LastModified)) + |> Md5Hasher.addStrings (referencesOnDisk |> Seq.map (fun r -> r.Path)) + |> Md5Hasher.addDateTimes (referencesOnDisk |> Seq.map (fun r -> r.LastModified)) |> Md5Hasher.addBytes' ( - ReferencedProjects + referencedProjects |> Seq.map (function | FSharpReference(_name, p) -> p.ProjectSnapshot.SignatureVersion | PEReference(getStamp, _) -> Md5Hasher.empty |> Md5Hasher.addDateTime (getStamp ()) @@ -401,16 +401,16 @@ and internal ProjectCore let commandLineOptions = lazy (seq { - yield! OtherOptions + yield! otherOptions - for r in ReferencesOnDisk do + for r in referencesOnDisk do $"-r:{r.Path}" } |> Seq.toList) - let outputFileName = lazy (OtherOptions |> findOutputFileName) + let outputFileName = lazy (otherOptions |> findOutputFileName) - let key = lazy (ProjectFileName, outputFileName.Value |> Option.defaultValue "") + let key = lazy (projectFileName, outputFileName.Value |> Option.defaultValue "") let cacheKey = lazy @@ -420,26 +420,26 @@ and internal ProjectCore member _.GetVersion() = fullHashString.Value }) - member val ProjectDirectory = !! Path.GetDirectoryName(ProjectFileName) + member val ProjectDirectory = !! Path.GetDirectoryName(projectFileName) member _.OutputFileName = outputFileName.Value member _.Identifier: ProjectIdentifier = key.Value member _.Version = fullHash.Value - member _.Label = ProjectFileName |> shortPath + member _.Label = projectFileName |> shortPath member _.VersionForParsing = hashForParsing.Value member _.CommandLineOptions = commandLineOptions.Value - member _.ProjectFileName = ProjectFileName - member _.ProjectId = ProjectId - member _.ReferencesOnDisk = ReferencesOnDisk - member _.OtherOptions = OtherOptions - member _.ReferencedProjects = ReferencedProjects - member _.IsIncompleteTypeCheckEnvironment = IsIncompleteTypeCheckEnvironment - member _.UseScriptResolutionRules = UseScriptResolutionRules - member _.LoadTime = LoadTime - member _.UnresolvedReferences = UnresolvedReferences - member _.OriginalLoadReferences = OriginalLoadReferences - member _.Stamp = Stamp + member _.ProjectFileName = projectFileName + member _.ProjectId = projectId + member _.ReferencesOnDisk = referencesOnDisk + member _.OtherOptions = otherOptions + member _.ReferencedProjects = referencedProjects + member _.IsIncompleteTypeCheckEnvironment = isIncompleteTypeCheckEnvironment + member _.UseScriptResolutionRules = useScriptResolutionRules + member _.LoadTime = loadTime + member _.UnresolvedReferences = unresolvedReferences + member _.OriginalLoadReferences = originalLoadReferences + member _.Stamp = stamp member _.CacheKeyWith(label, version) = { new ICacheKey<_, _> with diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index 5158ac7f25c..c7ba529e02e 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -1039,11 +1039,11 @@ type internal TransparentCompiler return FSharpFileSnapshotWithSource( - FileName = file.FileName, - Source = source, - SourceHash = source.GetChecksum(), - IsLastCompiland = isLastCompiland, - IsExe = isExe + fileName = file.FileName, + source = source, + sourceHash = source.GetChecksum(), + isLastCompiland = isLastCompiland, + isExe = isExe ) } diff --git a/src/FSharp.Core/MutableTuple.fs b/src/FSharp.Core/MutableTuple.fs index a9292f1c48b..78a06bc4c76 100644 --- a/src/FSharp.Core/MutableTuple.fs +++ b/src/FSharp.Core/MutableTuple.fs @@ -28,7 +28,7 @@ type AnonymousObject<'T1> = val private item1: 'T1 member x.Item1 = x.item1 - new(Item1) = { item1 = Item1 } + new(item1) = { item1 = item1 } /// This type shouldn't be used directly from user code. /// @@ -39,7 +39,7 @@ type AnonymousObject<'T1, 'T2> = val private item2: 'T2 member x.Item2 = x.item2 - new(Item1, Item2) = { item1 = Item1; item2 = Item2 } + new(item1, item2) = { item1 = item1; item2 = item2 } /// This type shouldn't be used directly from user code. /// @@ -53,11 +53,11 @@ type AnonymousObject<'T1, 'T2, 'T3> = val private item3: 'T3 member x.Item3 = x.item3 - new(Item1, Item2, Item3) = + new(item1, item2, item3) = { - item1 = Item1 - item2 = Item2 - item3 = Item3 + item1 = item1 + item2 = item2 + item3 = item3 } /// This type shouldn't be used directly from user code. @@ -75,12 +75,12 @@ type AnonymousObject<'T1, 'T2, 'T3, 'T4> = val private item4: 'T4 member x.Item4 = x.item4 - new(Item1, Item2, Item3, Item4) = + new(item1, item2, item3, item4) = { - item1 = Item1 - item2 = Item2 - item3 = Item3 - item4 = Item4 + item1 = item1 + item2 = item2 + item3 = item3 + item4 = item4 } /// This type shouldn't be used directly from user code. @@ -101,13 +101,13 @@ type AnonymousObject<'T1, 'T2, 'T3, 'T4, 'T5> = val private item5: 'T5 member x.Item5 = x.item5 - new(Item1, Item2, Item3, Item4, Item5) = + new(item1, item2, item3, item4, item5) = { - item1 = Item1 - item2 = Item2 - item3 = Item3 - item4 = Item4 - item5 = Item5 + item1 = item1 + item2 = item2 + item3 = item3 + item4 = item4 + item5 = item5 } /// This type shouldn't be used directly from user code. @@ -131,14 +131,14 @@ type AnonymousObject<'T1, 'T2, 'T3, 'T4, 'T5, 'T6> = val private item6: 'T6 member x.Item6 = x.item6 - new(Item1, Item2, Item3, Item4, Item5, Item6) = + new(item1, item2, item3, item4, item5, item6) = { - item1 = Item1 - item2 = Item2 - item3 = Item3 - item4 = Item4 - item5 = Item5 - item6 = Item6 + item1 = item1 + item2 = item2 + item3 = item3 + item4 = item4 + item5 = item5 + item6 = item6 } /// This type shouldn't be used directly from user code. @@ -165,15 +165,15 @@ type AnonymousObject<'T1, 'T2, 'T3, 'T4, 'T5, 'T6, 'T7> = val private item7: 'T7 member x.Item7 = x.item7 - new(Item1, Item2, Item3, Item4, Item5, Item6, Item7) = + new(item1, item2, item3, item4, item5, item6, item7) = { - item1 = Item1 - item2 = Item2 - item3 = Item3 - item4 = Item4 - item5 = Item5 - item6 = Item6 - item7 = Item7 + item1 = item1 + item2 = item2 + item3 = item3 + item4 = item4 + item5 = item5 + item6 = item6 + item7 = item7 } /// This type shouldn't be used directly from user code. @@ -203,14 +203,14 @@ type AnonymousObject<'T1, 'T2, 'T3, 'T4, 'T5, 'T6, 'T7, 'T8> = val private item8: 'T8 member x.Item8 = x.item8 - new(Item1, Item2, Item3, Item4, Item5, Item6, Item7, Item8) = + new(item1, item2, item3, item4, item5, item6, item7, item8) = { - item1 = Item1 - item2 = Item2 - item3 = Item3 - item4 = Item4 - item5 = Item5 - item6 = Item6 - item7 = Item7 - item8 = Item8 + item1 = item1 + item2 = item2 + item3 = item3 + item4 = item4 + item5 = item5 + item6 = item6 + item7 = item7 + item8 = item8 } diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs index 79f83b0f52c..109d3c261b3 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs @@ -216,4 +216,5 @@ module BindingExpressions = (Warning 3874, Line 53, Col 18, Line 53, Col 21, "Variable patterns should be lowercase.") (Warning 3874, Line 57, Col 18, Line 57, Col 20, "Variable patterns should be lowercase.") (Warning 3874, Line 61, Col 6, Line 61, Col 8, "Variable patterns should be lowercase.") + (Warning 3874, Line 67, Col 9, Line 67, Col 14, "Variable patterns should be lowercase.") ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs index 268d677b86b..637adac38d2 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs @@ -58,4 +58,10 @@ for II in [1..10] do |> ignore try () -with Ex -> () \ No newline at end of file +with Ex -> () + +type AnonymousObject<'T1, 'T2> = + val private item1: 'T1 + member x.Item1 = x.item1 + + new(Item1) = { item1 = Item1 } \ No newline at end of file diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs index 37a8e25e164..e730356e63b 100644 --- a/tests/FSharp.Test.Utilities/CompilerAssert.fs +++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs @@ -945,9 +945,9 @@ Updated automatically, please check diffs in your pull request, changes must be let getFileSnapshot _ fileName = async.Return (FSharpFileSnapshot( - FileName = fileName, - Version = "1", - GetSource = fun () -> task { + fileName = fileName, + version = "1", + getSource = fun () -> task { match! getSourceText fileName with | Some source -> return SourceTextNew.ofISourceText source | None -> return failwith $"couldn't get source for {fileName}" diff --git a/tests/FSharp.Test.Utilities/ProjectGeneration.fs b/tests/FSharp.Test.Utilities/ProjectGeneration.fs index a75784240dd..d4cfea29edb 100644 --- a/tests/FSharp.Test.Utilities/ProjectGeneration.fs +++ b/tests/FSharp.Test.Utilities/ProjectGeneration.fs @@ -642,9 +642,9 @@ module ProjectOperations = let hash = md5.ComputeHash(inputBytes) |> Array.map (fun b -> b.ToString("X2")) |> String.concat "" return FSharpFileSnapshot( - FileName = filePath, - Version = hash, - GetSource = fun () -> source |> Task.FromResult + fileName = filePath, + version = hash, + getSource = fun () -> source |> Task.FromResult ) } @@ -858,9 +858,9 @@ module Helpers = let getSource _ fileName = FSharpFileSnapshot( - FileName = fileName, - Version = "1", - GetSource = fun () -> source |> SourceTextNew.ofString |> Task.FromResult ) + fileName = fileName, + version = "1", + getSource = fun () -> source |> SourceTextNew.ofString |> Task.FromResult ) |> async.Return let checker = FSharpChecker.Create( diff --git a/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs b/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs index 6c3b04f1844..1d95fe33773 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs @@ -141,7 +141,7 @@ module private CheckerExtensions = return sourceText.ToFSharpSourceText() } - return FSharpFileSnapshot(FileName = document.FilePath, Version = version.ToString(), GetSource = getSource) + return FSharpFileSnapshot(fileName = document.FilePath, version = version.ToString(), getSource = getSource) } let getReferencedProjectVersions (project: Project) = @@ -286,7 +286,7 @@ module private CheckerExtensions = async.Return(version.ToString(), getSource) - return FSharpFileSnapshot(FileName = path, Version = version, GetSource = getSource) + return FSharpFileSnapshot(fileName = path, version = version, getSource = getSource) } let! snapshot = diff --git a/vsintegration/tests/FSharp.Editor.Tests/Refactors/RefactorTestFramework.fs b/vsintegration/tests/FSharp.Editor.Tests/Refactors/RefactorTestFramework.fs index 849da8c84ec..0fd7796d238 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/Refactors/RefactorTestFramework.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/Refactors/RefactorTestFramework.fs @@ -15,8 +15,8 @@ open System.Threading let GetTaskResult (task: Tasks.Task<'T>) = task.GetAwaiter().GetResult() -type TestContext(Solution: Solution) = - let mutable _solution = Solution +type TestContext(solution: Solution) = + let mutable _solution = solution member _.CancellationToken = CancellationToken.None member _.Solution @@ -24,7 +24,7 @@ type TestContext(Solution: Solution) = and get () = _solution interface IDisposable with - member _.Dispose() = Solution.Workspace.Dispose() + member _.Dispose() = solution.Workspace.Dispose() static member CreateWithCode(code: string) = let solution = RoslynTestHelpers.CreateSolution(code) From 3be7320f7e4ac5e638d436d3d8a9dbd713aee95c Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sun, 27 Oct 2024 07:37:49 +0000 Subject: [PATCH 23/49] Improve error message for match cases labels and update tests --- src/Compiler/Checking/CheckBasics.fs | 2 +- src/Compiler/Checking/CheckBasics.fsi | 2 -- src/Compiler/Checking/CheckPatterns.fs | 22 ++++++------- src/Compiler/Checking/CheckPatterns.fsi | 1 - .../Checking/Expressions/CheckExpressions.fs | 15 ++------- src/Compiler/FSStrings.resx | 2 +- src/Compiler/xlf/FSStrings.cs.xlf | 2 +- src/Compiler/xlf/FSStrings.de.xlf | 2 +- src/Compiler/xlf/FSStrings.es.xlf | 2 +- src/Compiler/xlf/FSStrings.fr.xlf | 2 +- src/Compiler/xlf/FSStrings.it.xlf | 2 +- src/Compiler/xlf/FSStrings.ja.xlf | 2 +- src/Compiler/xlf/FSStrings.ko.xlf | 2 +- src/Compiler/xlf/FSStrings.pl.xlf | 2 +- src/Compiler/xlf/FSStrings.pt-BR.xlf | 2 +- src/Compiler/xlf/FSStrings.ru.xlf | 2 +- src/Compiler/xlf/FSStrings.tr.xlf | 2 +- src/Compiler/xlf/FSStrings.zh-Hans.xlf | 2 +- src/Compiler/xlf/FSStrings.zh-Hant.xlf | 2 +- .../BindingExpressions/BindingExpressions.fs | 3 ++ .../BindingExpressions/UpperBindingPattern.fs | 4 ++- .../PatternMatching/Simple/Simple.fs | 17 ++++++++-- .../PatternMatching/Union/Union.fs | 32 ++++++++++--------- .../Union/UpperUnionCasePattern.fs | 9 +++++- 24 files changed, 75 insertions(+), 60 deletions(-) diff --git a/src/Compiler/Checking/CheckBasics.fs b/src/Compiler/Checking/CheckBasics.fs index 79320899ebf..7cbca970cc3 100644 --- a/src/Compiler/Checking/CheckBasics.fs +++ b/src/Compiler/Checking/CheckBasics.fs @@ -325,7 +325,7 @@ type TcFileState = TcPat: WarnOnUpperFlag -> TcFileState -> TcEnv -> PrelimValReprInfo option -> TcPatValFlags -> TcPatLinearEnv -> TType -> SynPat -> (TcPatPhase2Input -> Pattern) * TcPatLinearEnv // forward call - TcSimplePats: TcFileState -> bool -> CheckConstraints -> TType -> TcEnv -> TcPatLinearEnv -> SynSimplePats -> bool -> string list * TcPatLinearEnv + TcSimplePats: TcFileState -> bool -> CheckConstraints -> TType -> TcEnv -> TcPatLinearEnv -> SynSimplePats -> string list * TcPatLinearEnv // forward call TcSequenceExpressionEntry: TcFileState -> TcEnv -> OverallTy -> UnscopedTyparEnv -> bool * SynExpr -> range -> Expr * UnscopedTyparEnv diff --git a/src/Compiler/Checking/CheckBasics.fsi b/src/Compiler/Checking/CheckBasics.fsi index d8928638107..179752c394c 100644 --- a/src/Compiler/Checking/CheckBasics.fsi +++ b/src/Compiler/Checking/CheckBasics.fsi @@ -295,7 +295,6 @@ type TcFileState = -> TcEnv -> TcPatLinearEnv -> SynSimplePats - -> bool -> string list * TcPatLinearEnv // forward call @@ -346,7 +345,6 @@ type TcFileState = -> TcEnv -> TcPatLinearEnv -> SynSimplePats - -> bool -> string list * TcPatLinearEnv) * tcSequenceExpressionEntry: (TcFileState -> TcEnv -> OverallTy -> UnscopedTyparEnv -> bool * SynExpr -> range -> Expr * UnscopedTyparEnv) * diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index daee08106ce..1c0a3931d31 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -58,11 +58,11 @@ let UnifyRefTupleType contextInfo (cenv: cenv) denv m ty ps = AddCxTypeEqualsType contextInfo denv cenv.css m ty (TType_tuple (tupInfoRef, ptys)) ptys -let rec TryAdjustHiddenVarNameToCompGenName (cenv: cenv) env (id: Ident) altNameRefCellOpt (isConstructor: bool) = +let rec TryAdjustHiddenVarNameToCompGenName (cenv: cenv) env (id: Ident) altNameRefCellOpt = match altNameRefCellOpt with | Some ({contents = SynSimplePatAlternativeIdInfo.Undecided altId } as altNameRefCell) -> let supportsWarnOnUpperIdentifiersInPatterns = cenv.g.langVersion.SupportsFeature(LanguageFeature.WarnOnUppercaseIdentifiersInPatterns) - let warnOnUpperFlag = if supportsWarnOnUpperIdentifiersInPatterns && not isConstructor then WarnOnUpperVariablePatterns else AllIdsOK + let warnOnUpperFlag = if supportsWarnOnUpperIdentifiersInPatterns then WarnOnUpperVariablePatterns else AllIdsOK match ResolvePatternLongIdent cenv.tcSink cenv.nameResolver warnOnUpperFlag false id.idRange env.eAccessRights env.eNameResEnv TypeNameResolutionInfo.Default [id] ExtraDotAfterIdentifier.No with | Item.NewDef _ -> // The name is not in scope as a pattern identifier (e.g. union case), so do not use the alternate ID @@ -75,7 +75,7 @@ let rec TryAdjustHiddenVarNameToCompGenName (cenv: cenv) env (id: Ident) altName | None -> None /// Bind the patterns used in a lambda. Not clear why we don't use TcPat. -and TcSimplePat optionalArgsOK checkConstraints (cenv: cenv) ty env patEnv p (isConstructor: bool) = +and TcSimplePat optionalArgsOK checkConstraints (cenv: cenv) ty env patEnv p = let g = cenv.g let (TcPatLinearEnv(tpenv, names, takenNames)) = patEnv @@ -83,9 +83,9 @@ and TcSimplePat optionalArgsOK checkConstraints (cenv: cenv) ty env patEnv p (is | SynSimplePat.Id (id, altNameRefCellOpt, isCompGen, isMemberThis, isOpt, m) -> // Check to see if pattern translation decides to use an alternative identifier. - match TryAdjustHiddenVarNameToCompGenName (cenv: cenv) env id altNameRefCellOpt isConstructor with + match TryAdjustHiddenVarNameToCompGenName (cenv: cenv) env id altNameRefCellOpt with | Some altId -> - TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv (SynSimplePat.Id (altId, None, isCompGen, isMemberThis, isOpt, m) ) isConstructor + TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv (SynSimplePat.Id (altId, None, isCompGen, isMemberThis, isOpt, m) ) | None -> if isOpt then if not optionalArgsOK then @@ -114,10 +114,10 @@ and TcSimplePat optionalArgsOK checkConstraints (cenv: cenv) ty env patEnv p (is | SynType.Var(typar = SynTypar(ident = untypedIdent)), TType_var(typar = typedTp) -> typedTp.SetIdent(untypedIdent) | _ -> () - TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnvR p isConstructor + TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnvR p | SynSimplePat.Attrib (p, _, _) -> - TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv p isConstructor + TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv p // raise an error if any optional args precede any non-optional args and ValidateOptArgOrder (synSimplePats: SynSimplePats) = @@ -140,7 +140,7 @@ and ValidateOptArgOrder (synSimplePats: SynSimplePats) = /// Bind the patterns used in argument position for a function, method or lambda. -and TcSimplePats (cenv: cenv) optionalArgsOK checkConstraints ty env patEnv synSimplePats (isConstructor: bool) = +and TcSimplePats (cenv: cenv) optionalArgsOK checkConstraints ty env patEnv synSimplePats = let g = cenv.g let (TcPatLinearEnv(tpenv, names, takenNames)) = patEnv @@ -165,12 +165,12 @@ and TcSimplePats (cenv: cenv) optionalArgsOK checkConstraints ty env patEnv synS [id.idText], patEnvR | SynSimplePats.SimplePats (pats = [synSimplePat]) -> - let v, patEnv = TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv synSimplePat isConstructor + let v, patEnv = TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv synSimplePat [v], patEnv | SynSimplePats.SimplePats (ps, _, m) -> let ptys = UnifyRefTupleType env.eContextInfo cenv env.DisplayEnv m ty ps - let ps', patEnvR = (patEnv, List.zip ptys ps) ||> List.mapFold (fun patEnv (ty, pat) -> TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv pat isConstructor) + let ps', patEnvR = (patEnv, List.zip ptys ps) ||> List.mapFold (fun patEnv (ty, pat) -> TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv pat) ps', patEnvR and TcSimplePatsOfUnknownType (cenv: cenv) optionalArgsOK checkConstraints env tpenv (pat: SynPat) = @@ -178,7 +178,7 @@ and TcSimplePatsOfUnknownType (cenv: cenv) optionalArgsOK checkConstraints env t let argTy = NewInferenceType g let patEnv = TcPatLinearEnv (tpenv, NameMap.empty, Set.empty) let spats, _ = SimplePatsOfPat cenv.synArgNameGenerator pat - let names, patEnv = TcSimplePats cenv optionalArgsOK checkConstraints argTy env patEnv spats false + let names, patEnv = TcSimplePats cenv optionalArgsOK checkConstraints argTy env patEnv spats names, patEnv, spats and TcPatBindingName cenv env id ty isMemberThis vis1 valReprInfo (vFlags: TcPatValFlags) (names, takenNames: Set) = diff --git a/src/Compiler/Checking/CheckPatterns.fsi b/src/Compiler/Checking/CheckPatterns.fsi index 02e34208c65..da797b35a88 100644 --- a/src/Compiler/Checking/CheckPatterns.fsi +++ b/src/Compiler/Checking/CheckPatterns.fsi @@ -39,5 +39,4 @@ val TcSimplePats: env: TcEnv -> patEnv: TcPatLinearEnv -> synSimplePats: SynSimplePats -> - isConstructor: bool -> string list * TcPatLinearEnv diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index 433b0293ac2..d31a7909273 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -6428,13 +6428,8 @@ and TcIteratedLambdas (cenv: cenv) isFirst (env: TcEnv) overallTy takenNames tpe match e with | SynExpr.Lambda (isMember, isSubsequent, synSimplePats, bodyExpr, _parsedData, m, _trivia) when isMember || isFirst || isSubsequent -> let domainTy, resultTy = UnifyFunctionType None cenv env.DisplayEnv m overallTy.Commit - let isConstructor = - env.eCtorInfo - |> Option.map (fun ctorInfo -> ctorInfo.ctorIsImplicit) - |> Option.defaultValue false - let vs, (TcPatLinearEnv (tpenv, names, takenNames)) = - cenv.TcSimplePats cenv isMember CheckCxs domainTy env (TcPatLinearEnv (tpenv, Map.empty, takenNames)) synSimplePats isConstructor + cenv.TcSimplePats cenv isMember CheckCxs domainTy env (TcPatLinearEnv (tpenv, Map.empty, takenNames)) synSimplePats let envinner, _, vspecMap = MakeAndPublishSimpleValsForMergedScope cenv env m names let byrefs = vspecMap |> Map.map (fun _ v -> isByrefTy g v.Type, v) @@ -10611,12 +10606,9 @@ and TcAndPatternCompileMatchClauses mExpr mMatch actionOnFailure cenv inputExprO and TcMatchPattern (cenv: cenv) inputTy env tpenv (synPat: SynPat) (synWhenExprOpt: SynExpr option) (isTrueMatchClause: bool) = let g = cenv.g let m = synPat.Range - let hasConstructorShape = AreWithinCtorShape env let warnOnUpperFlag = - if isTrueMatchClause && not hasConstructorShape then + if isTrueMatchClause then WarnOnUpperUnionCaseLabel - elif hasConstructorShape then - AllIdsOK else WarnOnUpperVariablePatterns @@ -11640,8 +11632,7 @@ and ApplyTypesFromArgumentPatterns (cenv: cenv, env, optionalArgsOK, ty, m, tpen let domainTy, resultTy = UnifyFunctionType None cenv env.DisplayEnv m ty // We apply the type information from the patterns by type checking the // "simple" patterns against 'domainTyR'. They get re-typechecked later. - let isConstructor = memberFlagsOpt |> Option.map (fun flags -> flags.MemberKind = SynMemberKind.Constructor) |> Option.defaultValue false - ignore (cenv.TcSimplePats cenv optionalArgsOK CheckCxs domainTy env (TcPatLinearEnv (tpenv, Map.empty, Set.empty)) pushedPat isConstructor) + ignore (cenv.TcSimplePats cenv optionalArgsOK CheckCxs domainTy env (TcPatLinearEnv (tpenv, Map.empty, Set.empty)) pushedPat) ApplyTypesFromArgumentPatterns (cenv, env, optionalArgsOK, resultTy, m, tpenv, NormalizedBindingRhs (morePushedPats, retInfoOpt, e), memberFlagsOpt) /// Check if the type annotations and inferred type information in a value give a diff --git a/src/Compiler/FSStrings.resx b/src/Compiler/FSStrings.resx index 383b4991105..f9ce0a55951 100644 --- a/src/Compiler/FSStrings.resx +++ b/src/Compiler/FSStrings.resx @@ -166,7 +166,7 @@ Type constraint mismatch. The type \n '{0}' \nis not compatible with type\n '{1}' {2}\n - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. + Match cases labels must be lowercase identifiers Discriminated union cases and exception labels must be uppercase identifiers diff --git a/src/Compiler/xlf/FSStrings.cs.xlf b/src/Compiler/xlf/FSStrings.cs.xlf index 20b53f76f45..4d8aa69f6a0 100644 --- a/src/Compiler/xlf/FSStrings.cs.xlf +++ b/src/Compiler/xlf/FSStrings.cs.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. + Match cases labels must be lowercase identifiers Identifikátory proměnných psané velkými písmeny se ve vzorech obecně nedoporučují. Můžou označovat chybějící otevřenou deklaraci nebo špatně napsaný název vzoru. diff --git a/src/Compiler/xlf/FSStrings.de.xlf b/src/Compiler/xlf/FSStrings.de.xlf index f58d3a4711d..19060b8fa9e 100644 --- a/src/Compiler/xlf/FSStrings.de.xlf +++ b/src/Compiler/xlf/FSStrings.de.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. + Match cases labels must be lowercase identifiers Variablenbezeichner in Großbuchstaben sollten im Allgemeinen nicht in Mustern verwendet werden und können ein Hinweis auf eine fehlende open-Deklaration oder einen falsch geschriebenen Musternamen sein. diff --git a/src/Compiler/xlf/FSStrings.es.xlf b/src/Compiler/xlf/FSStrings.es.xlf index 88a130d699d..421ef4684b1 100644 --- a/src/Compiler/xlf/FSStrings.es.xlf +++ b/src/Compiler/xlf/FSStrings.es.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. + Match cases labels must be lowercase identifiers En general, los identificadores de variables en mayúscula no deben usarse en patrones y pueden indicar una declaración abierta que falta o un nombre de patrón mal escrito. diff --git a/src/Compiler/xlf/FSStrings.fr.xlf b/src/Compiler/xlf/FSStrings.fr.xlf index 7d7badde4ed..c046ee511d9 100644 --- a/src/Compiler/xlf/FSStrings.fr.xlf +++ b/src/Compiler/xlf/FSStrings.fr.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. + Match cases labels must be lowercase identifiers Les identificateurs de variables en majuscules ne doivent généralement pas être utilisés dans les modèles. Ils peuvent indiquer une absence de déclaration open ou un nom de modèle mal orthographié. diff --git a/src/Compiler/xlf/FSStrings.it.xlf b/src/Compiler/xlf/FSStrings.it.xlf index f43c8e77851..a0eb386ed64 100644 --- a/src/Compiler/xlf/FSStrings.it.xlf +++ b/src/Compiler/xlf/FSStrings.it.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. + Match cases labels must be lowercase identifiers In genere è consigliabile non usare identificatori di variabili scritti in maiuscolo nei criteri perché potrebbero indicare una dichiarazione OPEN mancante o un nome di criterio con ortografia errata. diff --git a/src/Compiler/xlf/FSStrings.ja.xlf b/src/Compiler/xlf/FSStrings.ja.xlf index 6f0a3a978e9..5607c8bd89f 100644 --- a/src/Compiler/xlf/FSStrings.ja.xlf +++ b/src/Compiler/xlf/FSStrings.ja.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. + Match cases labels must be lowercase identifiers 通常、大文字の変数識別子はパターンに使用できません。また、欠落している open 宣言か、つづりが間違っているパターン名を示す可能性があります。 diff --git a/src/Compiler/xlf/FSStrings.ko.xlf b/src/Compiler/xlf/FSStrings.ko.xlf index 43e0a0f1739..01181cf9b33 100644 --- a/src/Compiler/xlf/FSStrings.ko.xlf +++ b/src/Compiler/xlf/FSStrings.ko.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. + Match cases labels must be lowercase identifiers 일반적으로 대문자 변수 식별자는 패턴에 사용하지 말아야 합니다. 이러한 식별자는 열려 있는 선언이 없거나 철자가 잘못된 패턴 이름을 나타낼 수 있습니다. diff --git a/src/Compiler/xlf/FSStrings.pl.xlf b/src/Compiler/xlf/FSStrings.pl.xlf index 3096fca8dbf..f0862814773 100644 --- a/src/Compiler/xlf/FSStrings.pl.xlf +++ b/src/Compiler/xlf/FSStrings.pl.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. + Match cases labels must be lowercase identifiers Identyfikatory zmiennych pisane wielkimi literami nie powinny być na ogół używane we wzorcach i mogą oznaczać brak deklaracji otwierającej lub błąd pisowni w nazwie wzorca. diff --git a/src/Compiler/xlf/FSStrings.pt-BR.xlf b/src/Compiler/xlf/FSStrings.pt-BR.xlf index ea48f4c3545..63261920e55 100644 --- a/src/Compiler/xlf/FSStrings.pt-BR.xlf +++ b/src/Compiler/xlf/FSStrings.pt-BR.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. + Match cases labels must be lowercase identifiers Identificadores de variáveis em maiúsculas geralmente não devem ser usados em padrões, podendo indicar uma declaração aberta ausente ou um nome de padrão escrito incorretamente. diff --git a/src/Compiler/xlf/FSStrings.ru.xlf b/src/Compiler/xlf/FSStrings.ru.xlf index 7cb20b5e8de..c72de8f2738 100644 --- a/src/Compiler/xlf/FSStrings.ru.xlf +++ b/src/Compiler/xlf/FSStrings.ru.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. + Match cases labels must be lowercase identifiers Идентификаторы переменных в верхнем регистре обычно не должны использоваться в шаблонах, и могут указывать на отсутствующую открытую декларацию или неправильно написанное имя шаблона. diff --git a/src/Compiler/xlf/FSStrings.tr.xlf b/src/Compiler/xlf/FSStrings.tr.xlf index 9c65fabe248..12c61f4d85e 100644 --- a/src/Compiler/xlf/FSStrings.tr.xlf +++ b/src/Compiler/xlf/FSStrings.tr.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. + Match cases labels must be lowercase identifiers Büyük harfli değişken tanımlayıcıları desenlerde genel olarak kullanılmamalıdır. Bunlar, eksik bir açık bildirimin veya yanlış yazılmış bir desen adının göstergesi olabilirler. diff --git a/src/Compiler/xlf/FSStrings.zh-Hans.xlf b/src/Compiler/xlf/FSStrings.zh-Hans.xlf index c895f08ec60..5886241f37b 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hans.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hans.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. + Match cases labels must be lowercase identifiers 通常不得在模式中使用大写的变量标识符,存在它们可能表示缺少某个开放声明或某个模式名称拼写错误。 diff --git a/src/Compiler/xlf/FSStrings.zh-Hant.xlf b/src/Compiler/xlf/FSStrings.zh-Hant.xlf index d81a539866e..2d7f19ec059 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hant.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hant.xlf @@ -153,7 +153,7 @@ - Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. + Match cases labels must be lowercase identifiers 通常不應在樣式中使用大寫的變數識別碼。這可能表示缺少公開宣告或樣式名稱拼字錯誤。 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs index 109d3c261b3..ce1a6a4bab0 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs @@ -168,6 +168,7 @@ module BindingExpressions = (Warning 3874, Line 42, Col 31, Line 42, Col 34, "Variable patterns should be lowercase.") (Warning 3874, Line 46, Col 5, Line 46, Col 8, "Variable patterns should be lowercase.") (Warning 3874, Line 53, Col 18, Line 53, Col 21, "Variable patterns should be lowercase.") + (Warning 3874, Line 67, Col 9, Line 67, Col 14, "Variable patterns should be lowercase.") ] [] @@ -217,4 +218,6 @@ module BindingExpressions = (Warning 3874, Line 57, Col 18, Line 57, Col 20, "Variable patterns should be lowercase.") (Warning 3874, Line 61, Col 6, Line 61, Col 8, "Variable patterns should be lowercase.") (Warning 3874, Line 67, Col 9, Line 67, Col 14, "Variable patterns should be lowercase.") + (Warning 3874, Line 69, Col 19, Line 69, Col 24, "Variable patterns should be lowercase."); + (Warning 3874, Line 69, Col 34, Line 69, Col 44, "Variable patterns should be lowercase.") ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs index 637adac38d2..b850772f5d7 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs @@ -64,4 +64,6 @@ type AnonymousObject<'T1, 'T2> = val private item1: 'T1 member x.Item1 = x.item1 - new(Item1) = { item1 = Item1 } \ No newline at end of file + new(Item1) = { item1 = Item1 } + +type FSharpSource(Item1: string, SourceHash: string) = class end \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs index 3cd93d8c562..bb805266898 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs @@ -45,8 +45,21 @@ module Simple = |> compile |> shouldFail |> withDiagnostics [ - (Warning 49, Line 9, Col 16, Line 9, Col 19, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 10, Col 16, Line 10, Col 19, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 9, Col 16, Line 9, Col 19, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 10, Col 16, Line 10, Col 19, "Match cases labels must be lowercase identifiers") + ] + + [] + let ``Simple - W_BindCapitalIdent_fs preview - --test:ErrorRanges`` compilation = + compilation + |> withLangVersionPreview + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldFail + |> withDiagnostics [ + (Warning 49, Line 9, Col 16, Line 9, Col 19, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 10, Col 16, Line 10, Col 19, "Match cases labels must be lowercase identifiers") ] // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs index a073d1ab934..7308f667601 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs @@ -219,10 +219,11 @@ but here has type |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 15, Col 7, Line 15, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 16, Col 7, Line 16, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 20, Col 7, Line 20, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 24, Col 3, Line 24, Col 6, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 15, Col 7, Line 15, Col 10, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 16, Col 7, Line 16, Col 10, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 20, Col 7, Line 20, Col 10, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 24, Col 3, Line 24, Col 6, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 35, Col 14, Line 35, Col 17, "Match cases labels must be lowercase identifiers") ] [] @@ -234,15 +235,16 @@ but here has type |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 3, Col 7, Line 3, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 4, Col 7, Line 4, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 5, Col 7, Line 5, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 9, Col 7, Line 9, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 10, Col 7, Line 10, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 11, Col 7, Line 11, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 15, Col 7, Line 15, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 16, Col 7, Line 16, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 20, Col 7, Line 20, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 24, Col 3, Line 24, Col 6, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 28, Col 3, Line 28, Col 5, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 3, Col 7, Line 3, Col 9, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 4, Col 7, Line 4, Col 9, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 5, Col 7, Line 5, Col 8, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 9, Col 7, Line 9, Col 9, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 10, Col 7, Line 10, Col 9, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 11, Col 7, Line 11, Col 8, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 15, Col 7, Line 15, Col 10, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 16, Col 7, Line 16, Col 10, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 20, Col 7, Line 20, Col 10, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 24, Col 3, Line 24, Col 6, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 28, Col 3, Line 28, Col 5, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 35, Col 14, Line 35, Col 17, "Match cases labels must be lowercase identifiers") ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs index dd94a1c50ea..41eb8ed5b9a 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs @@ -25,4 +25,11 @@ with try () with -| Ex -> () \ No newline at end of file +| Ex -> () + +type CustomerId = CustomerId of string + +let customerId = CustomerId("123") + +match customerId with +| CustomerId BBB -> () \ No newline at end of file From 2f5d8789a66b0691ea0c47b8ab26ffbb7bfe0cbc Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sun, 27 Oct 2024 07:47:26 +0000 Subject: [PATCH 24/49] update fsharpqa tests --- .../DataExpressions/QueryExpressions/W_UppercaseIdentifier01.fs | 2 +- .../DataExpressions/QueryExpressions/W_UppercaseIdentifier02.fs | 2 +- .../DataExpressions/QueryExpressions/W_UppercaseIdentifier03.fs | 2 +- .../Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fs | 2 +- .../LexicalAnalysis/Directives/multiple_nowarn01.fsx | 2 +- .../LexicalAnalysis/Directives/multiple_nowarn02.fsx | 2 +- .../LexicalAnalysis/Directives/multiple_nowarn_many.fs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier01.fs b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier01.fs index 1a425cc70ac..d12212f1fb8 100644 --- a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier01.fs +++ b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier01.fs @@ -1,7 +1,7 @@ // Regression test for DevDiv:305886 // [QueryExpressions] Identifiers for range variables in for-join queries cannot be uppercase! // We expect a simple warning. -//Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name\.$ +//Variable patterns should be lowercase\.$ module M // Warning diff --git a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier02.fs b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier02.fs index b7bcb21fffb..29994ff268c 100644 --- a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier02.fs +++ b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier02.fs @@ -1,7 +1,7 @@ // Regression test for DevDiv:305886 // [QueryExpressions] Identifiers for range variables in for-join queries cannot be uppercase! // We expect a simple warning. -//Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name\.$ +//Variable patterns should be lowercase\.$ module M // Warning diff --git a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier03.fs b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier03.fs index 0df77bb848e..f01a271fb54 100644 --- a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier03.fs +++ b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier03.fs @@ -1,7 +1,7 @@ // Regression test for DevDiv:305886 // [QueryExpressions] Identifiers for range variables in for-join queries cannot be uppercase! // We expect a simple warning. -//Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name\.$ +//Variable patterns should be lowercase\.$ module M // Warning diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fs b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fs index 726f2b8658b..4cd183da1f0 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fs +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fs @@ -1,7 +1,7 @@ // #Regression #Conformance #LexicalAnalysis #ReqNOMT // Regression test for FSHARP1.0:6044 -#nowarn "44" "49" +#nowarn "44" "3874" [] let obsoleteIdentifier = 12 diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fsx b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fsx index 726f2b8658b..4cd183da1f0 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fsx +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fsx @@ -1,7 +1,7 @@ // #Regression #Conformance #LexicalAnalysis #ReqNOMT // Regression test for FSHARP1.0:6044 -#nowarn "44" "49" +#nowarn "44" "3874" [] let obsoleteIdentifier = 12 diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn02.fsx b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn02.fsx index 02a97bb444e..699b5d7be57 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn02.fsx +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn02.fsx @@ -1,7 +1,7 @@ // #Regression #Conformance #LexicalAnalysis #ReqNOMT // Regression test for FSHARP1.0:6044 -#nowarn "44" "49" +#nowarn "44" "3874" [] let obsoleteIdentifier = 12 diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn_many.fs b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn_many.fs index c4c1f6278c7..d5e819f651e 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn_many.fs +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn_many.fs @@ -1,7 +1,7 @@ // #Regression #Conformance #LexicalAnalysis #ReqNOMT // Regression test for FSHARP1.0:6044 // 100 nowarns... -#nowarn "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44" "45" "46" "47" "48" "49" "50" "51" "52" "53" "54" "55" "56" "57" "58" "59" "60" "61" "62" "63" "64" "65" "66" "67" "68" "69" "70" "71" "72" "73" "74" "75" "76" "77" "78" "79" "80" "81" "82" "83" "84" "85" "86" "87" "88" "89" "90" "91" "92" "93" "94" "95" "96" "97" "98" "99" +#nowarn "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44" "45" "46" "47" "48" "3874" "50" "51" "52" "53" "54" "55" "56" "57" "58" "59" "60" "61" "62" "63" "64" "65" "66" "67" "68" "69" "70" "71" "72" "73" "74" "75" "76" "77" "78" "79" "80" "81" "82" "83" "84" "85" "86" "87" "88" "89" "90" "91" "92" "93" "94" "95" "96" "97" "98" "99" [] let obsoleteIdentifier = 12 From bf5ca004ad126029ee367d7de353ead3bb222d9e Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sun, 27 Oct 2024 07:53:30 +0000 Subject: [PATCH 25/49] more tests --- .../BindingExpressions/BindingExpressions.fs | 11 ++++- .../BindingExpressions/UpperBindingPattern.fs | 46 ++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs index ce1a6a4bab0..a62674d26b3 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs @@ -169,6 +169,9 @@ module BindingExpressions = (Warning 3874, Line 46, Col 5, Line 46, Col 8, "Variable patterns should be lowercase.") (Warning 3874, Line 53, Col 18, Line 53, Col 21, "Variable patterns should be lowercase.") (Warning 3874, Line 67, Col 9, Line 67, Col 14, "Variable patterns should be lowercase.") + (Warning 3874, Line 73, Col 9, Line 73, Col 18, "Variable patterns should be lowercase.") + (Warning 3874, Line 80, Col 9, Line 80, Col 18, "Variable patterns should be lowercase.") + (Warning 3874, Line 87, Col 9, Line 87, Col 18, "Variable patterns should be lowercase.") ] [] @@ -218,6 +221,12 @@ module BindingExpressions = (Warning 3874, Line 57, Col 18, Line 57, Col 20, "Variable patterns should be lowercase.") (Warning 3874, Line 61, Col 6, Line 61, Col 8, "Variable patterns should be lowercase.") (Warning 3874, Line 67, Col 9, Line 67, Col 14, "Variable patterns should be lowercase.") - (Warning 3874, Line 69, Col 19, Line 69, Col 24, "Variable patterns should be lowercase."); + (Warning 3874, Line 69, Col 19, Line 69, Col 24, "Variable patterns should be lowercase.") (Warning 3874, Line 69, Col 34, Line 69, Col 44, "Variable patterns should be lowercase.") + (Warning 3874, Line 73, Col 9, Line 73, Col 18, "Variable patterns should be lowercase.") + (Warning 3874, Line 80, Col 9, Line 80, Col 18, "Variable patterns should be lowercase.") + (Warning 3874, Line 87, Col 9, Line 87, Col 18, "Variable patterns should be lowercase.") + (Warning 3874, Line 95, Col 9, Line 95, Col 11, "Variable patterns should be lowercase.") + (Warning 3874, Line 102, Col 9, Line 102, Col 11, "Variable patterns should be lowercase.") + (Warning 3874, Line 109, Col 9, Line 109, Col 11, "Variable patterns should be lowercase.") ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs index b850772f5d7..81afd272108 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs @@ -66,4 +66,48 @@ type AnonymousObject<'T1, 'T2> = new(Item1) = { item1 = Item1 } -type FSharpSource(Item1: string, SourceHash: string) = class end \ No newline at end of file +type FSharpSource(Item1: string, SourceHash: string) = class end + +let _ = + query { + for UpperCase in [1..10] do + join b in [1..2] on (UpperCase = b) + select b +} + +let _ = + query { + for UpperCase in [1..10] do + groupBy UpperCase into g + select g.Key +} + +let _ = + query { + for UpperCase in [1..10] do + groupJoin UpperCase2 in [|1..2|] on (UpperCase = UpperCase2) into g + for k in g do + select (k + 1) +} + +let _ = + query { + for Up in [1..10] do + join b in [1..2] on (Up = b) + select b +} + +let _ = + query { + for Up in [1..10] do + groupBy Up into g + select g.Key +} + +let _ = + query { + for Up in [1..10] do + groupJoin U2 in [|1..2|] on (Up = U2) into g + for k in g do + select (k + 1) +} \ No newline at end of file From 2865c6aa64b6b2b8f295d04346c0c0f26a8310b4 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sun, 27 Oct 2024 07:55:55 +0000 Subject: [PATCH 26/49] release notes entry --- docs/release-notes/.VisualStudio/17.13.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/.VisualStudio/17.13.md b/docs/release-notes/.VisualStudio/17.13.md index dae07600e1b..e54ebfb75b0 100644 --- a/docs/release-notes/.VisualStudio/17.13.md +++ b/docs/release-notes/.VisualStudio/17.13.md @@ -4,5 +4,6 @@ * Code fix for adding missing `seq`. ([PR #17772](https://github.com/dotnet/fsharp/pull/17772)) ### Changed +* Warn on uppercase identifiers in patterns. ([PR #15816](https://github.com/dotnet/fsharp/pull/15816)) ### Breaking Changes From 0c50d4cab80f15680bf0a53688d7418f1bd58ec6 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sun, 27 Oct 2024 08:02:31 +0000 Subject: [PATCH 27/49] reduce diff --- src/Compiler/Checking/CheckPatterns.fs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index 1c0a3931d31..df72f1d299c 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -83,7 +83,7 @@ and TcSimplePat optionalArgsOK checkConstraints (cenv: cenv) ty env patEnv p = | SynSimplePat.Id (id, altNameRefCellOpt, isCompGen, isMemberThis, isOpt, m) -> // Check to see if pattern translation decides to use an alternative identifier. - match TryAdjustHiddenVarNameToCompGenName (cenv: cenv) env id altNameRefCellOpt with + match TryAdjustHiddenVarNameToCompGenName cenv env id altNameRefCellOpt with | Some altId -> TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv (SynSimplePat.Id (altId, None, isCompGen, isMemberThis, isOpt, m) ) | None -> @@ -141,6 +141,7 @@ and ValidateOptArgOrder (synSimplePats: SynSimplePats) = /// Bind the patterns used in argument position for a function, method or lambda. and TcSimplePats (cenv: cenv) optionalArgsOK checkConstraints ty env patEnv synSimplePats = + let g = cenv.g let (TcPatLinearEnv(tpenv, names, takenNames)) = patEnv @@ -170,7 +171,7 @@ and TcSimplePats (cenv: cenv) optionalArgsOK checkConstraints ty env patEnv synS | SynSimplePats.SimplePats (ps, _, m) -> let ptys = UnifyRefTupleType env.eContextInfo cenv env.DisplayEnv m ty ps - let ps', patEnvR = (patEnv, List.zip ptys ps) ||> List.mapFold (fun patEnv (ty, pat) -> TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv pat) + let ps', patEnvR = (patEnv, List.zip ptys ps) ||> List.mapFold (fun patEnv (ty, pat) -> TcSimplePat optionalArgsOK checkConstraints cenv ty env patEnv pat) ps', patEnvR and TcSimplePatsOfUnknownType (cenv: cenv) optionalArgsOK checkConstraints env tpenv (pat: SynPat) = From 8f69e6774f611ae1bde4cef975597d8e2234c0e8 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sun, 27 Oct 2024 10:28:21 +0000 Subject: [PATCH 28/49] update tests --- tests/fsharp/typecheck/sigs/neg07.bsl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/fsharp/typecheck/sigs/neg07.bsl b/tests/fsharp/typecheck/sigs/neg07.bsl index 3a32ac5abb8..196bd70b314 100644 --- a/tests/fsharp/typecheck/sigs/neg07.bsl +++ b/tests/fsharp/typecheck/sigs/neg07.bsl @@ -1,21 +1,21 @@ -neg07.fs(7,10,7,29): typecheck error FS0049: Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. +neg07.fs(7,10,7,29): typecheck error FS3874: typecheck error FS3874: Variable patterns should be lowercase. neg07.fs(24,13,24,23): typecheck error FS0039: The value or constructor 'UnionCase1' is not defined. Maybe you want one of the following: X.UnionCase1 -neg07.fs(27,11,27,21): typecheck error FS0049: Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. +neg07.fs(27,11,27,21): typecheck error FS0049: Match cases labels must be lowercase identifiers -neg07.fs(28,11,28,21): typecheck error FS0049: Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. +neg07.fs(28,11,28,21): typecheck error FS0049: Match cases labels must be lowercase identifiers neg07.fs(28,11,28,21): typecheck error FS0026: This rule will never be matched neg07.fs(31,18,31,28): typecheck error FS0039: The value or constructor 'UnionCase1' is not defined. Maybe you want one of the following: X.UnionCase1 -neg07.fs(35,11,35,21): typecheck error FS0049: Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. +neg07.fs(35,11,35,21): typecheck error FS0049: Match cases labels must be lowercase identifiers -neg07.fs(36,11,36,21): typecheck error FS0049: Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. +neg07.fs(36,11,36,21): typecheck error FS0049: Match cases labels must be lowercase identifiers neg07.fs(36,11,36,21): typecheck error FS0026: This rule will never be matched From 2f360bfcd0b957f1d92e86d47ad0fe96f46e3bb3 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sun, 27 Oct 2024 19:19:04 +0000 Subject: [PATCH 29/49] update tests --- src/Compiler/Checking/CheckPatterns.fs | 9 +++++++-- .../Expressions/BindingExpressions/BindingExpressions.fs | 6 ++++++ .../BindingExpressions/UpperBindingPattern.fs | 8 +++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index df72f1d299c..abe1d46a4b8 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -718,10 +718,15 @@ and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (m for remainingArg in remaining do errorR (UnionCaseWrongArguments (env.DisplayEnv, numArgTys, numArgs, remainingArg.Range)) args, extraPatterns @ remaining + + let warnOnUpperForId = + if g.langVersion.SupportsFeature(LanguageFeature.WarnOnUppercaseIdentifiersInPatterns) then + WarnOnUpperVariablePatterns + else warnOnUpper let extraPatterns = extraPatterns @ extraPatternsFromNames - let argsR, acc = TcPatterns warnOnUpper cenv env vFlags patEnv argTys args - let _, acc = TcPatterns warnOnUpper cenv env vFlags acc (NewInferenceTypes g extraPatterns) extraPatterns + let argsR, acc = TcPatterns warnOnUpperForId cenv env vFlags patEnv argTys args + let _, acc = TcPatterns warnOnUpperForId cenv env vFlags acc (NewInferenceTypes g extraPatterns) extraPatterns (fun values -> mkf m (List.map (fun f -> f values) argsR)), acc /// Check a long identifier that has been resolved to an IL field - valid if a literal diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs index a62674d26b3..8d44801ec7d 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs @@ -172,6 +172,7 @@ module BindingExpressions = (Warning 3874, Line 73, Col 9, Line 73, Col 18, "Variable patterns should be lowercase.") (Warning 3874, Line 80, Col 9, Line 80, Col 18, "Variable patterns should be lowercase.") (Warning 3874, Line 87, Col 9, Line 87, Col 18, "Variable patterns should be lowercase.") + (Warning 3874, Line 117, Col 37, Line 117, Col 40, "Variable patterns should be lowercase.") ] [] @@ -213,6 +214,7 @@ module BindingExpressions = (Warning 3874, Line 32, Col 25, Line 32, Col 28, "Variable patterns should be lowercase.") (Warning 3874, Line 34, Col 21, Line 34, Col 24, "Variable patterns should be lowercase.") (Warning 3874, Line 34, Col 25, Line 34, Col 28, "Variable patterns should be lowercase.") + (Warning 3874, Line 40, Col 17, Line 40, Col 20, "Variable patterns should be lowercase.") (Warning 3874, Line 42, Col 31, Line 42, Col 34, "Variable patterns should be lowercase.") (Warning 3874, Line 44, Col 32, Line 44, Col 34, "Variable patterns should be lowercase.") (Warning 3874, Line 46, Col 5, Line 46, Col 8, "Variable patterns should be lowercase.") @@ -229,4 +231,8 @@ module BindingExpressions = (Warning 3874, Line 95, Col 9, Line 95, Col 11, "Variable patterns should be lowercase.") (Warning 3874, Line 102, Col 9, Line 102, Col 11, "Variable patterns should be lowercase.") (Warning 3874, Line 109, Col 9, Line 109, Col 11, "Variable patterns should be lowercase.") + (Warning 3874, Line 117, Col 33, Line 117, Col 35, "Variable patterns should be lowercase.") + (Warning 3874, Line 117, Col 37, Line 117, Col 40, "Variable patterns should be lowercase.") + (Warning 3874, Line 119, Col 18, Line 119, Col 20, "Variable patterns should be lowercase.") + (Warning 3874, Line 119, Col 22, Line 119, Col 24, "Variable patterns should be lowercase.") ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs index 81afd272108..3cf191dac08 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs @@ -110,4 +110,10 @@ let _ = groupJoin U2 in [|1..2|] on (Up = U2) into g for k in g do select (k + 1) -} \ No newline at end of file +} + +type CustomerId2 = CustomerId2 of string * string + +let getCustomerId3 (CustomerId2(AA, BBB)) = id + +let (CustomerId2(AA, Bb)) = CustomerId2("AA", "BB") \ No newline at end of file From 724dc0b52b5bc848239b6c95bbc032bc04ce6937 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sun, 27 Oct 2024 21:57:53 +0000 Subject: [PATCH 30/49] more tests --- src/Compiler/Checking/CheckPatterns.fs | 14 +++++++------- .../BindingExpressions/BindingExpressions.fs | 16 ++++++++-------- .../Conformance/PatternMatching/Union/Union.fs | 3 +++ .../Union/UpperUnionCasePattern.fs | 9 ++++++++- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index abe1d46a4b8..ea6b56e021d 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -531,6 +531,11 @@ and TcPatLongIdent warnOnUpper cenv env ad valReprInfo vFlags (patEnv: TcPatLine TcPatLongIdentActivePatternCase warnOnUpper cenv env vFlags patEnv ty (mLongId, item, apref, args, m) | Item.UnionCase _ | Item.ExnCase _ as item -> + let warnOnUpper = + if cenv.g.langVersion.SupportsFeature(LanguageFeature.WarnOnUppercaseIdentifiersInPatterns) then + WarnOnUpperUnionCaseLabel + else warnOnUpper + TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (mLongId, item, args, m) | Item.ILField finfo -> @@ -718,15 +723,10 @@ and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (m for remainingArg in remaining do errorR (UnionCaseWrongArguments (env.DisplayEnv, numArgTys, numArgs, remainingArg.Range)) args, extraPatterns @ remaining - - let warnOnUpperForId = - if g.langVersion.SupportsFeature(LanguageFeature.WarnOnUppercaseIdentifiersInPatterns) then - WarnOnUpperVariablePatterns - else warnOnUpper let extraPatterns = extraPatterns @ extraPatternsFromNames - let argsR, acc = TcPatterns warnOnUpperForId cenv env vFlags patEnv argTys args - let _, acc = TcPatterns warnOnUpperForId cenv env vFlags acc (NewInferenceTypes g extraPatterns) extraPatterns + let argsR, acc = TcPatterns warnOnUpper cenv env vFlags patEnv argTys args + let _, acc = TcPatterns warnOnUpper cenv env vFlags acc (NewInferenceTypes g extraPatterns) extraPatterns (fun values -> mkf m (List.map (fun f -> f values) argsR)), acc /// Check a long identifier that has been resolved to an IL field - valid if a literal diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs index 8d44801ec7d..ef70e2c2305 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs @@ -214,9 +214,9 @@ module BindingExpressions = (Warning 3874, Line 32, Col 25, Line 32, Col 28, "Variable patterns should be lowercase.") (Warning 3874, Line 34, Col 21, Line 34, Col 24, "Variable patterns should be lowercase.") (Warning 3874, Line 34, Col 25, Line 34, Col 28, "Variable patterns should be lowercase.") - (Warning 3874, Line 40, Col 17, Line 40, Col 20, "Variable patterns should be lowercase.") - (Warning 3874, Line 42, Col 31, Line 42, Col 34, "Variable patterns should be lowercase.") - (Warning 3874, Line 44, Col 32, Line 44, Col 34, "Variable patterns should be lowercase.") + (Warning 49, Line 40, Col 17, Line 40, Col 20, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 42, Col 31, Line 42, Col 34, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 44, Col 32, Line 44, Col 34, "Match cases labels must be lowercase identifiers") (Warning 3874, Line 46, Col 5, Line 46, Col 8, "Variable patterns should be lowercase.") (Warning 3874, Line 49, Col 5, Line 49, Col 7, "Variable patterns should be lowercase.") (Warning 3874, Line 53, Col 18, Line 53, Col 21, "Variable patterns should be lowercase.") @@ -231,8 +231,8 @@ module BindingExpressions = (Warning 3874, Line 95, Col 9, Line 95, Col 11, "Variable patterns should be lowercase.") (Warning 3874, Line 102, Col 9, Line 102, Col 11, "Variable patterns should be lowercase.") (Warning 3874, Line 109, Col 9, Line 109, Col 11, "Variable patterns should be lowercase.") - (Warning 3874, Line 117, Col 33, Line 117, Col 35, "Variable patterns should be lowercase.") - (Warning 3874, Line 117, Col 37, Line 117, Col 40, "Variable patterns should be lowercase.") - (Warning 3874, Line 119, Col 18, Line 119, Col 20, "Variable patterns should be lowercase.") - (Warning 3874, Line 119, Col 22, Line 119, Col 24, "Variable patterns should be lowercase.") - ] \ No newline at end of file + (Warning 49, Line 117, Col 33, Line 117, Col 35, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 117, Col 37, Line 117, Col 40, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 119, Col 18, Line 119, Col 20, "Match cases labels must be lowercase identifiers"); + (Warning 49, Line 119, Col 22, Line 119, Col 24, "Match cases labels must be lowercase identifiers") + ] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs index 7308f667601..41aca215752 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs @@ -247,4 +247,7 @@ but here has type (Warning 49, Line 24, Col 3, Line 24, Col 6, "Match cases labels must be lowercase identifiers") (Warning 49, Line 28, Col 3, Line 28, Col 5, "Match cases labels must be lowercase identifiers") (Warning 49, Line 35, Col 14, Line 35, Col 17, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 40, Col 12, Line 40, Col 14, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 41, Col 12, Line 41, Col 14, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 42, Col 12, Line 42, Col 14, "Match cases labels must be lowercase identifiers") ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs index 41eb8ed5b9a..447a8faaa17 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs @@ -32,4 +32,11 @@ type CustomerId = CustomerId of string let customerId = CustomerId("123") match customerId with -| CustomerId BBB -> () \ No newline at end of file +| CustomerId BBB -> () + +type Record = { Name: string; Age: int } + +match { Name = "Alice"; Age = 30 } with +| { Name = Al } -> printfn "Alice" +| { Name = Bo } -> printfn "Bob" +| { Name = Pe } -> printfn "Pepe" \ No newline at end of file From 573a1a06e0e106bd96ef5cff59be0de987d7aacc Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 29 Oct 2024 18:51:21 +0000 Subject: [PATCH 31/49] Do't want for WarnOnUpperVariablePatterns in preview --- src/Compiler/Checking/NameResolution.fs | 2 +- .../BindingExpressions/BindingExpressions.fs | 46 +------------------ 2 files changed, 2 insertions(+), 46 deletions(-) diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index 845ed98e360..a9890eedb50 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -3397,7 +3397,7 @@ let rec ResolvePatternLongIdentPrim sink (ncenv: NameResolver) fullyQualified wa then match warnOnUpper with | WarnOnUpperUnionCaseLabel -> warning(UpperCaseIdentifierInPattern m) - | WarnOnUpperVariablePatterns -> warning(Error(FSComp.SR.chkVariablePatternUppercase(), m)) + | WarnOnUpperVariablePatterns | AllIdsOK -> () else if not newDef diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs index ef70e2c2305..d03fca69c87 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs @@ -184,55 +184,11 @@ module BindingExpressions = |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 3874, Line 3, Col 8, Line 3, Col 10, "Variable patterns should be lowercase.") - (Warning 3874, Line 3, Col 11, Line 3, Col 13, "Variable patterns should be lowercase.") - (Warning 3874, Line 5, Col 8, Line 5, Col 10, "Variable patterns should be lowercase.") - (Warning 3874, Line 5, Col 11, Line 5, Col 13, "Variable patterns should be lowercase.") - (Warning 3874, Line 7, Col 8, Line 7, Col 9, "Variable patterns should be lowercase.") - (Warning 3874, Line 7, Col 10, Line 7, Col 11, "Variable patterns should be lowercase.") - (Warning 3874, Line 11, Col 8, Line 11, Col 11, "Variable patterns should be lowercase.") - (Warning 3874, Line 11, Col 12, Line 11, Col 15, "Variable patterns should be lowercase.") - (Warning 3874, Line 13, Col 8, Line 13, Col 11, "Variable patterns should be lowercase.") - (Warning 3874, Line 13, Col 12, Line 13, Col 15, "Variable patterns should be lowercase.") - (Warning 3874, Line 16, Col 22, Line 16, Col 24, "Variable patterns should be lowercase.") - (Warning 3874, Line 16, Col 26, Line 16, Col 28, "Variable patterns should be lowercase.") - (Warning 3874, Line 18, Col 22, Line 18, Col 24, "Variable patterns should be lowercase.") - (Warning 3874, Line 18, Col 25, Line 18, Col 27, "Variable patterns should be lowercase.") - (Warning 3874, Line 20, Col 22, Line 20, Col 23, "Variable patterns should be lowercase.") - (Warning 3874, Line 20, Col 24, Line 20, Col 25, "Variable patterns should be lowercase.") - (Warning 3874, Line 22, Col 22, Line 22, Col 25, "Variable patterns should be lowercase.") - (Warning 3874, Line 22, Col 27, Line 22, Col 30, "Variable patterns should be lowercase.") - (Warning 3874, Line 24, Col 22, Line 24, Col 25, "Variable patterns should be lowercase.") - (Warning 3874, Line 24, Col 26, Line 24, Col 29, "Variable patterns should be lowercase.") - (Warning 3874, Line 26, Col 20, Line 26, Col 22, "Variable patterns should be lowercase.") - (Warning 3874, Line 26, Col 24, Line 26, Col 26, "Variable patterns should be lowercase.") - (Warning 3874, Line 28, Col 20, Line 28, Col 22, "Variable patterns should be lowercase.") - (Warning 3874, Line 28, Col 23, Line 28, Col 25, "Variable patterns should be lowercase.") - (Warning 3874, Line 30, Col 20, Line 30, Col 21, "Variable patterns should be lowercase.") - (Warning 3874, Line 30, Col 22, Line 30, Col 23, "Variable patterns should be lowercase.") - (Warning 3874, Line 32, Col 20, Line 32, Col 23, "Variable patterns should be lowercase.") - (Warning 3874, Line 32, Col 25, Line 32, Col 28, "Variable patterns should be lowercase.") - (Warning 3874, Line 34, Col 21, Line 34, Col 24, "Variable patterns should be lowercase.") - (Warning 3874, Line 34, Col 25, Line 34, Col 28, "Variable patterns should be lowercase.") (Warning 49, Line 40, Col 17, Line 40, Col 20, "Match cases labels must be lowercase identifiers") (Warning 49, Line 42, Col 31, Line 42, Col 34, "Match cases labels must be lowercase identifiers") (Warning 49, Line 44, Col 32, Line 44, Col 34, "Match cases labels must be lowercase identifiers") - (Warning 3874, Line 46, Col 5, Line 46, Col 8, "Variable patterns should be lowercase.") - (Warning 3874, Line 49, Col 5, Line 49, Col 7, "Variable patterns should be lowercase.") - (Warning 3874, Line 53, Col 18, Line 53, Col 21, "Variable patterns should be lowercase.") - (Warning 3874, Line 57, Col 18, Line 57, Col 20, "Variable patterns should be lowercase.") - (Warning 3874, Line 61, Col 6, Line 61, Col 8, "Variable patterns should be lowercase.") - (Warning 3874, Line 67, Col 9, Line 67, Col 14, "Variable patterns should be lowercase.") - (Warning 3874, Line 69, Col 19, Line 69, Col 24, "Variable patterns should be lowercase.") - (Warning 3874, Line 69, Col 34, Line 69, Col 44, "Variable patterns should be lowercase.") - (Warning 3874, Line 73, Col 9, Line 73, Col 18, "Variable patterns should be lowercase.") - (Warning 3874, Line 80, Col 9, Line 80, Col 18, "Variable patterns should be lowercase.") - (Warning 3874, Line 87, Col 9, Line 87, Col 18, "Variable patterns should be lowercase.") - (Warning 3874, Line 95, Col 9, Line 95, Col 11, "Variable patterns should be lowercase.") - (Warning 3874, Line 102, Col 9, Line 102, Col 11, "Variable patterns should be lowercase.") - (Warning 3874, Line 109, Col 9, Line 109, Col 11, "Variable patterns should be lowercase.") (Warning 49, Line 117, Col 33, Line 117, Col 35, "Match cases labels must be lowercase identifiers") (Warning 49, Line 117, Col 37, Line 117, Col 40, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 119, Col 18, Line 119, Col 20, "Match cases labels must be lowercase identifiers"); + (Warning 49, Line 119, Col 18, Line 119, Col 20, "Match cases labels must be lowercase identifiers") (Warning 49, Line 119, Col 22, Line 119, Col 24, "Match cases labels must be lowercase identifiers") ] From cd0521c68bfd2977ef7248766bafe1cd6336fb40 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 29 Oct 2024 18:53:28 +0000 Subject: [PATCH 32/49] revert changes from MutableTuple --- src/FSharp.Core/MutableTuple.fs | 84 ++++++++++++++++----------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/src/FSharp.Core/MutableTuple.fs b/src/FSharp.Core/MutableTuple.fs index 78a06bc4c76..a71c33e442f 100644 --- a/src/FSharp.Core/MutableTuple.fs +++ b/src/FSharp.Core/MutableTuple.fs @@ -28,7 +28,7 @@ type AnonymousObject<'T1> = val private item1: 'T1 member x.Item1 = x.item1 - new(item1) = { item1 = item1 } + new(Item1) = { item1 = Item1 } /// This type shouldn't be used directly from user code. /// @@ -39,7 +39,7 @@ type AnonymousObject<'T1, 'T2> = val private item2: 'T2 member x.Item2 = x.item2 - new(item1, item2) = { item1 = item1; item2 = item2 } + new(Item1, Item2) = { item1 = Item1; item2 = Item2 } /// This type shouldn't be used directly from user code. /// @@ -53,11 +53,11 @@ type AnonymousObject<'T1, 'T2, 'T3> = val private item3: 'T3 member x.Item3 = x.item3 - new(item1, item2, item3) = + new(Item1, Item2, Item3) = { - item1 = item1 - item2 = item2 - item3 = item3 + item1 = Item1 + item2 = Item2 + item3 = Item3 } /// This type shouldn't be used directly from user code. @@ -75,12 +75,12 @@ type AnonymousObject<'T1, 'T2, 'T3, 'T4> = val private item4: 'T4 member x.Item4 = x.item4 - new(item1, item2, item3, item4) = + new(Item1, Item2, Item3, Item4) = { - item1 = item1 - item2 = item2 - item3 = item3 - item4 = item4 + item1 = Item1 + item2 = Item2 + item3 = Item3 + item4 = Item4 } /// This type shouldn't be used directly from user code. @@ -101,13 +101,13 @@ type AnonymousObject<'T1, 'T2, 'T3, 'T4, 'T5> = val private item5: 'T5 member x.Item5 = x.item5 - new(item1, item2, item3, item4, item5) = + new(Item1, Item2, Item3, Item4, Item5) = { - item1 = item1 - item2 = item2 - item3 = item3 - item4 = item4 - item5 = item5 + item1 = Item1 + item2 = Item2 + item3 = Item3 + item4 = Item4 + item5 = Item5 } /// This type shouldn't be used directly from user code. @@ -131,14 +131,14 @@ type AnonymousObject<'T1, 'T2, 'T3, 'T4, 'T5, 'T6> = val private item6: 'T6 member x.Item6 = x.item6 - new(item1, item2, item3, item4, item5, item6) = + new(Item1, Item2, Item3, Item4, Item5, Item6) = { - item1 = item1 - item2 = item2 - item3 = item3 - item4 = item4 - item5 = item5 - item6 = item6 + item1 = Item1 + item2 = Item2 + item3 = Item3 + item4 = Item4 + item5 = Item5 + item6 = Item6 } /// This type shouldn't be used directly from user code. @@ -165,15 +165,15 @@ type AnonymousObject<'T1, 'T2, 'T3, 'T4, 'T5, 'T6, 'T7> = val private item7: 'T7 member x.Item7 = x.item7 - new(item1, item2, item3, item4, item5, item6, item7) = + new(Item1, Item2, Item3, Item4, Item5, Item6, Item7) = { - item1 = item1 - item2 = item2 - item3 = item3 - item4 = item4 - item5 = item5 - item6 = item6 - item7 = item7 + item1 = Item1 + item2 = Item2 + item3 = Item3 + item4 = Item4 + item5 = Item5 + item6 = Item6 + item7 = Item7 } /// This type shouldn't be used directly from user code. @@ -203,14 +203,14 @@ type AnonymousObject<'T1, 'T2, 'T3, 'T4, 'T5, 'T6, 'T7, 'T8> = val private item8: 'T8 member x.Item8 = x.item8 - new(item1, item2, item3, item4, item5, item6, item7, item8) = + new(Item1, Item2, Item3, Item4, Item5, Item6, Item7, Item8) = { - item1 = item1 - item2 = item2 - item3 = item3 - item4 = item4 - item5 = item5 - item6 = item6 - item7 = item7 - item8 = item8 - } + item1 = Item1 + item2 = Item2 + item3 = Item3 + item4 = Item4 + item5 = Item5 + item6 = Item6 + item7 = Item7 + item8 = Item8 + } \ No newline at end of file From dd8a79c1375b3a0a69fad9ba372b8bea8a0a25db Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 29 Oct 2024 18:55:32 +0000 Subject: [PATCH 33/49] revert changes from Query.fs --- src/FSharp.Core/Query.fs | 48 +++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/FSharp.Core/Query.fs b/src/FSharp.Core/Query.fs index 22f326117d8..a5b270e7b55 100644 --- a/src/FSharp.Core/Query.fs +++ b/src/FSharp.Core/Query.fs @@ -452,14 +452,14 @@ module Query = let FuncExprToLinqFunc2 (srcTy, targetTy, v, body) = FuncExprToDelegateExpr(srcTy, targetTy, v, body) |> LeafExpressionConverter.EvaluateQuotation - let MakersCallers f = CallGenericStaticMethod f, MakeGenericStaticMethod f + let MakersCallers F = CallGenericStaticMethod F, MakeGenericStaticMethod F - let MakersCallersInstance f = CallGenericInstanceMethod f, MakeGenericInstanceMethod f + let MakersCallersInstance F = CallGenericInstanceMethod F, MakeGenericInstanceMethod F - let MakersCallers2 fQ fE = MakersCallers fQ, MakersCallers fE + let MakersCallers2 FQ FE = MakersCallers FQ, MakersCallers FE - let MakeOrCallContainsOrElementAt fQ fE = - let (CQ, MQ), (CE, ME) = MakersCallers2 fQ fE + let MakeOrCallContainsOrElementAt FQ FE = + let (CQ, MQ), (CE, ME) = MakersCallers2 FQ FE let Make (isIQ, srcItemTy: Type, src: Expr, key: Expr) = if isIQ then //let key = MakeImplicitExpressionConversion key @@ -483,8 +483,8 @@ module Query = let FE = methodhandleof (fun (x, y) -> Enumerable.ElementAt(x, y)) MakeOrCallContainsOrElementAt FQ FE - let MakeOrCallMinByOrMaxBy fQ fE = - let (CQ, MQ), (CE, ME) = MakersCallers2 fQ fE + let MakeOrCallMinByOrMaxBy FQ FE = + let (CQ, MQ), (CE, ME) = MakersCallers2 FQ FE let Make (isIQ, src: Expr, v: Var, valSelector: Expr) = let srcItemTy = v.Type let keyElemTy = valSelector.Type @@ -527,8 +527,8 @@ module Query = let FE = methodhandleof (fun (x, y: Func<_, 'Result>) -> Enumerable.Max(x, y)) MakeOrCallMinByOrMaxBy FQ FE - let MakeOrCallAnyOrAllOrFirstFind fQ fE = - let (CQ, MQ), (CE, ME) = MakersCallers2 fQ fE + let MakeOrCallAnyOrAllOrFirstFind FQ FE = + let (CQ, MQ), (CE, ME) = MakersCallers2 FQ FE let Make (isIQ, src: Expr, v: Var, predicate: Expr) = let srcItemTy= v.Type let predicate = FuncExprToDelegateExpr (srcItemTy, boolTy, v, predicate) @@ -563,14 +563,14 @@ module Query = let FE = methodhandleof (fun (x, y: Func<_, _>) -> Enumerable.First(x, y)) MakeOrCallAnyOrAllOrFirstFind FQ FE - let MakeOrCallAverageByOrSumByGeneric (isNullable, fq_double, fq_single, fq_decimal, fq_int32, fq_int64, fe_double, fe_single, fe_decimal, fe_int32, fe_int64, fE) = + let MakeOrCallAverageByOrSumByGeneric (isNullable, fq_double, fq_single, fq_decimal, fq_int32, fq_int64, fe_double, fe_single, fe_decimal, fe_int32, fe_int64, FE) = let (cq_double, mq_double), (ce_double, me_double) = MakersCallers2 fq_double fe_double let (cq_single, mq_single), (ce_single, me_single) = MakersCallers2 fq_single fe_single let (cq_decimal, mq_decimal), (ce_decimal, me_decimal) = MakersCallers2 fq_decimal fe_decimal let (cq_int32, mq_int32), (ce_int32, me_int32) = MakersCallers2 fq_int32 fe_int32 let (cq_int64, mq_int64), (ce_int64, me_int64) = MakersCallers2 fq_int64 fe_int64 // The F# implementation is an instance method on QueryBuilder - let (CE, ME) = MakersCallersInstance fE + let (CE, ME) = MakersCallersInstance FE let failDueToUnsupportedInputTypeInSumByOrAverageBy() = invalidOp (SR.GetString(SR.failDueToUnsupportedInputTypeInSumByOrAverageBy)) let Make (qb: Expr, isIQ, src: Expr, v: Var, res: Expr) = @@ -711,8 +711,8 @@ module Query = let FE = methodhandleof (fun (query:QueryBuilder, arg1: QuerySource<_, _>, arg2:_->Nullable) -> query.SumByNullable(arg1, arg2)) MakeOrCallAverageByOrSumByGeneric (true, FQ_double, FQ_single, FQ_decimal, FQ_int32, FQ_int64, FE_double, FE_single, FE_decimal, FE_int32, FE_int64, FE) - let MakeOrCallSimpleOp fQ fE = - let (CQ, MQ), (CE, ME) = MakersCallers2 fQ fE + let MakeOrCallSimpleOp FQ FE = + let (CQ, MQ), (CE, ME) = MakersCallers2 FQ FE let Make (isIQ, srcItemTy, src: Expr) = if isIQ then MQ ([srcItemTy], [src]) @@ -816,16 +816,16 @@ module Query = else FE ([v.Type], [src; selector]) - let MakeOrderByOrThenBy fQ fE = + let MakeOrderByOrThenBy FQ FE = fun (isIQ, src: Expr, v: Var, keySelector: Expr) -> let srcItemTy = v.Type let keyItemTy = keySelector.Type let selector = Expr.NewDelegate (MakeQueryFuncTy(srcItemTy, keyItemTy), [v], keySelector) if isIQ then let selector = MakeImplicitExpressionConversion selector - fQ ([srcItemTy; keyItemTy], [src; selector]) + FQ ([srcItemTy; keyItemTy], [src; selector]) else - fE ([srcItemTy; keyItemTy], [src; selector]) + FE ([srcItemTy; keyItemTy], [src; selector]) let MakeOrderBy = let FQ = MakeGenericStaticMethod (methodhandleof (fun (x, y: Expression>) -> System.Linq.Queryable.OrderBy(x, y))) @@ -856,9 +856,9 @@ module Query = let MakeThenByNullableDescending = MakeThenByDescending - let GenMakeSkipWhileOrTakeWhile fQ fE = - let FQ = MakeGenericStaticMethod fQ - let FE = MakeGenericStaticMethod fE + let GenMakeSkipWhileOrTakeWhile FQ FE = + let FQ = MakeGenericStaticMethod FQ + let FE = MakeGenericStaticMethod FE fun (isIQ, src: Expr, v: Var, predicate) -> let srcItemTy = v.Type let selector = Expr.NewDelegate (MakeQueryFuncTy(srcItemTy, boolTy), [v], predicate) @@ -868,9 +868,9 @@ module Query = else FE ([srcItemTy], [src; selector]) - let MakeSkipOrTake fQ fE = - let FQ = MakeGenericStaticMethod fQ - let FE = MakeGenericStaticMethod fE + let MakeSkipOrTake FQ FE = + let FQ = MakeGenericStaticMethod FQ + let FE = MakeGenericStaticMethod FE fun (isIQ, srcItemTy, src: Expr, count) -> if isIQ then FQ ([srcItemTy], [src; count]) @@ -1927,6 +1927,4 @@ module Query = new ForwardDeclarations.IQueryMethods with member _.Execute q = QueryExecute q member _.EliminateNestedQueries e = EliminateNestedQueries e - } - - + } \ No newline at end of file From 792249ac4f9ebe5c4046c17ebfc436abcda4f04c Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 29 Oct 2024 21:20:19 +0000 Subject: [PATCH 34/49] Revert remaining changes --- src/Compiler/Service/FSharpProjectSnapshot.fs | 120 +++++++++--------- src/Compiler/Service/TransparentCompiler.fs | 12 +- .../LanguageService/WorkspaceExtensions.fs | 6 +- .../Refactors/RefactorTestFramework.fs | 8 +- 4 files changed, 73 insertions(+), 73 deletions(-) diff --git a/src/Compiler/Service/FSharpProjectSnapshot.fs b/src/Compiler/Service/FSharpProjectSnapshot.fs index db3b3e7022f..5b4bfcfd750 100644 --- a/src/Compiler/Service/FSharpProjectSnapshot.fs +++ b/src/Compiler/Service/FSharpProjectSnapshot.fs @@ -67,7 +67,7 @@ module internal Helpers = /// A snapshot of an F# source file. [] -type FSharpFileSnapshot(fileName: string, version: string, getSource: unit -> Task) = +type FSharpFileSnapshot(FileName: string, Version: string, GetSource: unit -> Task) = static member Create(fileName: string, version: string, getSource: unit -> Task) = FSharpFileSnapshot(fileName, version, getSource) @@ -101,13 +101,13 @@ type FSharpFileSnapshot(fileName: string, version: string, getSource: unit -> Ta | DocumentSource.FileSystem -> FSharpFileSnapshot.CreateFromFileSystem fileName - member public _.FileName = fileName - member _.Version = version - member _.GetSource() = getSource () + member public _.FileName = FileName + member _.Version = Version + member _.GetSource() = GetSource() - member val IsSignatureFile = fileName |> isSignatureFile + member val IsSignatureFile = FileName |> isSignatureFile - member _.GetFileName() = fileName + member _.GetFileName() = FileName override this.Equals(o) = match o with @@ -124,19 +124,19 @@ type FSharpFileSnapshot(fileName: string, version: string, getSource: unit -> Ta /// A source file snapshot with loaded source text. type internal FSharpFileSnapshotWithSource - (fileName: string, sourceHash: ImmutableArray, source: ISourceTextNew, isLastCompiland: bool, isExe: bool) = + (FileName: string, SourceHash: ImmutableArray, Source: ISourceTextNew, IsLastCompiland: bool, IsExe: bool) = - let version = lazy (sourceHash.ToBuilder().ToArray()) + let version = lazy (SourceHash.ToBuilder().ToArray()) let stringVersion = lazy (version.Value |> BitConverter.ToString) member val Version = version.Value member val StringVersion = stringVersion.Value - member val IsSignatureFile = fileName |> isSignatureFile + member val IsSignatureFile = FileName |> isSignatureFile - member _.FileName = fileName - member _.Source = source - member _.IsLastCompiland = isLastCompiland - member _.IsExe = isExe + member _.FileName = FileName + member _.Source = Source + member _.IsLastCompiland = IsLastCompiland + member _.IsExe = IsExe interface IFileSnapshot with member this.FileName = this.FileName @@ -146,23 +146,23 @@ type internal FSharpFileSnapshotWithSource /// A source file snapshot with parsed syntax tree type internal FSharpParsedFile ( - fileName: string, - syntaxTreeHash: byte array, - sourceText: ISourceText, - parsedInput: ParsedInput, - parseDiagnostics: (PhasedDiagnostic * FSharpDiagnosticSeverity)[] + FileName: string, + SyntaxTreeHash: byte array, + SourceText: ISourceText, + ParsedInput: ParsedInput, + ParseDiagnostics: (PhasedDiagnostic * FSharpDiagnosticSeverity)[] ) = - member _.FileName = fileName - member _.SourceText = sourceText - member _.ParsedInput = parsedInput - member _.ParseDiagnostics = parseDiagnostics + member _.FileName = FileName + member _.SourceText = SourceText + member _.ParsedInput = ParsedInput + member _.ParseDiagnostics = ParseDiagnostics - member val IsSignatureFile = fileName |> isSignatureFile + member val IsSignatureFile = FileName |> isSignatureFile interface IFileSnapshot with member this.FileName = this.FileName - member this.Version = syntaxTreeHash + member this.Version = SyntaxTreeHash member this.IsSignatureFile = this.IsSignatureFile /// An on-disk reference needed for project compilation. @@ -362,34 +362,34 @@ and internal ProjectSnapshotWithSources = ProjectSnapshotBase Md5Hasher.addString projectFileName - |> Md5Hasher.addStrings otherOptions - |> Md5Hasher.addBool isIncompleteTypeCheckEnvironment - |> Md5Hasher.addBool useScriptResolutionRules) + |> Md5Hasher.addString ProjectFileName + |> Md5Hasher.addStrings OtherOptions + |> Md5Hasher.addBool IsIncompleteTypeCheckEnvironment + |> Md5Hasher.addBool UseScriptResolutionRules) let fullHash = lazy (hashForParsing.Value - |> Md5Hasher.addStrings (referencesOnDisk |> Seq.map (fun r -> r.Path)) - |> Md5Hasher.addDateTimes (referencesOnDisk |> Seq.map (fun r -> r.LastModified)) + |> Md5Hasher.addStrings (ReferencesOnDisk |> Seq.map (fun r -> r.Path)) + |> Md5Hasher.addDateTimes (ReferencesOnDisk |> Seq.map (fun r -> r.LastModified)) |> Md5Hasher.addBytes' ( - referencedProjects + ReferencedProjects |> Seq.map (function | FSharpReference(_name, p) -> p.ProjectSnapshot.SignatureVersion | PEReference(getStamp, _) -> Md5Hasher.empty |> Md5Hasher.addDateTime (getStamp ()) @@ -401,16 +401,16 @@ and internal ProjectCore let commandLineOptions = lazy (seq { - yield! otherOptions + yield! OtherOptions - for r in referencesOnDisk do + for r in ReferencesOnDisk do $"-r:{r.Path}" } |> Seq.toList) - let outputFileName = lazy (otherOptions |> findOutputFileName) + let outputFileName = lazy (OtherOptions |> findOutputFileName) - let key = lazy (projectFileName, outputFileName.Value |> Option.defaultValue "") + let key = lazy (ProjectFileName, outputFileName.Value |> Option.defaultValue "") let cacheKey = lazy @@ -420,26 +420,26 @@ and internal ProjectCore member _.GetVersion() = fullHashString.Value }) - member val ProjectDirectory = !! Path.GetDirectoryName(projectFileName) + member val ProjectDirectory = !! Path.GetDirectoryName(ProjectFileName) member _.OutputFileName = outputFileName.Value member _.Identifier: ProjectIdentifier = key.Value member _.Version = fullHash.Value - member _.Label = projectFileName |> shortPath + member _.Label = ProjectFileName |> shortPath member _.VersionForParsing = hashForParsing.Value member _.CommandLineOptions = commandLineOptions.Value - member _.ProjectFileName = projectFileName - member _.ProjectId = projectId - member _.ReferencesOnDisk = referencesOnDisk - member _.OtherOptions = otherOptions - member _.ReferencedProjects = referencedProjects - member _.IsIncompleteTypeCheckEnvironment = isIncompleteTypeCheckEnvironment - member _.UseScriptResolutionRules = useScriptResolutionRules - member _.LoadTime = loadTime - member _.UnresolvedReferences = unresolvedReferences - member _.OriginalLoadReferences = originalLoadReferences - member _.Stamp = stamp + member _.ProjectFileName = ProjectFileName + member _.ProjectId = ProjectId + member _.ReferencesOnDisk = ReferencesOnDisk + member _.OtherOptions = OtherOptions + member _.ReferencedProjects = ReferencedProjects + member _.IsIncompleteTypeCheckEnvironment = IsIncompleteTypeCheckEnvironment + member _.UseScriptResolutionRules = UseScriptResolutionRules + member _.LoadTime = LoadTime + member _.UnresolvedReferences = UnresolvedReferences + member _.OriginalLoadReferences = OriginalLoadReferences + member _.Stamp = Stamp member _.CacheKeyWith(label, version) = { new ICacheKey<_, _> with @@ -710,4 +710,4 @@ type internal Extensions = [] static member GetProjectIdentifier(this: FSharpProjectOptions) : ProjectIdentifier = - this.ProjectFileName, this.OtherOptions |> findOutputFileName |> Option.defaultValue "" + this.ProjectFileName, this.OtherOptions |> findOutputFileName |> Option.defaultValue "" \ No newline at end of file diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index c7ba529e02e..388b682c2fc 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -1039,11 +1039,11 @@ type internal TransparentCompiler return FSharpFileSnapshotWithSource( - fileName = file.FileName, - source = source, - sourceHash = source.GetChecksum(), - isLastCompiland = isLastCompiland, - isExe = isExe + FileName = file.FileName, + Source = source, + SourceHash = source.GetChecksum(), + IsLastCompiland = isLastCompiland, + IsExe = isExe ) } @@ -2517,4 +2517,4 @@ type internal TransparentCompiler projectSnapshot: FSharpProjectSnapshot, userOpName: string ) : (FSharpParseFileResults * FSharpCheckFileResults) option = - TryGetRecentCheckResultsForFile(fileName, projectSnapshot, userOpName) + TryGetRecentCheckResultsForFile(fileName, projectSnapshot, userOpName) \ No newline at end of file diff --git a/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs b/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs index 1d95fe33773..1eca0e49ff0 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs @@ -141,7 +141,7 @@ module private CheckerExtensions = return sourceText.ToFSharpSourceText() } - return FSharpFileSnapshot(fileName = document.FilePath, version = version.ToString(), getSource = getSource) + return FSharpFileSnapshot(FileName = document.FilePath, Version = version.ToString(), GetSource = getSource) } let getReferencedProjectVersions (project: Project) = @@ -286,7 +286,7 @@ module private CheckerExtensions = async.Return(version.ToString(), getSource) - return FSharpFileSnapshot(fileName = path, version = version, getSource = getSource) + return FSharpFileSnapshot(FileName = path, Version = version, GetSource = getSource) } let! snapshot = @@ -664,4 +664,4 @@ type Project with member this.GetFSharpCompilationOptionsAsync() = this |> getFSharpOptionsForProject member this.GetFSharpProjectSnapshot(?snapshotAccumulator) = - cancellableTask { return! getOrCreateSnapshotForProject this None snapshotAccumulator } + cancellableTask { return! getOrCreateSnapshotForProject this None snapshotAccumulator } \ No newline at end of file diff --git a/vsintegration/tests/FSharp.Editor.Tests/Refactors/RefactorTestFramework.fs b/vsintegration/tests/FSharp.Editor.Tests/Refactors/RefactorTestFramework.fs index 0fd7796d238..16eb3925fcb 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/Refactors/RefactorTestFramework.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/Refactors/RefactorTestFramework.fs @@ -15,8 +15,8 @@ open System.Threading let GetTaskResult (task: Tasks.Task<'T>) = task.GetAwaiter().GetResult() -type TestContext(solution: Solution) = - let mutable _solution = solution +type TestContext(Solution: Solution) = + let mutable _solution = Solution member _.CancellationToken = CancellationToken.None member _.Solution @@ -24,7 +24,7 @@ type TestContext(solution: Solution) = and get () = _solution interface IDisposable with - member _.Dispose() = solution.Workspace.Dispose() + member _.Dispose() = Solution.Workspace.Dispose() static member CreateWithCode(code: string) = let solution = RoslynTestHelpers.CreateSolution(code) @@ -86,4 +86,4 @@ let tryGetRefactoringActions (code: string) (cursorPosition) (context: TestConte return refactoringActions } |> CancellableTask.startWithoutCancellation - |> fun task -> task.Result + |> fun task -> task.Result \ No newline at end of file From 34b42f9b98f35a450f7d77d0a8bff584aaeafc43 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 29 Oct 2024 21:23:34 +0000 Subject: [PATCH 35/49] format code --- src/Compiler/Service/FSharpProjectSnapshot.fs | 2 +- src/Compiler/Service/TransparentCompiler.fs | 2 +- src/FSharp.Core/MutableTuple.fs | 2 +- tests/FSharp.Test.Utilities/CompilerAssert.fs | 8 ++++---- tests/FSharp.Test.Utilities/ProjectGeneration.fs | 14 +++++++------- .../LanguageService/WorkspaceExtensions.fs | 2 +- .../Refactors/RefactorTestFramework.fs | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Compiler/Service/FSharpProjectSnapshot.fs b/src/Compiler/Service/FSharpProjectSnapshot.fs index 5b4bfcfd750..fbff9619b88 100644 --- a/src/Compiler/Service/FSharpProjectSnapshot.fs +++ b/src/Compiler/Service/FSharpProjectSnapshot.fs @@ -710,4 +710,4 @@ type internal Extensions = [] static member GetProjectIdentifier(this: FSharpProjectOptions) : ProjectIdentifier = - this.ProjectFileName, this.OtherOptions |> findOutputFileName |> Option.defaultValue "" \ No newline at end of file + this.ProjectFileName, this.OtherOptions |> findOutputFileName |> Option.defaultValue "" diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index 388b682c2fc..5158ac7f25c 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -2517,4 +2517,4 @@ type internal TransparentCompiler projectSnapshot: FSharpProjectSnapshot, userOpName: string ) : (FSharpParseFileResults * FSharpCheckFileResults) option = - TryGetRecentCheckResultsForFile(fileName, projectSnapshot, userOpName) \ No newline at end of file + TryGetRecentCheckResultsForFile(fileName, projectSnapshot, userOpName) diff --git a/src/FSharp.Core/MutableTuple.fs b/src/FSharp.Core/MutableTuple.fs index a71c33e442f..a9292f1c48b 100644 --- a/src/FSharp.Core/MutableTuple.fs +++ b/src/FSharp.Core/MutableTuple.fs @@ -213,4 +213,4 @@ type AnonymousObject<'T1, 'T2, 'T3, 'T4, 'T5, 'T6, 'T7, 'T8> = item6 = Item6 item7 = Item7 item8 = Item8 - } \ No newline at end of file + } diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs index e730356e63b..44ac9ace6b8 100644 --- a/tests/FSharp.Test.Utilities/CompilerAssert.fs +++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs @@ -945,9 +945,9 @@ Updated automatically, please check diffs in your pull request, changes must be let getFileSnapshot _ fileName = async.Return (FSharpFileSnapshot( - fileName = fileName, - version = "1", - getSource = fun () -> task { + FileName = fileName, + Version = "1", + GetSource = fun () -> task { match! getSourceText fileName with | Some source -> return SourceTextNew.ofISourceText source | None -> return failwith $"couldn't get source for {fileName}" @@ -1081,4 +1081,4 @@ Updated automatically, please check diffs in your pull request, changes must be Assert.Equal(expectedErrorNumber, info.ErrorNumber) Assert.Equal(expectedErrorRange, (info.StartLine, info.StartColumn + 1, info.EndLine, info.EndColumn + 1)) Assert.Equal(expectedErrorMsg, info.Message) - ) + ) \ No newline at end of file diff --git a/tests/FSharp.Test.Utilities/ProjectGeneration.fs b/tests/FSharp.Test.Utilities/ProjectGeneration.fs index d4cfea29edb..5e3e9a9d222 100644 --- a/tests/FSharp.Test.Utilities/ProjectGeneration.fs +++ b/tests/FSharp.Test.Utilities/ProjectGeneration.fs @@ -642,9 +642,9 @@ module ProjectOperations = let hash = md5.ComputeHash(inputBytes) |> Array.map (fun b -> b.ToString("X2")) |> String.concat "" return FSharpFileSnapshot( - fileName = filePath, - version = hash, - getSource = fun () -> source |> Task.FromResult + FileName = filePath, + Version = hash, + GetSource = fun () -> source |> Task.FromResult ) } @@ -858,9 +858,9 @@ module Helpers = let getSource _ fileName = FSharpFileSnapshot( - fileName = fileName, - version = "1", - getSource = fun () -> source |> SourceTextNew.ofString |> Task.FromResult ) + FileName = fileName, + Version = "1", + GetSource = fun () -> source |> SourceTextNew.ofString |> Task.FromResult ) |> async.Return let checker = FSharpChecker.Create( @@ -1451,4 +1451,4 @@ type SyntheticProject with FrameworkReferences = parseReferences "FrameworkReference" OtherOptions = [ for w in nowarns do - $"--nowarn:{w}" ] } + $"--nowarn:{w}" ] } \ No newline at end of file diff --git a/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs b/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs index 1eca0e49ff0..6c3b04f1844 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs @@ -664,4 +664,4 @@ type Project with member this.GetFSharpCompilationOptionsAsync() = this |> getFSharpOptionsForProject member this.GetFSharpProjectSnapshot(?snapshotAccumulator) = - cancellableTask { return! getOrCreateSnapshotForProject this None snapshotAccumulator } \ No newline at end of file + cancellableTask { return! getOrCreateSnapshotForProject this None snapshotAccumulator } diff --git a/vsintegration/tests/FSharp.Editor.Tests/Refactors/RefactorTestFramework.fs b/vsintegration/tests/FSharp.Editor.Tests/Refactors/RefactorTestFramework.fs index 16eb3925fcb..849da8c84ec 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/Refactors/RefactorTestFramework.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/Refactors/RefactorTestFramework.fs @@ -86,4 +86,4 @@ let tryGetRefactoringActions (code: string) (cursorPosition) (context: TestConte return refactoringActions } |> CancellableTask.startWithoutCancellation - |> fun task -> task.Result \ No newline at end of file + |> fun task -> task.Result From b8682b6875be9f03f66b55b8a0995aaa22931e67 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 29 Oct 2024 21:39:57 +0000 Subject: [PATCH 36/49] use TcTrueMatchClause instead of bool --- .../CheckComputationExpressions.fs | 18 +++++++-------- .../Checking/Expressions/CheckExpressions.fs | 23 +++++++++++++------ .../Checking/Expressions/CheckExpressions.fsi | 8 ++++++- .../Expressions/CheckSequenceExpressions.fs | 16 +++++++++---- 4 files changed, 44 insertions(+), 21 deletions(-) diff --git a/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs b/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs index 6b6c8ab4472..22b603d211a 100644 --- a/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs @@ -982,7 +982,7 @@ let rec TryTranslateComputationExpression use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink let _, _, vspecs, envinner, _ = - TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv firstSourcePat None false + TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv firstSourcePat None TcTrueMatchClause.No vspecs, envinner) @@ -991,7 +991,7 @@ let rec TryTranslateComputationExpression use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink let _, _, vspecs, envinner, _ = - TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv secondSourcePat None false + TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv secondSourcePat None TcTrueMatchClause.No vspecs, envinner) @@ -1002,7 +1002,7 @@ let rec TryTranslateComputationExpression use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink let _, _, vspecs, envinner, _ = - TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv pat3 None false + TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv pat3 None TcTrueMatchClause.No vspecs, envinner) | None -> varSpace @@ -1231,7 +1231,7 @@ let rec TryTranslateComputationExpression use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink let _, _, vspecs, envinner, _ = - TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv pat None false + TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv pat None TcTrueMatchClause.No vspecs, envinner) @@ -1789,7 +1789,7 @@ let rec TryTranslateComputationExpression use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink let _, _, vspecs, envinner, _ = - TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv pat None false + TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv pat None TcTrueMatchClause.No vspecs, envinner | _ -> @@ -1873,7 +1873,7 @@ let rec TryTranslateComputationExpression use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink let _, _, vspecs, envinner, _ = - TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv pat None false + TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv pat None TcTrueMatchClause.No vspecs, envinner) @@ -2066,7 +2066,7 @@ let rec TryTranslateComputationExpression use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink let _, _, vspecs, envinner, _ = - TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv consumePat None false + TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv consumePat None TcTrueMatchClause.No vspecs, envinner) @@ -2111,7 +2111,7 @@ let rec TryTranslateComputationExpression use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink let _, _, vspecs, envinner, _ = - TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv consumePat None false + TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv consumePat None TcTrueMatchClause.No vspecs, envinner) @@ -2239,7 +2239,7 @@ let rec TryTranslateComputationExpression use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink let _, _, vspecs, envinner, _ = - TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv consumePat None false + TcMatchPattern cenv (NewInferenceType cenv.g) env ceenv.tpenv consumePat None TcTrueMatchClause.No vspecs, envinner) diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index d31a7909273..5543bd36dc4 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -1016,6 +1016,12 @@ type TcCanFail = | IgnoreMemberResoutionError | IgnoreAllErrors | ReportAllErrors + +[] +[] +type TcTrueMatchClause = + | Yes + | No let TcAddNullnessToType (warn: bool) (cenv: cenv) (env: TcEnv) nullness innerTyC m = let g = cenv.g @@ -8073,7 +8079,7 @@ and TcForEachExpr cenv overallTy env tpenv (seqExprOnly, isFromSource, synPat, s let pat, _, vspecs, envinner, tpenv = let env = { env with eIsControlFlow = false } - TcMatchPattern cenv enumElemTy env tpenv synPat None false + TcMatchPattern cenv enumElemTy env tpenv synPat None TcTrueMatchClause.No let elemVar, pat = // nice: don't introduce awful temporary for r.h.s. in the 99% case where we know what we're binding it to @@ -10603,14 +10609,13 @@ and TcAndPatternCompileMatchClauses mExpr mMatch actionOnFailure cenv inputExprO let matchVal, expr = CompilePatternForMatchClauses cenv env mExpr mMatch true actionOnFailure inputExprOpt inputTy resultTy.Commit clauses matchVal, expr, tpenv -and TcMatchPattern (cenv: cenv) inputTy env tpenv (synPat: SynPat) (synWhenExprOpt: SynExpr option) (isTrueMatchClause: bool) = +and TcMatchPattern (cenv: cenv) inputTy env tpenv (synPat: SynPat) (synWhenExprOpt: SynExpr option) (tcTrueMatchClause: TcTrueMatchClause) = let g = cenv.g let m = synPat.Range let warnOnUpperFlag = - if isTrueMatchClause then - WarnOnUpperUnionCaseLabel - else - WarnOnUpperVariablePatterns + match tcTrueMatchClause with + | TcTrueMatchClause.Yes -> WarnOnUpperUnionCaseLabel + | TcTrueMatchClause.No -> WarnOnUpperVariablePatterns let patf', (TcPatLinearEnv (tpenv, names, _)) = cenv.TcPat warnOnUpperFlag cenv env None (TcPatValFlags (ValInline.Optional, permitInferTypars, noArgOrRetAttribs, false, None, false)) (TcPatLinearEnv (tpenv, Map.empty, Set.empty)) inputTy synPat let envinner, values, vspecMap = MakeAndPublishSimpleValsForMergedScope cenv env m names @@ -10635,7 +10640,11 @@ and TcMatchClauses cenv inputTy (resultTy: OverallTy) env tpenv clauses = and TcMatchClause cenv inputTy (resultTy: OverallTy) env isFirst tpenv synMatchClause = let (SynMatchClause(synPat, synWhenExprOpt, synResultExpr, patm, spTgt, trivia)) = synMatchClause - let isTrueMatchClause = trivia.BarRange.IsSome && trivia.ArrowRange.IsSome + let isTrueMatchClause = + if trivia.BarRange.IsSome && trivia.ArrowRange.IsSome then + TcTrueMatchClause.Yes + else + TcTrueMatchClause.No let pat, whenExprOpt, vspecs, envinner, tpenv = TcMatchPattern cenv inputTy env tpenv synPat synWhenExprOpt isTrueMatchClause diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fsi b/src/Compiler/Checking/Expressions/CheckExpressions.fsi index 2ebda98c746..c5777bf7133 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fsi +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fsi @@ -351,6 +351,12 @@ type TcCanFail = | IgnoreAllErrors | ReportAllErrors +[] +[] +type TcTrueMatchClause = + | Yes + | No + /// Represents a recursive binding after it has been both checked and generalized, but /// before initialization recursion has been rewritten type PreInitializationGraphEliminationBinding = @@ -703,7 +709,7 @@ val TcMatchPattern: tpenv: UnscopedTyparEnv -> synPat: SynPat -> synWhenExprOpt: SynExpr option -> - isTrueMatchClause: bool -> + tcTrueMatchClause: TcTrueMatchClause -> Pattern * Expr option * Val list * TcEnv * UnscopedTyparEnv [] diff --git a/src/Compiler/Checking/Expressions/CheckSequenceExpressions.fs b/src/Compiler/Checking/Expressions/CheckSequenceExpressions.fs index 93c860dbd33..9b597952258 100644 --- a/src/Compiler/Checking/Expressions/CheckSequenceExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckSequenceExpressions.fs @@ -59,7 +59,7 @@ let TcSequenceExpression (cenv: TcFileState) env tpenv comp (overallTy: OverallT ConvertArbitraryExprToEnumerable cenv arbitraryTy env pseudoEnumExpr let patR, _, vspecs, envinner, tpenv = - TcMatchPattern cenv enumElemTy env tpenv pat None false + TcMatchPattern cenv enumElemTy env tpenv pat None TcTrueMatchClause.No let innerExpr, tpenv = let envinner = { envinner with eIsControlFlow = true } @@ -241,7 +241,7 @@ let TcSequenceExpression (cenv: TcFileState) env tpenv comp (overallTy: OverallT let inputExprTy = NewInferenceType g let pat', _, vspecs, envinner, tpenv = - TcMatchPattern cenv bindPatTy env tpenv pat None false + TcMatchPattern cenv bindPatTy env tpenv pat None TcTrueMatchClause.No UnifyTypes cenv env m inputExprTy bindPatTy @@ -271,7 +271,11 @@ let TcSequenceExpression (cenv: TcFileState) env tpenv comp (overallTy: OverallT let tclauses, tpenv = (tpenv, clauses) ||> List.mapFold (fun tpenv (SynMatchClause(pat, cond, innerComp, _, sp, trivia)) -> - let isTrueMatchClause = trivia.BarRange.IsSome && trivia.ArrowRange.IsSome + let isTrueMatchClause = + if trivia.BarRange.IsSome && trivia.ArrowRange.IsSome then + TcTrueMatchClause.Yes + else + TcTrueMatchClause.No let patR, condR, vspecs, envinner, tpenv = TcMatchPattern cenv inputTy env tpenv pat cond isTrueMatchClause @@ -316,7 +320,11 @@ let TcSequenceExpression (cenv: TcFileState) env tpenv comp (overallTy: OverallT let clauses, tpenv = (tpenv, withList) ||> List.mapFold (fun tpenv (SynMatchClause(pat, cond, innerComp, m, sp, trivia)) -> - let isTrueMatchClause = trivia.BarRange.IsSome && trivia.ArrowRange.IsSome + let isTrueMatchClause = + if trivia.BarRange.IsSome && trivia.ArrowRange.IsSome then + TcTrueMatchClause.Yes + else + TcTrueMatchClause.No let patR, condR, vspecs, envinner, tpenv = TcMatchPattern cenv g.exn_ty env tpenv pat cond isTrueMatchClause From cb71b1c4b9099d6d7d347c73bc8a5f42adaab8ed Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 29 Oct 2024 21:46:18 +0000 Subject: [PATCH 37/49] revert test changes --- tests/fsharp/core/auto-widen/5.0/test.fsx | 4 ++-- .../core/auto-widen/preview-default-warns/test.fsx | 10 +++++----- tests/fsharp/core/auto-widen/preview/test.fsx | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/fsharp/core/auto-widen/5.0/test.fsx b/tests/fsharp/core/auto-widen/5.0/test.fsx index 87f79b3a73d..74f1af4fdb9 100644 --- a/tests/fsharp/core/auto-widen/5.0/test.fsx +++ b/tests/fsharp/core/auto-widen/5.0/test.fsx @@ -131,7 +131,7 @@ module ConvertToSealedViaOpImplicit = [] type C() = static member op_Implicit(x:int) = C() - static member M1(c:C) = 1 + static member M1(C:C) = 1 let x = C.M1(2) module ConvertNoOverloading = @@ -161,7 +161,7 @@ module ConvertViaOpImplicit3 = module ConvertViaOpImplicit4 = type C() = static member op_Implicit(x:int) = C() - static member M1(c:C) = 1 + static member M1(C:C) = 1 let x = C.M1(2) module ConvertViaOpImplicit5 = diff --git a/tests/fsharp/core/auto-widen/preview-default-warns/test.fsx b/tests/fsharp/core/auto-widen/preview-default-warns/test.fsx index 86022264360..ea91533c0dd 100644 --- a/tests/fsharp/core/auto-widen/preview-default-warns/test.fsx +++ b/tests/fsharp/core/auto-widen/preview-default-warns/test.fsx @@ -131,7 +131,7 @@ module ConvertToSealedViaOpImplicit = [] type C() = static member op_Implicit(x:int) = C() - static member M1(c:C) = 1 + static member M1(C:C) = 1 let x = C.M1(2) module ConvertNoOverloading = @@ -161,7 +161,7 @@ module ConvertViaOpImplicit3 = module ConvertViaOpImplicit4 = type C() = static member op_Implicit(x:int) = C() - static member M1(c:C) = 1 + static member M1(C:C) = 1 let x = C.M1(2) module ConvertViaOpImplicit5 = @@ -459,7 +459,7 @@ module TestAccessibilityOfOpImplicit = [] type C() = static member private op_Implicit(x:int) = C() - static member M1(c:C) = 1 + static member M1(C:C) = 1 let x = C.M1(2) module TestObsoleteOfOpImplicit = @@ -467,7 +467,7 @@ module TestObsoleteOfOpImplicit = type C() = [] static member op_Implicit(x:int) = C() - static member M1(c:C) = 1 + static member M1(C:C) = 1 let x = C.M1(2) module TestAmbiguousOpImplicit = @@ -477,7 +477,7 @@ module TestAmbiguousOpImplicit = and [] C(x:int) = static member op_Implicit(x:B) = C(1) - static member M1(c:C) = 1 + static member M1(C:C) = 1 member _.Value = x let x = C.M1(B()) diff --git a/tests/fsharp/core/auto-widen/preview/test.fsx b/tests/fsharp/core/auto-widen/preview/test.fsx index 3c13ddc96e6..50eaae85f62 100644 --- a/tests/fsharp/core/auto-widen/preview/test.fsx +++ b/tests/fsharp/core/auto-widen/preview/test.fsx @@ -131,7 +131,7 @@ module ConvertToSealedViaOpImplicit = [] type C() = static member op_Implicit(x:int) = C() - static member M1(c:C) = 1 + static member M1(C:C) = 1 let x = C.M1(2) module ConvertNoOverloading = @@ -161,7 +161,7 @@ module ConvertViaOpImplicit3 = module ConvertViaOpImplicit4 = type C() = static member op_Implicit(x:int) = C() - static member M1(c:C) = 1 + static member M1(C:C) = 1 let x = C.M1(2) module ConvertViaOpImplicit5 = @@ -459,7 +459,7 @@ module TestAccessibilityOfOpImplicit = [] type C() = static member private op_Implicit(x:int) = C() - static member M1(c:C) = 1 + static member M1(C:C) = 1 let x = C.M1(2) module TestObsoleteOfOpImplicit = @@ -467,7 +467,7 @@ module TestObsoleteOfOpImplicit = type C() = [] static member op_Implicit(x:int) = C() - static member M1(c:C) = 1 + static member M1(C:C) = 1 let x = C.M1(2) module TestAmbiguousOpImplicit = @@ -477,7 +477,7 @@ module TestAmbiguousOpImplicit = and [] C(x:int) = static member op_Implicit(x:B) = C(1) - static member M1(c:C) = 1 + static member M1(C:C) = 1 member _.Value = x let x = C.M1(B()) From a294904abf04de74c542f82567dc1ba3699f42d7 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 29 Oct 2024 21:50:37 +0000 Subject: [PATCH 38/49] reverte changes on Query.fs --- src/FSharp.Core/Query.fs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/FSharp.Core/Query.fs b/src/FSharp.Core/Query.fs index a5b270e7b55..de1435df688 100644 --- a/src/FSharp.Core/Query.fs +++ b/src/FSharp.Core/Query.fs @@ -1927,4 +1927,6 @@ module Query = new ForwardDeclarations.IQueryMethods with member _.Execute q = QueryExecute q member _.EliminateNestedQueries e = EliminateNestedQueries e - } \ No newline at end of file + } + + From 1cb2c7412ddf42a7aa0681fd3363d18b12580ad9 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 29 Oct 2024 21:55:17 +0000 Subject: [PATCH 39/49] revert changes --- docs/release-notes/.FSharp.Core/9.0.200.md | 1 - docs/release-notes/.VisualStudio/17.13.md | 1 - tests/FSharp.Test.Utilities/CompilerAssert.fs | 2 +- tests/FSharp.Test.Utilities/ProjectGeneration.fs | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/release-notes/.FSharp.Core/9.0.200.md b/docs/release-notes/.FSharp.Core/9.0.200.md index 07d2454340e..a6f39af96ec 100644 --- a/docs/release-notes/.FSharp.Core/9.0.200.md +++ b/docs/release-notes/.FSharp.Core/9.0.200.md @@ -3,7 +3,6 @@ ### Added ### Fixed -* Warn on uppercase identifiers in patterns. ([PR #15816](https://github.com/dotnet/fsharp/pull/15816)) ### Breaking Changes diff --git a/docs/release-notes/.VisualStudio/17.13.md b/docs/release-notes/.VisualStudio/17.13.md index e54ebfb75b0..dae07600e1b 100644 --- a/docs/release-notes/.VisualStudio/17.13.md +++ b/docs/release-notes/.VisualStudio/17.13.md @@ -4,6 +4,5 @@ * Code fix for adding missing `seq`. ([PR #17772](https://github.com/dotnet/fsharp/pull/17772)) ### Changed -* Warn on uppercase identifiers in patterns. ([PR #15816](https://github.com/dotnet/fsharp/pull/15816)) ### Breaking Changes diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs index 44ac9ace6b8..37a8e25e164 100644 --- a/tests/FSharp.Test.Utilities/CompilerAssert.fs +++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs @@ -1081,4 +1081,4 @@ Updated automatically, please check diffs in your pull request, changes must be Assert.Equal(expectedErrorNumber, info.ErrorNumber) Assert.Equal(expectedErrorRange, (info.StartLine, info.StartColumn + 1, info.EndLine, info.EndColumn + 1)) Assert.Equal(expectedErrorMsg, info.Message) - ) \ No newline at end of file + ) diff --git a/tests/FSharp.Test.Utilities/ProjectGeneration.fs b/tests/FSharp.Test.Utilities/ProjectGeneration.fs index 5e3e9a9d222..a75784240dd 100644 --- a/tests/FSharp.Test.Utilities/ProjectGeneration.fs +++ b/tests/FSharp.Test.Utilities/ProjectGeneration.fs @@ -1451,4 +1451,4 @@ type SyntheticProject with FrameworkReferences = parseReferences "FrameworkReference" OtherOptions = [ for w in nowarns do - $"--nowarn:{w}" ] } \ No newline at end of file + $"--nowarn:{w}" ] } From 5597e60da9550cb2c71cb896d7622850945b6733 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 30 Oct 2024 08:58:40 +0000 Subject: [PATCH 40/49] allow all identifier pattern regardless its length in preview --- src/Compiler/Checking/CheckPatterns.fs | 7 +------ .../BindingExpressions/BindingExpressions.fs | 11 +---------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index ea6b56e021d..ed1707ee838 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -530,12 +530,7 @@ and TcPatLongIdent warnOnUpper cenv env ad valReprInfo vFlags (patEnv: TcPatLine TcPatLongIdentActivePatternCase warnOnUpper cenv env vFlags patEnv ty (mLongId, item, apref, args, m) - | Item.UnionCase _ | Item.ExnCase _ as item -> - let warnOnUpper = - if cenv.g.langVersion.SupportsFeature(LanguageFeature.WarnOnUppercaseIdentifiersInPatterns) then - WarnOnUpperUnionCaseLabel - else warnOnUpper - + | Item.UnionCase _ | Item.ExnCase _ as item -> TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (mLongId, item, args, m) | Item.ILField finfo -> diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs index d03fca69c87..661f26c2a65 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs @@ -182,13 +182,4 @@ module BindingExpressions = |> withLangVersionPreview |> withOptions ["--test:ErrorRanges"] |> typecheck - |> shouldFail - |> withDiagnostics [ - (Warning 49, Line 40, Col 17, Line 40, Col 20, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 42, Col 31, Line 42, Col 34, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 44, Col 32, Line 44, Col 34, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 117, Col 33, Line 117, Col 35, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 117, Col 37, Line 117, Col 40, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 119, Col 18, Line 119, Col 20, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 119, Col 22, Line 119, Col 24, "Match cases labels must be lowercase identifiers") - ] + |> shouldSucceed From 2330290721e4e9664bfac7d2d6bbc204bfebea92 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 30 Oct 2024 13:54:10 +0000 Subject: [PATCH 41/49] Preview: Don't warn on as named pattern --- src/Compiler/Checking/CheckPatterns.fs | 16 ++++++++++++++-- .../BindingExpressions/BindingExpressions.fs | 1 + .../BindingExpressions/UpperBindingPattern.fs | 11 ++++++++++- .../Conformance/PatternMatching/Union/Union.fs | 9 ++++++--- .../Union/UpperUnionCasePattern.fs | 14 ++++++++++++-- 5 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index ed1707ee838..dcb25087f62 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -358,6 +358,12 @@ and TcPatNamedAs warnOnUpper cenv env valReprInfo vFlags patEnv ty synInnerPat i and TcPatUnnamedAs warnOnUpper cenv env vFlags patEnv ty pat1 pat2 m = let pats = [pat1; pat2] + let warnOnUpper = + if cenv.g.langVersion.SupportsFeature(LanguageFeature.WarnOnUppercaseIdentifiersInPatterns) then + AllIdsOK + else + warnOnUpper + let patsR, patEnvR = TcPatterns warnOnUpper cenv env vFlags patEnv (List.map (fun _ -> ty) pats) pats let phase2 values = TPat_conjs(List.map (fun f -> f values) patsR, m) phase2, patEnvR @@ -443,7 +449,7 @@ and TcPatArrayOrList warnOnUpper cenv env vFlags patEnv ty isArray args m = else List.foldBack (mkConsListPat g argTy) argsR (mkNilListPat g m argTy) phase2, acc -and TcRecordPat warnOnUpper cenv env vFlags patEnv ty fieldPats m = +and TcRecordPat warnOnUpper (cenv: cenv) env vFlags patEnv ty fieldPats m = let fieldPats = fieldPats |> List.map (fun (fieldId, _, fieldPat) -> fieldId, fieldPat) match BuildFieldMap cenv env false ty fieldPats m with | None -> (fun _ -> TPat_error m), patEnv @@ -460,7 +466,13 @@ and TcRecordPat warnOnUpper cenv env vFlags patEnv ty fieldPats m = let fieldPats, patEnvR = (patEnv, ftys) ||> List.mapFold (fun s (ty, fsp) -> match fldsmap.TryGetValue fsp.rfield_id.idText with - | true, v -> TcPat warnOnUpper cenv env None vFlags s ty v + | true, v -> + let warnOnUpper = + if cenv.g.langVersion.SupportsFeature(LanguageFeature.WarnOnUppercaseIdentifiersInPatterns) then + AllIdsOK + else + warnOnUpper + TcPat warnOnUpper cenv env None vFlags s ty v | _ -> (fun _ -> TPat_wild m), s) let phase2 values = diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs index 661f26c2a65..a2b935c620f 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs @@ -173,6 +173,7 @@ module BindingExpressions = (Warning 3874, Line 80, Col 9, Line 80, Col 18, "Variable patterns should be lowercase.") (Warning 3874, Line 87, Col 9, Line 87, Col 18, "Variable patterns should be lowercase.") (Warning 3874, Line 117, Col 37, Line 117, Col 40, "Variable patterns should be lowercase.") + (Warning 3874, Line 122, Col 12, Line 122, Col 15, "Variable patterns should be lowercase.") ] [] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs index 3cf191dac08..79712e2b7f0 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/UpperBindingPattern.fs @@ -116,4 +116,13 @@ type CustomerId2 = CustomerId2 of string * string let getCustomerId3 (CustomerId2(AA, BBB)) = id -let (CustomerId2(AA, Bb)) = CustomerId2("AA", "BB") \ No newline at end of file +let (CustomerId2(AA, Bb)) = CustomerId2("AA", "BB") + +try () +with Ex as Foo -> () + +try () +with Ex as Fo -> () + +try () +with Ex as F -> () \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs index 41aca215752..72970db77bf 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs @@ -224,6 +224,12 @@ but here has type (Warning 49, Line 20, Col 7, Line 20, Col 10, "Match cases labels must be lowercase identifiers") (Warning 49, Line 24, Col 3, Line 24, Col 6, "Match cases labels must be lowercase identifiers") (Warning 49, Line 35, Col 14, Line 35, Col 17, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 41, Col 12, Line 41, Col 15, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 45, Col 20, Line 45, Col 23, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 50, Col 14, Line 50, Col 17, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 50, Col 21, Line 50, Col 24, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 51, Col 14, Line 51, Col 17, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 52, Col 14, Line 52, Col 17, "Match cases labels must be lowercase identifiers") ] [] @@ -247,7 +253,4 @@ but here has type (Warning 49, Line 24, Col 3, Line 24, Col 6, "Match cases labels must be lowercase identifiers") (Warning 49, Line 28, Col 3, Line 28, Col 5, "Match cases labels must be lowercase identifiers") (Warning 49, Line 35, Col 14, Line 35, Col 17, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 40, Col 12, Line 40, Col 14, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 41, Col 12, Line 41, Col 14, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 42, Col 12, Line 42, Col 14, "Match cases labels must be lowercase identifiers") ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs index 447a8faaa17..9d9715f87bf 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs @@ -38,5 +38,15 @@ type Record = { Name: string; Age: int } match { Name = "Alice"; Age = 30 } with | { Name = Al } -> printfn "Alice" -| { Name = Bo } -> printfn "Bob" -| { Name = Pe } -> printfn "Pepe" \ No newline at end of file +| { Name = Bob } -> printfn "Bob" +| { Name = P } -> printfn "Pepe" + +match { Name = "Alice"; Age = 30 } with +| { Name = Al } as Foo -> printfn "Alice" +| { Name = Al } as Fo -> printfn "Alice" +| { Name = Al } as F -> printfn "Alice" + +match customerId with +| CustomerId BBB as Foo -> () +| CustomerId Aaa as Fo -> () +| CustomerId CCC as F -> () \ No newline at end of file From 490b665f8180e41efbde325c55b33e6eba3c1fdb Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 31 Oct 2024 12:07:50 +0000 Subject: [PATCH 42/49] revert error message changes --- src/Compiler/Checking/NameResolution.fs | 4 +- src/Compiler/FSComp.txt | 3 +- src/Compiler/FSStrings.resx | 2 +- src/Compiler/xlf/FSComp.txt.cs.xlf | 5 -- src/Compiler/xlf/FSComp.txt.de.xlf | 5 -- src/Compiler/xlf/FSComp.txt.es.xlf | 5 -- src/Compiler/xlf/FSComp.txt.fr.xlf | 5 -- src/Compiler/xlf/FSComp.txt.it.xlf | 5 -- src/Compiler/xlf/FSComp.txt.ja.xlf | 5 -- src/Compiler/xlf/FSComp.txt.ko.xlf | 5 -- src/Compiler/xlf/FSComp.txt.pl.xlf | 5 -- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 5 -- src/Compiler/xlf/FSComp.txt.ru.xlf | 5 -- src/Compiler/xlf/FSComp.txt.tr.xlf | 5 -- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 5 -- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 5 -- src/Compiler/xlf/FSStrings.cs.xlf | 2 +- src/Compiler/xlf/FSStrings.de.xlf | 2 +- src/Compiler/xlf/FSStrings.es.xlf | 2 +- src/Compiler/xlf/FSStrings.fr.xlf | 2 +- src/Compiler/xlf/FSStrings.it.xlf | 2 +- src/Compiler/xlf/FSStrings.ja.xlf | 2 +- src/Compiler/xlf/FSStrings.ko.xlf | 2 +- src/Compiler/xlf/FSStrings.pl.xlf | 2 +- src/Compiler/xlf/FSStrings.pt-BR.xlf | 2 +- src/Compiler/xlf/FSStrings.ru.xlf | 2 +- src/Compiler/xlf/FSStrings.tr.xlf | 2 +- src/Compiler/xlf/FSStrings.zh-Hans.xlf | 2 +- src/Compiler/xlf/FSStrings.zh-Hant.xlf | 2 +- .../BindingExpressions/BindingExpressions.fs | 42 ++++++++--------- .../PatternMatching/Simple/Simple.fs | 8 ++-- .../PatternMatching/Union/Union.fs | 46 +++++++++---------- 32 files changed, 65 insertions(+), 131 deletions(-) diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index a9890eedb50..028ee084387 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -3406,8 +3406,8 @@ let rec ResolvePatternLongIdentPrim sink (ncenv: NameResolver) fullyQualified wa && System.Char.ToLowerInvariant id.idText[0] <> id.idText[0] then match warnOnUpper with - | WarnOnUpperUnionCaseLabel -> warning(UpperCaseIdentifierInPattern m) - | WarnOnUpperVariablePatterns -> warning(Error(FSComp.SR.chkVariablePatternUppercase(), m)) + | WarnOnUpperUnionCaseLabel + | WarnOnUpperVariablePatterns -> warning(UpperCaseIdentifierInPattern m) | AllIdsOK -> () // If there's an extra dot, we check whether the single identifier is a union, module or namespace and report it to the sink for the sake of tooling diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index b50626371ca..396b8ba806e 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1786,5 +1786,4 @@ featureAllowObjectExpressionWithoutOverrides,"Allow object expressions without o 3872,tcPartialActivePattern,"Multi-case partial active patterns are not supported. Consider using a single-case partial active pattern or a full active pattern." featureWarnOnUppercaseIdentifiersInPatterns,"Warn on uppercase identifiers in patterns" 3873,chkDeprecatePlacesWhereSeqCanBeOmitted,"This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'" -featureDeprecatePlacesWhereSeqCanBeOmitted,"Deprecate places where 'seq' can be omitted" -3874,chkVariablePatternUppercase,"Variable patterns should be lowercase." +featureDeprecatePlacesWhereSeqCanBeOmitted,"Deprecate places where 'seq' can be omitted" \ No newline at end of file diff --git a/src/Compiler/FSStrings.resx b/src/Compiler/FSStrings.resx index f9ce0a55951..383b4991105 100644 --- a/src/Compiler/FSStrings.resx +++ b/src/Compiler/FSStrings.resx @@ -166,7 +166,7 @@ Type constraint mismatch. The type \n '{0}' \nis not compatible with type\n '{1}' {2}\n - Match cases labels must be lowercase identifiers + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. Discriminated union cases and exception labels must be uppercase identifiers diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 5d0fab260ff..99bc12f43e8 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -147,11 +147,6 @@ Atribut TailCall by se měl použít jenom pro rekurzivní funkce. - - Variable patterns should be lowercase. - Variable patterns should be lowercase. - - The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. Atribut AssemblyKeyNameAttribute je zastaralý. Použijte místo něj AssemblyKeyFileAttribute. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 3d54e03ee47..339fc6e66f4 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -147,11 +147,6 @@ Das Attribut "TailCall" darf nur auf rekursive Funktionen angewendet werden. - - Variable patterns should be lowercase. - Variable patterns should be lowercase. - - The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. "AssemblyKeyNameAttribute" gilt als veraltet. Verwenden Sie stattdessen "AssemblyKeyFileAttribute". diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 7b8a7835840..f0b55298fd1 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -147,11 +147,6 @@ El atributo TailCall solo se debe aplicar a funciones recursivas. - - Variable patterns should be lowercase. - Variable patterns should be lowercase. - - The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. El elemento "AssemblyKeyNameAttribute" está en desuso. Use "AssemblyKeyFileAttribute" en su lugar. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 213f44fc1d8..d5e3c520e1f 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -147,11 +147,6 @@ L’attribut TailCall ne doit être appliqué qu’aux fonctions récursives. - - Variable patterns should be lowercase. - Variable patterns should be lowercase. - - The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. 'AssemblyKeyNameAttribute' a été déprécié. Utilisez 'AssemblyKeyFileAttribute' à la place. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index ad3be72a7a7..802c5c95f2a 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -147,11 +147,6 @@ L'attributo TailCall deve essere applicato solo a funzioni ricorsive. - - Variable patterns should be lowercase. - Variable patterns should be lowercase. - - The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. L'attributo 'AssemblyKeyNameAttribute' è deprecato. In alternativa, usare 'AssemblyKeyFileAttribute'. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 9336ca2b53d..6da7ef9148a 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -147,11 +147,6 @@ TailCall 属性は再帰関数にのみ適用する必要があります。 - - Variable patterns should be lowercase. - Variable patterns should be lowercase. - - The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. 'AssemblyKeyNameAttribute' は非推奨になりました。代わりに 'AssemblyKeyFileAttribute' を使用してください。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 9089b287d4b..fc696d4e7a5 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -147,11 +147,6 @@ TailCall 특성은 재귀 함수에만 적용해야 합니다. - - Variable patterns should be lowercase. - Variable patterns should be lowercase. - - The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. 'AssemblyKeyNameAttribute'는 사용되지 않습니다. 대신 'AssemblyKeyFileAttribute'를 사용하세요. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 22528692d8c..e17fbf1515c 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -147,11 +147,6 @@ Atrybut TailCall powinien być stosowany tylko do funkcji rekursywnych. - - Variable patterns should be lowercase. - Variable patterns should be lowercase. - - The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. Element „AssemblyKeyNameAttribute” jest przestarzały. Zamiast niego użyj elementu „AssemblyKeyFileAttribute”. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index bd06ff5a471..98265792bb7 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -147,11 +147,6 @@ O atributo TailCall só deve ser aplicado a funções recursivas. - - Variable patterns should be lowercase. - Variable patterns should be lowercase. - - The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. O 'AssemblyKeyNameAttribute' foi preterido. Use o 'AssemblyKeyFileAttribute'. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 8938011cafc..272a31d7329 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -147,11 +147,6 @@ Атрибут TailCall следует применять только к рекурсивным функциям. - - Variable patterns should be lowercase. - Variable patterns should be lowercase. - - The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. Атрибут "AssemblyKeyNameAttribute" является устаревшим. Используйте вместо него атрибут "AssemblyKeyFileAttribute". diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index e83826e9293..43d8b371206 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -147,11 +147,6 @@ TailCall özniteliği yalnızca özyinelemeli işlevlere uygulanmalıdır. - - Variable patterns should be lowercase. - Variable patterns should be lowercase. - - The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. 'AssemblyKeyNameAttribute' kullanım dışı bırakıldı. Bunun yerine 'AssemblyKeyFileAttribute' kullanın. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 62d5d929eda..8e435be8f97 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -147,11 +147,6 @@ TailCall 属性应仅应用于递归函数。 - - Variable patterns should be lowercase. - Variable patterns should be lowercase. - - The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. "AssemblyKeyNameAttribute" 已被弃用。请改为使用 "AssemblyKeyFileAttribute"。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index f119c38c57b..0354bc8d14e 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -147,11 +147,6 @@ TailCall 屬性只應套用至遞迴函數。 - - Variable patterns should be lowercase. - Variable patterns should be lowercase. - - The 'AssemblyKeyNameAttribute' has been deprecated. Use 'AssemblyKeyFileAttribute' instead. 'AssemblyKeyNameAttribute' 已淘汰。請改用 'AssemblyKeyFileAttribute'。 diff --git a/src/Compiler/xlf/FSStrings.cs.xlf b/src/Compiler/xlf/FSStrings.cs.xlf index 4d8aa69f6a0..20b53f76f45 100644 --- a/src/Compiler/xlf/FSStrings.cs.xlf +++ b/src/Compiler/xlf/FSStrings.cs.xlf @@ -153,7 +153,7 @@ - Match cases labels must be lowercase identifiers + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. Identifikátory proměnných psané velkými písmeny se ve vzorech obecně nedoporučují. Můžou označovat chybějící otevřenou deklaraci nebo špatně napsaný název vzoru. diff --git a/src/Compiler/xlf/FSStrings.de.xlf b/src/Compiler/xlf/FSStrings.de.xlf index 19060b8fa9e..f58d3a4711d 100644 --- a/src/Compiler/xlf/FSStrings.de.xlf +++ b/src/Compiler/xlf/FSStrings.de.xlf @@ -153,7 +153,7 @@ - Match cases labels must be lowercase identifiers + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. Variablenbezeichner in Großbuchstaben sollten im Allgemeinen nicht in Mustern verwendet werden und können ein Hinweis auf eine fehlende open-Deklaration oder einen falsch geschriebenen Musternamen sein. diff --git a/src/Compiler/xlf/FSStrings.es.xlf b/src/Compiler/xlf/FSStrings.es.xlf index 421ef4684b1..88a130d699d 100644 --- a/src/Compiler/xlf/FSStrings.es.xlf +++ b/src/Compiler/xlf/FSStrings.es.xlf @@ -153,7 +153,7 @@ - Match cases labels must be lowercase identifiers + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. En general, los identificadores de variables en mayúscula no deben usarse en patrones y pueden indicar una declaración abierta que falta o un nombre de patrón mal escrito. diff --git a/src/Compiler/xlf/FSStrings.fr.xlf b/src/Compiler/xlf/FSStrings.fr.xlf index c046ee511d9..7d7badde4ed 100644 --- a/src/Compiler/xlf/FSStrings.fr.xlf +++ b/src/Compiler/xlf/FSStrings.fr.xlf @@ -153,7 +153,7 @@ - Match cases labels must be lowercase identifiers + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. Les identificateurs de variables en majuscules ne doivent généralement pas être utilisés dans les modèles. Ils peuvent indiquer une absence de déclaration open ou un nom de modèle mal orthographié. diff --git a/src/Compiler/xlf/FSStrings.it.xlf b/src/Compiler/xlf/FSStrings.it.xlf index a0eb386ed64..f43c8e77851 100644 --- a/src/Compiler/xlf/FSStrings.it.xlf +++ b/src/Compiler/xlf/FSStrings.it.xlf @@ -153,7 +153,7 @@ - Match cases labels must be lowercase identifiers + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. In genere è consigliabile non usare identificatori di variabili scritti in maiuscolo nei criteri perché potrebbero indicare una dichiarazione OPEN mancante o un nome di criterio con ortografia errata. diff --git a/src/Compiler/xlf/FSStrings.ja.xlf b/src/Compiler/xlf/FSStrings.ja.xlf index 5607c8bd89f..6f0a3a978e9 100644 --- a/src/Compiler/xlf/FSStrings.ja.xlf +++ b/src/Compiler/xlf/FSStrings.ja.xlf @@ -153,7 +153,7 @@ - Match cases labels must be lowercase identifiers + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. 通常、大文字の変数識別子はパターンに使用できません。また、欠落している open 宣言か、つづりが間違っているパターン名を示す可能性があります。 diff --git a/src/Compiler/xlf/FSStrings.ko.xlf b/src/Compiler/xlf/FSStrings.ko.xlf index 01181cf9b33..43e0a0f1739 100644 --- a/src/Compiler/xlf/FSStrings.ko.xlf +++ b/src/Compiler/xlf/FSStrings.ko.xlf @@ -153,7 +153,7 @@ - Match cases labels must be lowercase identifiers + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. 일반적으로 대문자 변수 식별자는 패턴에 사용하지 말아야 합니다. 이러한 식별자는 열려 있는 선언이 없거나 철자가 잘못된 패턴 이름을 나타낼 수 있습니다. diff --git a/src/Compiler/xlf/FSStrings.pl.xlf b/src/Compiler/xlf/FSStrings.pl.xlf index f0862814773..3096fca8dbf 100644 --- a/src/Compiler/xlf/FSStrings.pl.xlf +++ b/src/Compiler/xlf/FSStrings.pl.xlf @@ -153,7 +153,7 @@ - Match cases labels must be lowercase identifiers + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. Identyfikatory zmiennych pisane wielkimi literami nie powinny być na ogół używane we wzorcach i mogą oznaczać brak deklaracji otwierającej lub błąd pisowni w nazwie wzorca. diff --git a/src/Compiler/xlf/FSStrings.pt-BR.xlf b/src/Compiler/xlf/FSStrings.pt-BR.xlf index 63261920e55..ea48f4c3545 100644 --- a/src/Compiler/xlf/FSStrings.pt-BR.xlf +++ b/src/Compiler/xlf/FSStrings.pt-BR.xlf @@ -153,7 +153,7 @@ - Match cases labels must be lowercase identifiers + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. Identificadores de variáveis em maiúsculas geralmente não devem ser usados em padrões, podendo indicar uma declaração aberta ausente ou um nome de padrão escrito incorretamente. diff --git a/src/Compiler/xlf/FSStrings.ru.xlf b/src/Compiler/xlf/FSStrings.ru.xlf index c72de8f2738..7cb20b5e8de 100644 --- a/src/Compiler/xlf/FSStrings.ru.xlf +++ b/src/Compiler/xlf/FSStrings.ru.xlf @@ -153,7 +153,7 @@ - Match cases labels must be lowercase identifiers + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. Идентификаторы переменных в верхнем регистре обычно не должны использоваться в шаблонах, и могут указывать на отсутствующую открытую декларацию или неправильно написанное имя шаблона. diff --git a/src/Compiler/xlf/FSStrings.tr.xlf b/src/Compiler/xlf/FSStrings.tr.xlf index 12c61f4d85e..9c65fabe248 100644 --- a/src/Compiler/xlf/FSStrings.tr.xlf +++ b/src/Compiler/xlf/FSStrings.tr.xlf @@ -153,7 +153,7 @@ - Match cases labels must be lowercase identifiers + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. Büyük harfli değişken tanımlayıcıları desenlerde genel olarak kullanılmamalıdır. Bunlar, eksik bir açık bildirimin veya yanlış yazılmış bir desen adının göstergesi olabilirler. diff --git a/src/Compiler/xlf/FSStrings.zh-Hans.xlf b/src/Compiler/xlf/FSStrings.zh-Hans.xlf index 5886241f37b..c895f08ec60 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hans.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hans.xlf @@ -153,7 +153,7 @@ - Match cases labels must be lowercase identifiers + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. 通常不得在模式中使用大写的变量标识符,存在它们可能表示缺少某个开放声明或某个模式名称拼写错误。 diff --git a/src/Compiler/xlf/FSStrings.zh-Hant.xlf b/src/Compiler/xlf/FSStrings.zh-Hant.xlf index 2d7f19ec059..d81a539866e 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hant.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hant.xlf @@ -153,7 +153,7 @@ - Match cases labels must be lowercase identifiers + Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. 通常不應在樣式中使用大寫的變數識別碼。這可能表示缺少公開宣告或樣式名稱拼字錯誤。 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs index a2b935c620f..cf2f4a833cc 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs @@ -153,27 +153,27 @@ module BindingExpressions = |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 3874, Line 11, Col 8, Line 11, Col 11, "Variable patterns should be lowercase.") - (Warning 3874, Line 11, Col 12, Line 11, Col 15, "Variable patterns should be lowercase.") - (Warning 3874, Line 13, Col 8, Line 13, Col 11, "Variable patterns should be lowercase.") - (Warning 3874, Line 13, Col 12, Line 13, Col 15, "Variable patterns should be lowercase.") - (Warning 3874, Line 22, Col 22, Line 22, Col 25, "Variable patterns should be lowercase.") - (Warning 3874, Line 22, Col 27, Line 22, Col 30, "Variable patterns should be lowercase.") - (Warning 3874, Line 24, Col 22, Line 24, Col 25, "Variable patterns should be lowercase.") - (Warning 3874, Line 24, Col 26, Line 24, Col 29, "Variable patterns should be lowercase.") - (Warning 3874, Line 32, Col 20, Line 32, Col 23, "Variable patterns should be lowercase.") - (Warning 3874, Line 32, Col 25, Line 32, Col 28, "Variable patterns should be lowercase.") - (Warning 3874, Line 34, Col 21, Line 34, Col 24, "Variable patterns should be lowercase.") - (Warning 3874, Line 34, Col 25, Line 34, Col 28, "Variable patterns should be lowercase.") - (Warning 3874, Line 42, Col 31, Line 42, Col 34, "Variable patterns should be lowercase.") - (Warning 3874, Line 46, Col 5, Line 46, Col 8, "Variable patterns should be lowercase.") - (Warning 3874, Line 53, Col 18, Line 53, Col 21, "Variable patterns should be lowercase.") - (Warning 3874, Line 67, Col 9, Line 67, Col 14, "Variable patterns should be lowercase.") - (Warning 3874, Line 73, Col 9, Line 73, Col 18, "Variable patterns should be lowercase.") - (Warning 3874, Line 80, Col 9, Line 80, Col 18, "Variable patterns should be lowercase.") - (Warning 3874, Line 87, Col 9, Line 87, Col 18, "Variable patterns should be lowercase.") - (Warning 3874, Line 117, Col 37, Line 117, Col 40, "Variable patterns should be lowercase.") - (Warning 3874, Line 122, Col 12, Line 122, Col 15, "Variable patterns should be lowercase.") + (Warning 49, Line 11, Col 8, Line 11, Col 11, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 11, Col 12, Line 11, Col 15, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 13, Col 8, Line 13, Col 11, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 13, Col 12, Line 13, Col 15, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 22, Col 22, Line 22, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 22, Col 27, Line 22, Col 30, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 24, Col 22, Line 24, Col 25, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 24, Col 26, Line 24, Col 29, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 32, Col 20, Line 32, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 32, Col 25, Line 32, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 34, Col 21, Line 34, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 34, Col 25, Line 34, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 42, Col 31, Line 42, Col 34, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 46, Col 5, Line 46, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 53, Col 18, Line 53, Col 21, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 67, Col 9, Line 67, Col 14, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 73, Col 9, Line 73, Col 18, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 80, Col 9, Line 80, Col 18, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 87, Col 9, Line 87, Col 18, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 117, Col 37, Line 117, Col 40, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 122, Col 12, Line 122, Col 15, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] [] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs index bb805266898..e161faded77 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs @@ -45,8 +45,8 @@ module Simple = |> compile |> shouldFail |> withDiagnostics [ - (Warning 49, Line 9, Col 16, Line 9, Col 19, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 10, Col 16, Line 10, Col 19, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 9, Col 16, Line 9, Col 19, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 10, Col 16, Line 10, Col 19, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] [] @@ -58,8 +58,8 @@ module Simple = |> compile |> shouldFail |> withDiagnostics [ - (Warning 49, Line 9, Col 16, Line 9, Col 19, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 10, Col 16, Line 10, Col 19, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 9, Col 16, Line 9, Col 19, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 10, Col 16, Line 10, Col 19, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs index 72970db77bf..88e98b14542 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs @@ -219,17 +219,17 @@ but here has type |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 15, Col 7, Line 15, Col 10, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 16, Col 7, Line 16, Col 10, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 20, Col 7, Line 20, Col 10, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 24, Col 3, Line 24, Col 6, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 35, Col 14, Line 35, Col 17, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 41, Col 12, Line 41, Col 15, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 45, Col 20, Line 45, Col 23, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 50, Col 14, Line 50, Col 17, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 50, Col 21, Line 50, Col 24, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 51, Col 14, Line 51, Col 17, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 52, Col 14, Line 52, Col 17, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 15, Col 7, Line 15, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 16, Col 7, Line 16, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 20, Col 7, Line 20, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 24, Col 3, Line 24, Col 6, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 35, Col 14, Line 35, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 41, Col 12, Line 41, Col 15, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 45, Col 20, Line 45, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 50, Col 14, Line 50, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 50, Col 21, Line 50, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 51, Col 14, Line 51, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 52, Col 14, Line 52, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] [] @@ -241,16 +241,16 @@ but here has type |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 3, Col 7, Line 3, Col 9, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 4, Col 7, Line 4, Col 9, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 5, Col 7, Line 5, Col 8, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 9, Col 7, Line 9, Col 9, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 10, Col 7, Line 10, Col 9, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 11, Col 7, Line 11, Col 8, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 15, Col 7, Line 15, Col 10, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 16, Col 7, Line 16, Col 10, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 20, Col 7, Line 20, Col 10, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 24, Col 3, Line 24, Col 6, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 28, Col 3, Line 28, Col 5, "Match cases labels must be lowercase identifiers") - (Warning 49, Line 35, Col 14, Line 35, Col 17, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 3, Col 7, Line 3, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 4, Col 7, Line 4, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 5, Col 7, Line 5, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 9, Col 7, Line 9, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 10, Col 7, Line 10, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 11, Col 7, Line 11, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 15, Col 7, Line 15, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 16, Col 7, Line 16, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 20, Col 7, Line 20, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 24, Col 3, Line 24, Col 6, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 28, Col 3, Line 28, Col 5, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 35, Col 14, Line 35, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] \ No newline at end of file From e126d0a1cba4d6700f37e2838e5e7c0cfaad4e2b Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 31 Oct 2024 12:08:11 +0000 Subject: [PATCH 43/49] Revert "update tests" This reverts commit 8f69e6774f611ae1bde4cef975597d8e2234c0e8. --- tests/fsharp/typecheck/sigs/neg07.bsl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/fsharp/typecheck/sigs/neg07.bsl b/tests/fsharp/typecheck/sigs/neg07.bsl index 196bd70b314..3a32ac5abb8 100644 --- a/tests/fsharp/typecheck/sigs/neg07.bsl +++ b/tests/fsharp/typecheck/sigs/neg07.bsl @@ -1,21 +1,21 @@ -neg07.fs(7,10,7,29): typecheck error FS3874: typecheck error FS3874: Variable patterns should be lowercase. +neg07.fs(7,10,7,29): typecheck error FS0049: Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. neg07.fs(24,13,24,23): typecheck error FS0039: The value or constructor 'UnionCase1' is not defined. Maybe you want one of the following: X.UnionCase1 -neg07.fs(27,11,27,21): typecheck error FS0049: Match cases labels must be lowercase identifiers +neg07.fs(27,11,27,21): typecheck error FS0049: Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. -neg07.fs(28,11,28,21): typecheck error FS0049: Match cases labels must be lowercase identifiers +neg07.fs(28,11,28,21): typecheck error FS0049: Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. neg07.fs(28,11,28,21): typecheck error FS0026: This rule will never be matched neg07.fs(31,18,31,28): typecheck error FS0039: The value or constructor 'UnionCase1' is not defined. Maybe you want one of the following: X.UnionCase1 -neg07.fs(35,11,35,21): typecheck error FS0049: Match cases labels must be lowercase identifiers +neg07.fs(35,11,35,21): typecheck error FS0049: Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. -neg07.fs(36,11,36,21): typecheck error FS0049: Match cases labels must be lowercase identifiers +neg07.fs(36,11,36,21): typecheck error FS0049: Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. neg07.fs(36,11,36,21): typecheck error FS0026: This rule will never be matched From 1ec5c871b0e5fe2cefe93ed01cb98f66cc0682d0 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 31 Oct 2024 12:11:07 +0000 Subject: [PATCH 44/49] Revert "update fsharpqa tests" This reverts commit 2f5d8789a66b0691ea0c47b8ab26ffbb7bfe0cbc. --- .../DataExpressions/QueryExpressions/W_UppercaseIdentifier01.fs | 2 +- .../DataExpressions/QueryExpressions/W_UppercaseIdentifier02.fs | 2 +- .../DataExpressions/QueryExpressions/W_UppercaseIdentifier03.fs | 2 +- .../Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fs | 2 +- .../LexicalAnalysis/Directives/multiple_nowarn01.fsx | 2 +- .../LexicalAnalysis/Directives/multiple_nowarn02.fsx | 2 +- .../LexicalAnalysis/Directives/multiple_nowarn_many.fs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier01.fs b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier01.fs index d12212f1fb8..1a425cc70ac 100644 --- a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier01.fs +++ b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier01.fs @@ -1,7 +1,7 @@ // Regression test for DevDiv:305886 // [QueryExpressions] Identifiers for range variables in for-join queries cannot be uppercase! // We expect a simple warning. -//Variable patterns should be lowercase\.$ +//Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name\.$ module M // Warning diff --git a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier02.fs b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier02.fs index 29994ff268c..b7bcb21fffb 100644 --- a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier02.fs +++ b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier02.fs @@ -1,7 +1,7 @@ // Regression test for DevDiv:305886 // [QueryExpressions] Identifiers for range variables in for-join queries cannot be uppercase! // We expect a simple warning. -//Variable patterns should be lowercase\.$ +//Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name\.$ module M // Warning diff --git a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier03.fs b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier03.fs index f01a271fb54..0df77bb848e 100644 --- a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier03.fs +++ b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/W_UppercaseIdentifier03.fs @@ -1,7 +1,7 @@ // Regression test for DevDiv:305886 // [QueryExpressions] Identifiers for range variables in for-join queries cannot be uppercase! // We expect a simple warning. -//Variable patterns should be lowercase\.$ +//Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name\.$ module M // Warning diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fs b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fs index 4cd183da1f0..726f2b8658b 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fs +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fs @@ -1,7 +1,7 @@ // #Regression #Conformance #LexicalAnalysis #ReqNOMT // Regression test for FSHARP1.0:6044 -#nowarn "44" "3874" +#nowarn "44" "49" [] let obsoleteIdentifier = 12 diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fsx b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fsx index 4cd183da1f0..726f2b8658b 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fsx +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fsx @@ -1,7 +1,7 @@ // #Regression #Conformance #LexicalAnalysis #ReqNOMT // Regression test for FSHARP1.0:6044 -#nowarn "44" "3874" +#nowarn "44" "49" [] let obsoleteIdentifier = 12 diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn02.fsx b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn02.fsx index 699b5d7be57..02a97bb444e 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn02.fsx +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn02.fsx @@ -1,7 +1,7 @@ // #Regression #Conformance #LexicalAnalysis #ReqNOMT // Regression test for FSHARP1.0:6044 -#nowarn "44" "3874" +#nowarn "44" "49" [] let obsoleteIdentifier = 12 diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn_many.fs b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn_many.fs index d5e819f651e..c4c1f6278c7 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn_many.fs +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn_many.fs @@ -1,7 +1,7 @@ // #Regression #Conformance #LexicalAnalysis #ReqNOMT // Regression test for FSHARP1.0:6044 // 100 nowarns... -#nowarn "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44" "45" "46" "47" "48" "3874" "50" "51" "52" "53" "54" "55" "56" "57" "58" "59" "60" "61" "62" "63" "64" "65" "66" "67" "68" "69" "70" "71" "72" "73" "74" "75" "76" "77" "78" "79" "80" "81" "82" "83" "84" "85" "86" "87" "88" "89" "90" "91" "92" "93" "94" "95" "96" "97" "98" "99" +#nowarn "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44" "45" "46" "47" "48" "49" "50" "51" "52" "53" "54" "55" "56" "57" "58" "59" "60" "61" "62" "63" "64" "65" "66" "67" "68" "69" "70" "71" "72" "73" "74" "75" "76" "77" "78" "79" "80" "81" "82" "83" "84" "85" "86" "87" "88" "89" "90" "91" "92" "93" "94" "95" "96" "97" "98" "99" [] let obsoleteIdentifier = 12 From f34f9a34feb8b03e6b5c9c1758b0356a31bdec9e Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 31 Oct 2024 12:22:41 +0000 Subject: [PATCH 45/49] Rename LanguageFeature --- src/Compiler/Checking/CheckPatterns.fs | 6 +++--- src/Compiler/Checking/NameResolution.fs | 2 +- src/Compiler/FSComp.txt | 2 +- src/Compiler/Facilities/LanguageFeatures.fs | 6 +++--- src/Compiler/Facilities/LanguageFeatures.fsi | 2 +- 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 +++++----- 18 files changed, 74 insertions(+), 74 deletions(-) diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index dcb25087f62..026710a8f81 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -61,7 +61,7 @@ let UnifyRefTupleType contextInfo (cenv: cenv) denv m ty ps = let rec TryAdjustHiddenVarNameToCompGenName (cenv: cenv) env (id: Ident) altNameRefCellOpt = match altNameRefCellOpt with | Some ({contents = SynSimplePatAlternativeIdInfo.Undecided altId } as altNameRefCell) -> - let supportsWarnOnUpperIdentifiersInPatterns = cenv.g.langVersion.SupportsFeature(LanguageFeature.WarnOnUppercaseIdentifiersInPatterns) + let supportsWarnOnUpperIdentifiersInPatterns = cenv.g.langVersion.SupportsFeature(LanguageFeature.DontWarnOnUppercaseIdentifiersInBindingPatterns) let warnOnUpperFlag = if supportsWarnOnUpperIdentifiersInPatterns then WarnOnUpperVariablePatterns else AllIdsOK match ResolvePatternLongIdent cenv.tcSink cenv.nameResolver warnOnUpperFlag false id.idRange env.eAccessRights env.eNameResEnv TypeNameResolutionInfo.Default [id] ExtraDotAfterIdentifier.No with | Item.NewDef _ -> @@ -359,7 +359,7 @@ and TcPatNamedAs warnOnUpper cenv env valReprInfo vFlags patEnv ty synInnerPat i and TcPatUnnamedAs warnOnUpper cenv env vFlags patEnv ty pat1 pat2 m = let pats = [pat1; pat2] let warnOnUpper = - if cenv.g.langVersion.SupportsFeature(LanguageFeature.WarnOnUppercaseIdentifiersInPatterns) then + if cenv.g.langVersion.SupportsFeature(LanguageFeature.DontWarnOnUppercaseIdentifiersInBindingPatterns) then AllIdsOK else warnOnUpper @@ -468,7 +468,7 @@ and TcRecordPat warnOnUpper (cenv: cenv) env vFlags patEnv ty fieldPats m = match fldsmap.TryGetValue fsp.rfield_id.idText with | true, v -> let warnOnUpper = - if cenv.g.langVersion.SupportsFeature(LanguageFeature.WarnOnUppercaseIdentifiersInPatterns) then + if cenv.g.langVersion.SupportsFeature(LanguageFeature.DontWarnOnUppercaseIdentifiersInBindingPatterns) then AllIdsOK else warnOnUpper diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index 028ee084387..674bca446bc 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -3392,7 +3392,7 @@ let rec ResolvePatternLongIdentPrim sink (ncenv: NameResolver) fullyQualified wa | true, res when not newDef -> ResolveUnqualifiedItem ncenv nenv m res | _ -> // Single identifiers in patterns - variable bindings - let supportsWarnOnUpperIdentifiersInPatterns = ncenv.g.langVersion.SupportsFeature(LanguageFeature.WarnOnUppercaseIdentifiersInPatterns) + let supportsWarnOnUpperIdentifiersInPatterns = ncenv.g.langVersion.SupportsFeature(LanguageFeature.DontWarnOnUppercaseIdentifiersInBindingPatterns) if (supportsWarnOnUpperIdentifiersInPatterns && not newDef && System.Char.ToLowerInvariant id.idText[0] <> id.idText[0]) then match warnOnUpper with diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 396b8ba806e..273c2489d54 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1784,6 +1784,6 @@ featureAllowAccessModifiersToAutoPropertiesGettersAndSetters,"Allow access modif 3871,tcAccessModifiersNotAllowedInSRTPConstraint,"Access modifiers cannot be applied to an SRTP constraint." featureAllowObjectExpressionWithoutOverrides,"Allow object expressions without overrides" 3872,tcPartialActivePattern,"Multi-case partial active patterns are not supported. Consider using a single-case partial active pattern or a full active pattern." -featureWarnOnUppercaseIdentifiersInPatterns,"Warn on uppercase identifiers in patterns" +featureDontWarnOnUppercaseIdentifiersInBindingPatterns,"Don't warn on uppercase identifiers in binding patterns" 3873,chkDeprecatePlacesWhereSeqCanBeOmitted,"This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'" featureDeprecatePlacesWhereSeqCanBeOmitted,"Deprecate places where 'seq' can be omitted" \ No newline at end of file diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index f80758e67ef..7b6651be2e6 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -94,7 +94,7 @@ type LanguageFeature = | ParsedHashDirectiveArgumentNonQuotes | EmptyBodiedComputationExpressions | AllowObjectExpressionWithoutOverrides - | WarnOnUppercaseIdentifiersInPatterns + | DontWarnOnUppercaseIdentifiersInBindingPatterns | DeprecatePlacesWhereSeqCanBeOmitted /// LanguageVersion management @@ -221,7 +221,7 @@ type LanguageVersion(versionText) = LanguageFeature.FromEndSlicing, previewVersion // Unfinished features --- needs work LanguageFeature.AllowAccessModifiersToAutoPropertiesGettersAndSetters, previewVersion LanguageFeature.AllowObjectExpressionWithoutOverrides, previewVersion - LanguageFeature.WarnOnUppercaseIdentifiersInPatterns, previewVersion + LanguageFeature.DontWarnOnUppercaseIdentifiersInBindingPatterns, previewVersion LanguageFeature.DeprecatePlacesWhereSeqCanBeOmitted, previewVersion ] @@ -379,7 +379,7 @@ type LanguageVersion(versionText) = | LanguageFeature.ParsedHashDirectiveArgumentNonQuotes -> FSComp.SR.featureParsedHashDirectiveArgumentNonString () | LanguageFeature.EmptyBodiedComputationExpressions -> FSComp.SR.featureEmptyBodiedComputationExpressions () | LanguageFeature.AllowObjectExpressionWithoutOverrides -> FSComp.SR.featureAllowObjectExpressionWithoutOverrides () - | LanguageFeature.WarnOnUppercaseIdentifiersInPatterns -> FSComp.SR.featureWarnOnUppercaseIdentifiersInPatterns () + | LanguageFeature.DontWarnOnUppercaseIdentifiersInBindingPatterns -> FSComp.SR.featureDontWarnOnUppercaseIdentifiersInBindingPatterns () | LanguageFeature.DeprecatePlacesWhereSeqCanBeOmitted -> FSComp.SR.featureDeprecatePlacesWhereSeqCanBeOmitted () /// Get a version string associated with the given feature. diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index d535c7453d3..e8820f5b38a 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -85,7 +85,7 @@ type LanguageFeature = | ParsedHashDirectiveArgumentNonQuotes | EmptyBodiedComputationExpressions | AllowObjectExpressionWithoutOverrides - | WarnOnUppercaseIdentifiersInPatterns + | DontWarnOnUppercaseIdentifiersInBindingPatterns | DeprecatePlacesWhereSeqCanBeOmitted /// LanguageVersion management diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 99bc12f43e8..938dab3e303 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -337,6 +337,11 @@ vzor discard ve vazbě použití + + Don't warn on uppercase identifiers in binding patterns + Don't warn on uppercase identifiers in binding patterns + + dotless float32 literal literál float32 bez tečky @@ -622,11 +627,6 @@ Interoperabilita mezi neřízeným obecným omezením jazyka C# a F# (emitovat další modreq) - - Warn on uppercase identifiers in patterns - Warn on uppercase identifiers in patterns - - Indexed properties getter and setter must have the same type Metoda getter a setter indexované vlastnosti musí mít stejný typ. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 339fc6e66f4..b189d5d6965 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -337,6 +337,11 @@ Das Verwerfen des verwendeten Musters ist verbindlich. + + Don't warn on uppercase identifiers in binding patterns + Don't warn on uppercase identifiers in binding patterns + + dotless float32 literal punktloses float32-Literal @@ -622,11 +627,6 @@ Interop zwischen nicht verwalteter generischer Einschränkung in C# und F# (zusätzlicher ModReq ausgeben) - - Warn on uppercase identifiers in patterns - Warn on uppercase identifiers in patterns - - Indexed properties getter and setter must have the same type Getter und Setter für indizierte Eigenschaften müssen denselben Typ aufweisen. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index f0b55298fd1..b21bc460406 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -337,6 +337,11 @@ descartar enlace de patrón en uso + + Don't warn on uppercase identifiers in binding patterns + Don't warn on uppercase identifiers in binding patterns + + dotless float32 literal literal float32 sin punto @@ -622,11 +627,6 @@ Interoperabilidad entre la restricción genérica no administrada de C# y F# (emitir modreq adicional) - - Warn on uppercase identifiers in patterns - Warn on uppercase identifiers in patterns - - Indexed properties getter and setter must have the same type El captador y el establecedor de propiedades indexadas deben tener el mismo tipo. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index d5e3c520e1f..ff6fd6fb8ae 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -337,6 +337,11 @@ annuler le modèle dans la liaison d’utilisation + + Don't warn on uppercase identifiers in binding patterns + Don't warn on uppercase identifiers in binding patterns + + dotless float32 literal littéral float32 sans point @@ -622,11 +627,6 @@ Interopérabilité entre les contraintes génériques non gérées de C# et F# (émettre un modreq supplémentaire) - - Warn on uppercase identifiers in patterns - Warn on uppercase identifiers in patterns - - Indexed properties getter and setter must have the same type Les propriétés indexées getter et setter doivent avoir le même type diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 802c5c95f2a..a7da11ccee1 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -337,6 +337,11 @@ rimuovi criterio nell'utilizzo dell'associazione + + Don't warn on uppercase identifiers in binding patterns + Don't warn on uppercase identifiers in binding patterns + + dotless float32 literal valore letterale float32 senza punti @@ -622,11 +627,6 @@ Interoperabilità tra il vincolo generico non gestito di C# e di F# (crea un modreq aggiuntivo) - - Warn on uppercase identifiers in patterns - Warn on uppercase identifiers in patterns - - Indexed properties getter and setter must have the same type Il getter e il setter delle proprietà indicizzate devono avere lo stesso tipo diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 6da7ef9148a..db59d57ba67 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -337,6 +337,11 @@ 使用バインドでパターンを破棄する + + Don't warn on uppercase identifiers in binding patterns + Don't warn on uppercase identifiers in binding patterns + + dotless float32 literal ドットなしの float32 リテラル @@ -622,11 +627,6 @@ C# と F# のアンマネージド ジェネリック制約の間の相互運用 (追加の modreq を出力) - - Warn on uppercase identifiers in patterns - Warn on uppercase identifiers in patterns - - Indexed properties getter and setter must have the same type インデックス付きプロパティのゲッターとセッターの型は同じである必要があります diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index fc696d4e7a5..d02c5849251 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -337,6 +337,11 @@ 사용 중인 패턴 바인딩 무시 + + Don't warn on uppercase identifiers in binding patterns + Don't warn on uppercase identifiers in binding patterns + + dotless float32 literal 점이 없는 float32 리터럴 @@ -622,11 +627,6 @@ C#과 F#의 관리되지 않는 제네릭 제약 조건 간의 Interop(추가 modreq 내보내기) - - Warn on uppercase identifiers in patterns - Warn on uppercase identifiers in patterns - - Indexed properties getter and setter must have the same type 인덱싱된 속성 getter와 setter의 형식이 같아야 합니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index e17fbf1515c..07a525cffcb 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -337,6 +337,11 @@ odrzuć wzorzec w powiązaniu użycia + + Don't warn on uppercase identifiers in binding patterns + Don't warn on uppercase identifiers in binding patterns + + dotless float32 literal bezkropkowy literał float32 @@ -622,11 +627,6 @@ Międzyoperacyjnie między niezarządzanym ograniczeniem ogólnym języka C# i F# (emituj dodatkowe modreq) - - Warn on uppercase identifiers in patterns - Warn on uppercase identifiers in patterns - - Indexed properties getter and setter must have the same type Metoda pobierająca i metoda ustawiająca właściwości indeksowanych muszą mieć taki sam typ. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 98265792bb7..8f0c398f123 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -337,6 +337,11 @@ descartar o padrão em uso de associação + + Don't warn on uppercase identifiers in binding patterns + Don't warn on uppercase identifiers in binding patterns + + dotless float32 literal literal float32 sem ponto @@ -622,11 +627,6 @@ Interoperabilidade entre a restrição genérica não gerenciada de C# e F# (emitir modreq adicional) - - Warn on uppercase identifiers in patterns - Warn on uppercase identifiers in patterns - - Indexed properties getter and setter must have the same type As propriedades indexadas getter e setter devem ter o mesmo tipo diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 272a31d7329..1b404f73d6a 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -337,6 +337,11 @@ шаблон отмены в привязке использования + + Don't warn on uppercase identifiers in binding patterns + Don't warn on uppercase identifiers in binding patterns + + dotless float32 literal литерал float32 без точки @@ -622,11 +627,6 @@ Взаимодействие между универсальным ограничением "unmanaged" C# и F#(создание дополнительного modreq) - - Warn on uppercase identifiers in patterns - Warn on uppercase identifiers in patterns - - Indexed properties getter and setter must have the same type Методы получения и установки индексированных свойств должны иметь один и тот же тип. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 43d8b371206..312ac85e069 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -337,6 +337,11 @@ kullanım bağlamasında deseni at + + Don't warn on uppercase identifiers in binding patterns + Don't warn on uppercase identifiers in binding patterns + + dotless float32 literal noktasız float32 sabit değeri @@ -622,11 +627,6 @@ C# ile F#' arasında yönetilmeyen genel kısıtlama (ek modreq yayın) - - Warn on uppercase identifiers in patterns - Warn on uppercase identifiers in patterns - - Indexed properties getter and setter must have the same type Dizini oluşturulmuş özelliklerin alıcısı ve ayarlayıcısı aynı türde olmalıdır diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 8e435be8f97..05af9c3fab8 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -337,6 +337,11 @@ 放弃使用绑定模式 + + Don't warn on uppercase identifiers in binding patterns + Don't warn on uppercase identifiers in binding patterns + + dotless float32 literal 无点 float32 文本 @@ -622,11 +627,6 @@ C# 和 F# 的非托管泛型约束之间的互操作(发出额外的 modreq) - - Warn on uppercase identifiers in patterns - Warn on uppercase identifiers in patterns - - Indexed properties getter and setter must have the same type 索引属性 getter 和 setter 必须具有相同的类型 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 0354bc8d14e..f697dd05514 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -337,6 +337,11 @@ 捨棄使用繫結中的模式 + + Don't warn on uppercase identifiers in binding patterns + Don't warn on uppercase identifiers in binding patterns + + dotless float32 literal 無點號的 float32 常值 @@ -622,11 +627,6 @@ C# 與 F# 的非受控泛型條件約束之間的 Interop (發出額外的 modreq) - - Warn on uppercase identifiers in patterns - Warn on uppercase identifiers in patterns - - Indexed properties getter and setter must have the same type 索引屬性 getter 和 setter 必須具有相同的類型 From 824412478bd175f69ec9e5f7dd98cb0b37874045 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 31 Oct 2024 13:15:41 +0000 Subject: [PATCH 46/49] 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 7b6651be2e6..af83a76f2fa 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -379,7 +379,8 @@ type LanguageVersion(versionText) = | LanguageFeature.ParsedHashDirectiveArgumentNonQuotes -> FSComp.SR.featureParsedHashDirectiveArgumentNonString () | LanguageFeature.EmptyBodiedComputationExpressions -> FSComp.SR.featureEmptyBodiedComputationExpressions () | LanguageFeature.AllowObjectExpressionWithoutOverrides -> FSComp.SR.featureAllowObjectExpressionWithoutOverrides () - | LanguageFeature.DontWarnOnUppercaseIdentifiersInBindingPatterns -> FSComp.SR.featureDontWarnOnUppercaseIdentifiersInBindingPatterns () + | LanguageFeature.DontWarnOnUppercaseIdentifiersInBindingPatterns -> + FSComp.SR.featureDontWarnOnUppercaseIdentifiersInBindingPatterns () | LanguageFeature.DeprecatePlacesWhereSeqCanBeOmitted -> FSComp.SR.featureDeprecatePlacesWhereSeqCanBeOmitted () /// Get a version string associated with the given feature. From 698e3f25bf378e62111472d91bcc0ac5d909896f Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sat, 2 Nov 2024 12:14:11 +0000 Subject: [PATCH 47/49] Update src/Compiler/Checking/CheckPatterns.fs Co-authored-by: Tomas Grosup --- src/Compiler/Checking/CheckPatterns.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index 026710a8f81..3f97cf81780 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -542,7 +542,7 @@ and TcPatLongIdent warnOnUpper cenv env ad valReprInfo vFlags (patEnv: TcPatLine TcPatLongIdentActivePatternCase warnOnUpper cenv env vFlags patEnv ty (mLongId, item, apref, args, m) - | Item.UnionCase _ | Item.ExnCase _ as item -> + | Item.UnionCase _ | Item.ExnCase _ as item -> TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (mLongId, item, args, m) | Item.ILField finfo -> From 3adf463351cd1efbb5815dee5d324034e38622d1 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sun, 3 Nov 2024 14:18:22 +0000 Subject: [PATCH 48/49] PR review --- .../Checking/Expressions/CheckExpressions.fs | 2 +- .../Expressions/CheckSequenceExpressions.fs | 8 +- src/Compiler/Checking/NameResolution.fs | 12 ++- src/Compiler/SyntaxTree/SyntaxTree.fs | 4 + src/Compiler/SyntaxTree/SyntaxTree.fsi | 2 + ...ervice.SurfaceArea.netstandard20.debug.bsl | 70 +++++++++--------- ...vice.SurfaceArea.netstandard20.release.bsl | 70 +++++++++--------- .../QueryExpressions/UppercaseIdentifier04.fs | Bin 1066 -> 1066 bytes 8 files changed, 88 insertions(+), 80 deletions(-) diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index d68e82b0b9f..c6b1372843d 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -10642,7 +10642,7 @@ and TcMatchClause cenv inputTy (resultTy: OverallTy) env isFirst tpenv synMatchC let (SynMatchClause(synPat, synWhenExprOpt, synResultExpr, patm, spTgt, trivia)) = synMatchClause let isTrueMatchClause = - if trivia.BarRange.IsSome && trivia.ArrowRange.IsSome then + if synMatchClause.IsTrueMatchClause then TcTrueMatchClause.Yes else TcTrueMatchClause.No diff --git a/src/Compiler/Checking/Expressions/CheckSequenceExpressions.fs b/src/Compiler/Checking/Expressions/CheckSequenceExpressions.fs index 9b597952258..6f483cc2e53 100644 --- a/src/Compiler/Checking/Expressions/CheckSequenceExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckSequenceExpressions.fs @@ -270,9 +270,9 @@ let TcSequenceExpression (cenv: TcFileState) env tpenv comp (overallTy: OverallT let tclauses, tpenv = (tpenv, clauses) - ||> List.mapFold (fun tpenv (SynMatchClause(pat, cond, innerComp, _, sp, trivia)) -> + ||> List.mapFold (fun tpenv (SynMatchClause(pat, cond, innerComp, _, sp, trivia) as clause) -> let isTrueMatchClause = - if trivia.BarRange.IsSome && trivia.ArrowRange.IsSome then + if clause.IsTrueMatchClause then TcTrueMatchClause.Yes else TcTrueMatchClause.No @@ -319,9 +319,9 @@ let TcSequenceExpression (cenv: TcFileState) env tpenv comp (overallTy: OverallT // Compile the pattern twice, once as a filter with all succeeding targets returning "1", and once as a proper catch block. let clauses, tpenv = (tpenv, withList) - ||> List.mapFold (fun tpenv (SynMatchClause(pat, cond, innerComp, m, sp, trivia)) -> + ||> List.mapFold (fun tpenv (SynMatchClause(pat, cond, innerComp, m, sp, trivia) as clause) -> let isTrueMatchClause = - if trivia.BarRange.IsSome && trivia.ArrowRange.IsSome then + if clause.IsTrueMatchClause then TcTrueMatchClause.Yes else TcTrueMatchClause.No diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index 674bca446bc..5b0c9842f77 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -3392,19 +3392,17 @@ let rec ResolvePatternLongIdentPrim sink (ncenv: NameResolver) fullyQualified wa | true, res when not newDef -> ResolveUnqualifiedItem ncenv nenv m res | _ -> // Single identifiers in patterns - variable bindings - let supportsWarnOnUpperIdentifiersInPatterns = ncenv.g.langVersion.SupportsFeature(LanguageFeature.DontWarnOnUppercaseIdentifiersInBindingPatterns) - if (supportsWarnOnUpperIdentifiersInPatterns && not newDef && System.Char.ToLowerInvariant id.idText[0] <> id.idText[0]) + let supportsDontWarnOnUppercaseIdentifiers = ncenv.g.langVersion.SupportsFeature(LanguageFeature.DontWarnOnUppercaseIdentifiersInBindingPatterns) + let isUpperCaseIdentifier = (not newDef && System.Char.ToLowerInvariant id.idText[0] <> id.idText[0]) + if (supportsDontWarnOnUppercaseIdentifiers && isUpperCaseIdentifier) then match warnOnUpper with | WarnOnUpperUnionCaseLabel -> warning(UpperCaseIdentifierInPattern m) | WarnOnUpperVariablePatterns | AllIdsOK -> () else - if not newDef - // HACK: This is an historical hack that seems to related the use country and language codes, which are very common in codebases - && id.idText.Length >= 3 - && System.Char.ToLowerInvariant id.idText[0] <> id.idText[0] - then + // HACK: This is an historical hack that seems to related the use country and language codes, which are very common in codebases + if isUpperCaseIdentifier && id.idText.Length >= 3 then match warnOnUpper with | WarnOnUpperUnionCaseLabel | WarnOnUpperVariablePatterns -> warning(UpperCaseIdentifierInPattern m) diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index d0c39dc1494..8977e8fba6b 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -1047,6 +1047,10 @@ type SynMatchClause = | None -> e.Range | Some x -> unionRanges e.Range x.Range + member this.IsTrueMatchClause = + let (SynMatchClause(trivia = trivia)) = this + trivia.BarRange.IsSome && trivia.ArrowRange.IsSome + member this.Range = match this with | SynMatchClause(range = m) -> m diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index 0b24535623b..494e86bbd22 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -1177,6 +1177,8 @@ type SynMatchClause = /// Gets the syntax range of part of this construct member RangeOfGuardAndRhs: range + member IsTrueMatchClause: bool + /// Gets the syntax range of this construct member Range: range diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl index 5f4436a79f2..58788fc8fe0 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl @@ -6896,6 +6896,8 @@ FSharp.Compiler.Syntax.SynExpr+Do: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynExpr+Do: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynExpr+DoBang: FSharp.Compiler.Syntax.SynExpr expr FSharp.Compiler.Syntax.SynExpr+DoBang: FSharp.Compiler.Syntax.SynExpr get_expr() +FSharp.Compiler.Syntax.SynExpr+DoBang: FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia get_trivia() +FSharp.Compiler.Syntax.SynExpr+DoBang: FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia trivia FSharp.Compiler.Syntax.SynExpr+DoBang: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynExpr+DoBang: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynExpr+DotGet: FSharp.Compiler.Syntax.SynExpr expr @@ -7442,12 +7444,16 @@ FSharp.Compiler.Syntax.SynExpr+WhileBang: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynExpr+WhileBang: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: FSharp.Compiler.Syntax.SynExpr expr FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: FSharp.Compiler.Syntax.SynExpr get_expr() +FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia get_trivia() +FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia trivia FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: System.Tuple`2[System.Boolean,System.Boolean] flags FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: System.Tuple`2[System.Boolean,System.Boolean] get_flags() FSharp.Compiler.Syntax.SynExpr+YieldOrReturnFrom: FSharp.Compiler.Syntax.SynExpr expr FSharp.Compiler.Syntax.SynExpr+YieldOrReturnFrom: FSharp.Compiler.Syntax.SynExpr get_expr() +FSharp.Compiler.Syntax.SynExpr+YieldOrReturnFrom: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia get_trivia() +FSharp.Compiler.Syntax.SynExpr+YieldOrReturnFrom: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia trivia FSharp.Compiler.Syntax.SynExpr+YieldOrReturnFrom: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynExpr+YieldOrReturnFrom: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynExpr+YieldOrReturnFrom: System.Tuple`2[System.Boolean,System.Boolean] flags @@ -7606,13 +7612,7 @@ FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewConst(FSharp.C FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewDebugPoint(FSharp.Compiler.Syntax.DebugPointAtLeafExpr, Boolean, FSharp.Compiler.Syntax.SynExpr) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewDiscardAfterMissingQualificationAfterDot(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewDo(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range) -FSharp.Compiler.Syntax.SynExpr+DoBang: FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia get_trivia() -FSharp.Compiler.Syntax.SynExpr+DoBang: FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia trivia FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewDoBang(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia) -FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia: FSharp.Compiler.Text.Range DoBangKeyword -FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia: FSharp.Compiler.Text.Range get_DoBangKeyword() -FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia: System.String ToString() -FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia: Void .ctor(FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewDotGet(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.SynLongIdent, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewDotIndexedGet(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewDotIndexedSet(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) @@ -7668,22 +7668,8 @@ FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTyped(FSharp.C FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewUpcast(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewWhile(FSharp.Compiler.Syntax.DebugPointAtWhile, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewWhileBang(FSharp.Compiler.Syntax.DebugPointAtWhile, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range) -FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia get_trivia() -FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia trivia -FSharp.Compiler.Syntax.SynExpr+YieldOrReturnFrom: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia get_trivia() -FSharp.Compiler.Syntax.SynExpr+YieldOrReturnFrom: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia trivia FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewYieldOrReturn(System.Tuple`2[System.Boolean,System.Boolean], FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewYieldOrReturnFrom(System.Tuple`2[System.Boolean,System.Boolean], FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia) -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia: FSharp.Compiler.Text.Range YieldOrReturnFromKeyword -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia: FSharp.Compiler.Text.Range get_YieldOrReturnFromKeyword() -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia: System.String ToString() -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia: Void .ctor(FSharp.Compiler.Text.Range) -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia Zero -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia get_Zero() -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: FSharp.Compiler.Text.Range YieldOrReturnKeyword -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: FSharp.Compiler.Text.Range get_YieldOrReturnKeyword() -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: System.String ToString() -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: Void .ctor(FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr+AddressOf FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr+AnonRecd FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr+App @@ -7895,6 +7881,8 @@ FSharp.Compiler.Syntax.SynLongIdent: Microsoft.FSharp.Collections.FSharpList`1[M FSharp.Compiler.Syntax.SynLongIdent: System.String ToString() FSharp.Compiler.Syntax.SynLongIdentHelpers: FSharp.Compiler.Syntax.SynLongIdent LongIdentWithDots(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range]) FSharp.Compiler.Syntax.SynLongIdentHelpers: System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident],Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range]] |LongIdentWithDots|(FSharp.Compiler.Syntax.SynLongIdent) +FSharp.Compiler.Syntax.SynMatchClause: Boolean IsTrueMatchClause +FSharp.Compiler.Syntax.SynMatchClause: Boolean get_IsTrueMatchClause() FSharp.Compiler.Syntax.SynMatchClause: FSharp.Compiler.Syntax.DebugPointAtTarget debugPoint FSharp.Compiler.Syntax.SynMatchClause: FSharp.Compiler.Syntax.DebugPointAtTarget get_debugPoint() FSharp.Compiler.Syntax.SynMatchClause: FSharp.Compiler.Syntax.SynExpr get_resultExpr() @@ -8066,16 +8054,20 @@ FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.Syntax.Syn FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.Syntax.SynExpr inheritArgs FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.Syntax.SynType get_inheritType() FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.Syntax.SynType inheritType +FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia get_trivia() +FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia trivia FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident] get_inheritAlias() FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident] inheritAlias -FSharp.Compiler.Syntax.SynMemberDefn+Inherit: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynType] baseType -FSharp.Compiler.Syntax.SynMemberDefn+Inherit: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynType] get_baseType() +FSharp.Compiler.Syntax.SynMemberDefn+Inherit: FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia get_trivia() +FSharp.Compiler.Syntax.SynMemberDefn+Inherit: FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia trivia FSharp.Compiler.Syntax.SynMemberDefn+Inherit: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynMemberDefn+Inherit: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynMemberDefn+Inherit: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident] asIdent FSharp.Compiler.Syntax.SynMemberDefn+Inherit: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident] get_asIdent() +FSharp.Compiler.Syntax.SynMemberDefn+Inherit: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynType] baseType +FSharp.Compiler.Syntax.SynMemberDefn+Inherit: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynType] get_baseType() FSharp.Compiler.Syntax.SynMemberDefn+Interface: FSharp.Compiler.Syntax.SynType get_interfaceType() FSharp.Compiler.Syntax.SynMemberDefn+Interface: FSharp.Compiler.Syntax.SynType interfaceType FSharp.Compiler.Syntax.SynMemberDefn+Interface: FSharp.Compiler.Text.Range get_range() @@ -8150,16 +8142,8 @@ FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewAb FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewAutoProperty(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], Boolean, FSharp.Compiler.Syntax.Ident, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Syntax.SynMemberKind, FSharp.Compiler.Syntax.SynMemberFlags, FSharp.Compiler.Syntax.SynMemberFlags, FSharp.Compiler.Xml.PreXmlDoc, FSharp.Compiler.Syntax.SynValSigAccess, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynMemberDefnAutoPropertyTrivia) FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewGetSetMember(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynBinding], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynBinding], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynMemberGetSetTrivia) FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewImplicitCtor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], FSharp.Compiler.Syntax.SynPat, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident], FSharp.Compiler.Xml.PreXmlDoc, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynMemberDefnImplicitCtorTrivia) -FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia get_trivia() -FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia trivia FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewImplicitInherit(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynExpr, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia) -FSharp.Compiler.Syntax.SynMemberDefn+Inherit: FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia get_trivia() -FSharp.Compiler.Syntax.SynMemberDefn+Inherit: FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia trivia FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewInherit(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynType], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia) -FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia: FSharp.Compiler.Text.Range InheritKeyword -FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia: FSharp.Compiler.Text.Range get_InheritKeyword() -FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia: System.String ToString() -FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia: Void .ctor(FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewInterface(FSharp.Compiler.Syntax.SynType, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynMemberDefn]], FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewLetBindings(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynBinding], Boolean, Boolean, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewMember(FSharp.Compiler.Syntax.SynBinding, FSharp.Compiler.Text.Range) @@ -10202,6 +10186,10 @@ FSharp.Compiler.SyntaxTrivia.SynExprAnonRecdTrivia: FSharp.Compiler.Text.Range O FSharp.Compiler.SyntaxTrivia.SynExprAnonRecdTrivia: FSharp.Compiler.Text.Range get_OpeningBraceRange() FSharp.Compiler.SyntaxTrivia.SynExprAnonRecdTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynExprAnonRecdTrivia: Void .ctor(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia: FSharp.Compiler.Text.Range DoBangKeyword +FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia: FSharp.Compiler.Text.Range get_DoBangKeyword() +FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia: System.String ToString() +FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia: Void .ctor(FSharp.Compiler.Text.Range) FSharp.Compiler.SyntaxTrivia.SynExprDotLambdaTrivia: FSharp.Compiler.Text.Range DotRange FSharp.Compiler.SyntaxTrivia.SynExprDotLambdaTrivia: FSharp.Compiler.Text.Range UnderscoreRange FSharp.Compiler.SyntaxTrivia.SynExprDotLambdaTrivia: FSharp.Compiler.Text.Range get_DotRange() @@ -10228,19 +10216,19 @@ FSharp.Compiler.SyntaxTrivia.SynExprLambdaTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynExprLambdaTrivia: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range]) FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia Zero FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia get_Zero() +FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: FSharp.Compiler.Text.Range LetOrUseBangKeyword +FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: FSharp.Compiler.Text.Range get_LetOrUseBangKeyword() FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] EqualsRange FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_EqualsRange() FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: System.String ToString() -FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: FSharp.Compiler.Text.Range LetOrUseBangKeyword -FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: FSharp.Compiler.Text.Range get_LetOrUseBangKeyword() FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: Void .ctor(FSharp.Compiler.Text.Range, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range]) FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia Zero FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia get_Zero() +FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: FSharp.Compiler.Text.Range LetOrUseKeyword +FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: FSharp.Compiler.Text.Range get_LetOrUseKeyword() FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] InKeyword FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_InKeyword() FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: System.String ToString() -FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: FSharp.Compiler.Text.Range LetOrUseKeyword -FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: FSharp.Compiler.Text.Range get_LetOrUseKeyword() FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: Void .ctor(FSharp.Compiler.Text.Range, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range]) FSharp.Compiler.SyntaxTrivia.SynExprMatchBangTrivia: FSharp.Compiler.Text.Range MatchBangKeyword FSharp.Compiler.SyntaxTrivia.SynExprMatchBangTrivia: FSharp.Compiler.Text.Range WithKeyword @@ -10276,6 +10264,16 @@ FSharp.Compiler.SyntaxTrivia.SynExprTryWithTrivia: FSharp.Compiler.Text.Range ge FSharp.Compiler.SyntaxTrivia.SynExprTryWithTrivia: FSharp.Compiler.Text.Range get_WithToEndRange() FSharp.Compiler.SyntaxTrivia.SynExprTryWithTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynExprTryWithTrivia: Void .ctor(FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia: FSharp.Compiler.Text.Range YieldOrReturnFromKeyword +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia: FSharp.Compiler.Text.Range get_YieldOrReturnFromKeyword() +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia: System.String ToString() +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia: Void .ctor(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia Zero +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia get_Zero() +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: FSharp.Compiler.Text.Range YieldOrReturnKeyword +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: FSharp.Compiler.Text.Range get_YieldOrReturnKeyword() +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: System.String ToString() +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: Void .ctor(FSharp.Compiler.Text.Range) FSharp.Compiler.SyntaxTrivia.SynFieldTrivia: FSharp.Compiler.SyntaxTrivia.SynFieldTrivia Zero FSharp.Compiler.SyntaxTrivia.SynFieldTrivia: FSharp.Compiler.SyntaxTrivia.SynFieldTrivia get_Zero() FSharp.Compiler.SyntaxTrivia.SynFieldTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword] LeadingKeyword @@ -10545,6 +10543,10 @@ FSharp.Compiler.SyntaxTrivia.SynMemberDefnImplicitCtorTrivia: Microsoft.FSharp.C FSharp.Compiler.SyntaxTrivia.SynMemberDefnImplicitCtorTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_AsKeyword() FSharp.Compiler.SyntaxTrivia.SynMemberDefnImplicitCtorTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynMemberDefnImplicitCtorTrivia: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range]) +FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia: FSharp.Compiler.Text.Range InheritKeyword +FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia: FSharp.Compiler.Text.Range get_InheritKeyword() +FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia: System.String ToString() +FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia: Void .ctor(FSharp.Compiler.Text.Range) FSharp.Compiler.SyntaxTrivia.SynMemberGetSetTrivia: FSharp.Compiler.Text.Range WithKeyword FSharp.Compiler.SyntaxTrivia.SynMemberGetSetTrivia: FSharp.Compiler.Text.Range get_WithKeyword() FSharp.Compiler.SyntaxTrivia.SynMemberGetSetTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] AndKeyword diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index 5f4436a79f2..58788fc8fe0 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -6896,6 +6896,8 @@ FSharp.Compiler.Syntax.SynExpr+Do: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynExpr+Do: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynExpr+DoBang: FSharp.Compiler.Syntax.SynExpr expr FSharp.Compiler.Syntax.SynExpr+DoBang: FSharp.Compiler.Syntax.SynExpr get_expr() +FSharp.Compiler.Syntax.SynExpr+DoBang: FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia get_trivia() +FSharp.Compiler.Syntax.SynExpr+DoBang: FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia trivia FSharp.Compiler.Syntax.SynExpr+DoBang: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynExpr+DoBang: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynExpr+DotGet: FSharp.Compiler.Syntax.SynExpr expr @@ -7442,12 +7444,16 @@ FSharp.Compiler.Syntax.SynExpr+WhileBang: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynExpr+WhileBang: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: FSharp.Compiler.Syntax.SynExpr expr FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: FSharp.Compiler.Syntax.SynExpr get_expr() +FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia get_trivia() +FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia trivia FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: System.Tuple`2[System.Boolean,System.Boolean] flags FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: System.Tuple`2[System.Boolean,System.Boolean] get_flags() FSharp.Compiler.Syntax.SynExpr+YieldOrReturnFrom: FSharp.Compiler.Syntax.SynExpr expr FSharp.Compiler.Syntax.SynExpr+YieldOrReturnFrom: FSharp.Compiler.Syntax.SynExpr get_expr() +FSharp.Compiler.Syntax.SynExpr+YieldOrReturnFrom: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia get_trivia() +FSharp.Compiler.Syntax.SynExpr+YieldOrReturnFrom: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia trivia FSharp.Compiler.Syntax.SynExpr+YieldOrReturnFrom: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynExpr+YieldOrReturnFrom: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynExpr+YieldOrReturnFrom: System.Tuple`2[System.Boolean,System.Boolean] flags @@ -7606,13 +7612,7 @@ FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewConst(FSharp.C FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewDebugPoint(FSharp.Compiler.Syntax.DebugPointAtLeafExpr, Boolean, FSharp.Compiler.Syntax.SynExpr) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewDiscardAfterMissingQualificationAfterDot(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewDo(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range) -FSharp.Compiler.Syntax.SynExpr+DoBang: FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia get_trivia() -FSharp.Compiler.Syntax.SynExpr+DoBang: FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia trivia FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewDoBang(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia) -FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia: FSharp.Compiler.Text.Range DoBangKeyword -FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia: FSharp.Compiler.Text.Range get_DoBangKeyword() -FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia: System.String ToString() -FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia: Void .ctor(FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewDotGet(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.SynLongIdent, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewDotIndexedGet(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewDotIndexedSet(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) @@ -7668,22 +7668,8 @@ FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTyped(FSharp.C FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewUpcast(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewWhile(FSharp.Compiler.Syntax.DebugPointAtWhile, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewWhileBang(FSharp.Compiler.Syntax.DebugPointAtWhile, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range) -FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia get_trivia() -FSharp.Compiler.Syntax.SynExpr+YieldOrReturn: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia trivia -FSharp.Compiler.Syntax.SynExpr+YieldOrReturnFrom: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia get_trivia() -FSharp.Compiler.Syntax.SynExpr+YieldOrReturnFrom: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia trivia FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewYieldOrReturn(System.Tuple`2[System.Boolean,System.Boolean], FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewYieldOrReturnFrom(System.Tuple`2[System.Boolean,System.Boolean], FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia) -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia: FSharp.Compiler.Text.Range YieldOrReturnFromKeyword -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia: FSharp.Compiler.Text.Range get_YieldOrReturnFromKeyword() -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia: System.String ToString() -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia: Void .ctor(FSharp.Compiler.Text.Range) -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia Zero -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia get_Zero() -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: FSharp.Compiler.Text.Range YieldOrReturnKeyword -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: FSharp.Compiler.Text.Range get_YieldOrReturnKeyword() -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: System.String ToString() -FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: Void .ctor(FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr+AddressOf FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr+AnonRecd FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr+App @@ -7895,6 +7881,8 @@ FSharp.Compiler.Syntax.SynLongIdent: Microsoft.FSharp.Collections.FSharpList`1[M FSharp.Compiler.Syntax.SynLongIdent: System.String ToString() FSharp.Compiler.Syntax.SynLongIdentHelpers: FSharp.Compiler.Syntax.SynLongIdent LongIdentWithDots(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range]) FSharp.Compiler.Syntax.SynLongIdentHelpers: System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident],Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range]] |LongIdentWithDots|(FSharp.Compiler.Syntax.SynLongIdent) +FSharp.Compiler.Syntax.SynMatchClause: Boolean IsTrueMatchClause +FSharp.Compiler.Syntax.SynMatchClause: Boolean get_IsTrueMatchClause() FSharp.Compiler.Syntax.SynMatchClause: FSharp.Compiler.Syntax.DebugPointAtTarget debugPoint FSharp.Compiler.Syntax.SynMatchClause: FSharp.Compiler.Syntax.DebugPointAtTarget get_debugPoint() FSharp.Compiler.Syntax.SynMatchClause: FSharp.Compiler.Syntax.SynExpr get_resultExpr() @@ -8066,16 +8054,20 @@ FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.Syntax.Syn FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.Syntax.SynExpr inheritArgs FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.Syntax.SynType get_inheritType() FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.Syntax.SynType inheritType +FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia get_trivia() +FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia trivia FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident] get_inheritAlias() FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident] inheritAlias -FSharp.Compiler.Syntax.SynMemberDefn+Inherit: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynType] baseType -FSharp.Compiler.Syntax.SynMemberDefn+Inherit: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynType] get_baseType() +FSharp.Compiler.Syntax.SynMemberDefn+Inherit: FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia get_trivia() +FSharp.Compiler.Syntax.SynMemberDefn+Inherit: FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia trivia FSharp.Compiler.Syntax.SynMemberDefn+Inherit: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynMemberDefn+Inherit: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynMemberDefn+Inherit: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident] asIdent FSharp.Compiler.Syntax.SynMemberDefn+Inherit: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident] get_asIdent() +FSharp.Compiler.Syntax.SynMemberDefn+Inherit: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynType] baseType +FSharp.Compiler.Syntax.SynMemberDefn+Inherit: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynType] get_baseType() FSharp.Compiler.Syntax.SynMemberDefn+Interface: FSharp.Compiler.Syntax.SynType get_interfaceType() FSharp.Compiler.Syntax.SynMemberDefn+Interface: FSharp.Compiler.Syntax.SynType interfaceType FSharp.Compiler.Syntax.SynMemberDefn+Interface: FSharp.Compiler.Text.Range get_range() @@ -8150,16 +8142,8 @@ FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewAb FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewAutoProperty(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], Boolean, FSharp.Compiler.Syntax.Ident, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Syntax.SynMemberKind, FSharp.Compiler.Syntax.SynMemberFlags, FSharp.Compiler.Syntax.SynMemberFlags, FSharp.Compiler.Xml.PreXmlDoc, FSharp.Compiler.Syntax.SynValSigAccess, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynMemberDefnAutoPropertyTrivia) FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewGetSetMember(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynBinding], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynBinding], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynMemberGetSetTrivia) FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewImplicitCtor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], FSharp.Compiler.Syntax.SynPat, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident], FSharp.Compiler.Xml.PreXmlDoc, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynMemberDefnImplicitCtorTrivia) -FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia get_trivia() -FSharp.Compiler.Syntax.SynMemberDefn+ImplicitInherit: FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia trivia FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewImplicitInherit(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynExpr, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia) -FSharp.Compiler.Syntax.SynMemberDefn+Inherit: FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia get_trivia() -FSharp.Compiler.Syntax.SynMemberDefn+Inherit: FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia trivia FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewInherit(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynType], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia) -FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia: FSharp.Compiler.Text.Range InheritKeyword -FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia: FSharp.Compiler.Text.Range get_InheritKeyword() -FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia: System.String ToString() -FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia: Void .ctor(FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewInterface(FSharp.Compiler.Syntax.SynType, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynMemberDefn]], FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewLetBindings(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynBinding], Boolean, Boolean, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewMember(FSharp.Compiler.Syntax.SynBinding, FSharp.Compiler.Text.Range) @@ -10202,6 +10186,10 @@ FSharp.Compiler.SyntaxTrivia.SynExprAnonRecdTrivia: FSharp.Compiler.Text.Range O FSharp.Compiler.SyntaxTrivia.SynExprAnonRecdTrivia: FSharp.Compiler.Text.Range get_OpeningBraceRange() FSharp.Compiler.SyntaxTrivia.SynExprAnonRecdTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynExprAnonRecdTrivia: Void .ctor(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia: FSharp.Compiler.Text.Range DoBangKeyword +FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia: FSharp.Compiler.Text.Range get_DoBangKeyword() +FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia: System.String ToString() +FSharp.Compiler.SyntaxTrivia.SynExprDoBangTrivia: Void .ctor(FSharp.Compiler.Text.Range) FSharp.Compiler.SyntaxTrivia.SynExprDotLambdaTrivia: FSharp.Compiler.Text.Range DotRange FSharp.Compiler.SyntaxTrivia.SynExprDotLambdaTrivia: FSharp.Compiler.Text.Range UnderscoreRange FSharp.Compiler.SyntaxTrivia.SynExprDotLambdaTrivia: FSharp.Compiler.Text.Range get_DotRange() @@ -10228,19 +10216,19 @@ FSharp.Compiler.SyntaxTrivia.SynExprLambdaTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynExprLambdaTrivia: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range]) FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia Zero FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia get_Zero() +FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: FSharp.Compiler.Text.Range LetOrUseBangKeyword +FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: FSharp.Compiler.Text.Range get_LetOrUseBangKeyword() FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] EqualsRange FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_EqualsRange() FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: System.String ToString() -FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: FSharp.Compiler.Text.Range LetOrUseBangKeyword -FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: FSharp.Compiler.Text.Range get_LetOrUseBangKeyword() FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseBangTrivia: Void .ctor(FSharp.Compiler.Text.Range, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range]) FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia Zero FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia get_Zero() +FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: FSharp.Compiler.Text.Range LetOrUseKeyword +FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: FSharp.Compiler.Text.Range get_LetOrUseKeyword() FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] InKeyword FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_InKeyword() FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: System.String ToString() -FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: FSharp.Compiler.Text.Range LetOrUseKeyword -FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: FSharp.Compiler.Text.Range get_LetOrUseKeyword() FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia: Void .ctor(FSharp.Compiler.Text.Range, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range]) FSharp.Compiler.SyntaxTrivia.SynExprMatchBangTrivia: FSharp.Compiler.Text.Range MatchBangKeyword FSharp.Compiler.SyntaxTrivia.SynExprMatchBangTrivia: FSharp.Compiler.Text.Range WithKeyword @@ -10276,6 +10264,16 @@ FSharp.Compiler.SyntaxTrivia.SynExprTryWithTrivia: FSharp.Compiler.Text.Range ge FSharp.Compiler.SyntaxTrivia.SynExprTryWithTrivia: FSharp.Compiler.Text.Range get_WithToEndRange() FSharp.Compiler.SyntaxTrivia.SynExprTryWithTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynExprTryWithTrivia: Void .ctor(FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia: FSharp.Compiler.Text.Range YieldOrReturnFromKeyword +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia: FSharp.Compiler.Text.Range get_YieldOrReturnFromKeyword() +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia: System.String ToString() +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnFromTrivia: Void .ctor(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia Zero +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia get_Zero() +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: FSharp.Compiler.Text.Range YieldOrReturnKeyword +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: FSharp.Compiler.Text.Range get_YieldOrReturnKeyword() +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: System.String ToString() +FSharp.Compiler.SyntaxTrivia.SynExprYieldOrReturnTrivia: Void .ctor(FSharp.Compiler.Text.Range) FSharp.Compiler.SyntaxTrivia.SynFieldTrivia: FSharp.Compiler.SyntaxTrivia.SynFieldTrivia Zero FSharp.Compiler.SyntaxTrivia.SynFieldTrivia: FSharp.Compiler.SyntaxTrivia.SynFieldTrivia get_Zero() FSharp.Compiler.SyntaxTrivia.SynFieldTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword] LeadingKeyword @@ -10545,6 +10543,10 @@ FSharp.Compiler.SyntaxTrivia.SynMemberDefnImplicitCtorTrivia: Microsoft.FSharp.C FSharp.Compiler.SyntaxTrivia.SynMemberDefnImplicitCtorTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_AsKeyword() FSharp.Compiler.SyntaxTrivia.SynMemberDefnImplicitCtorTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynMemberDefnImplicitCtorTrivia: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range]) +FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia: FSharp.Compiler.Text.Range InheritKeyword +FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia: FSharp.Compiler.Text.Range get_InheritKeyword() +FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia: System.String ToString() +FSharp.Compiler.SyntaxTrivia.SynMemberDefnInheritTrivia: Void .ctor(FSharp.Compiler.Text.Range) FSharp.Compiler.SyntaxTrivia.SynMemberGetSetTrivia: FSharp.Compiler.Text.Range WithKeyword FSharp.Compiler.SyntaxTrivia.SynMemberGetSetTrivia: FSharp.Compiler.Text.Range get_WithKeyword() FSharp.Compiler.SyntaxTrivia.SynMemberGetSetTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] AndKeyword diff --git a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/UppercaseIdentifier04.fs b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/UppercaseIdentifier04.fs index ca2c823d157474ea878b119f82b8252581335410..de1f4a7ecdce806a86a29b19a0755f8e805aeb06 100644 GIT binary patch delta 50 zcmZ3*v5I4Z5)-Q Date: Mon, 4 Nov 2024 12:08:32 +0000 Subject: [PATCH 49/49] Add xml comments --- src/Compiler/Checking/Expressions/CheckExpressions.fsi | 1 + src/Compiler/SyntaxTree/SyntaxTree.fsi | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fsi b/src/Compiler/Checking/Expressions/CheckExpressions.fsi index c5777bf7133..0e4e17a8f83 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fsi +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fsi @@ -351,6 +351,7 @@ type TcCanFail = | IgnoreAllErrors | ReportAllErrors +/// Represents a pattern that is used in a true match clause e.g. | pat -> expr [] [] type TcTrueMatchClause = diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index 494e86bbd22..654a3971175 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -1177,6 +1177,7 @@ type SynMatchClause = /// Gets the syntax range of part of this construct member RangeOfGuardAndRhs: range + /// Is a pattern used in a true match clause e.g. | pat -> expr member IsTrueMatchClause: bool /// Gets the syntax range of this construct