diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index a501f74edc0..8a0a5d91a4d 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -1665,7 +1665,9 @@ let private ReportErrorOnStaticClass (synMembers: SynMemberDefn list) = | SynMemberDefn.Member(SynBinding(valData = SynValData(memberFlags = Some memberFlags)), m) when memberFlags.MemberKind = SynMemberKind.Constructor -> errorR(Error(FSComp.SR.chkAdditionalConstructorOnStaticClasses(), m)) | SynMemberDefn.Member(SynBinding(valData = SynValData(memberFlags = Some memberFlags)), m) when memberFlags.MemberKind = SynMemberKind.Member && memberFlags.IsInstance -> - errorR(Error(FSComp.SR.chkInstanceMemberOnStaticClasses(), m)); + errorR(Error(FSComp.SR.chkInstanceMemberOnStaticClasses(), m)) + | SynMemberDefn.LetBindings(isStatic = false; range = range) -> + errorR(Error(FSComp.SR.chkInstanceLetBindingOnStaticClasses(), range)) | _ -> () /// Check and generalize the interface implementations, members, 'let' definitions in a mutually recursive group of definitions. diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 03ab28bfc97..542f45f7fe1 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1669,3 +1669,4 @@ featureEscapeBracesInFormattableString,"Escapes curly braces before calling Form 3552,chkConstructorWithArgumentsOnStaticClasses,"If a type uses both [] and [] attributes, it means it is static. Constructor with arguments is not allowed." 3553,chkAdditionalConstructorOnStaticClasses,"If a type uses both [] and [] attributes, it means it is static. Additional constructor is not allowed." 3554,chkInstanceMemberOnStaticClasses,"If a type uses both [] and [] attributes, it means it is static. Instance members are not allowed." +3555,chkInstanceLetBindingOnStaticClasses,"If a type uses both [] and [] attributes, it means it is static. Instance let bindings are not allowed." \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index e2477998461..ba069c51771 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -72,6 +72,11 @@ Použití incr z knihovny F# je zastaralé. Více informací: https://aka.ms/fsharp-refcell-ops. Změňte prosím například incr cell na cell.Value <- cell.Value + 1. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index a3d68b6bde1..89ea05c22db 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -72,6 +72,11 @@ Die Verwendung von "incr" aus der F#-Bibliothek ist veraltet. Siehe https://aka.ms/fsharp-refcell-ops. Ändern Sie z. B. "incr cell" in "cell.Value <- cell.Value + 1". + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 3dcd9a96d4e..9c1f8f44de4 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -72,6 +72,11 @@ El uso de "incr" de la biblioteca de F# está en desuso. Vea https://aka.ms/fsharp-refcell-ops. Por ejemplo, cambie "incr cell" a "cell.Value <- cell.Value + 1". + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 06bdee98069..41d93aec3b6 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -72,6 +72,11 @@ L’utilisation de « incr » à partir de la bibliothèque F# est déconseillée. Voir https://aka.ms/fsharp-refcell-ops. Par exemple, veuillez remplacer « incr cell » par « cell.Value <- cell.Value + 1 ». + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 6da5546c729..310d3cfed2b 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -72,6 +72,11 @@ L'uso di 'incr' dalla libreria F # è deprecato. Vedere https://aka.ms/fsharp-refcell-ops. Ad esempio, modificare 'incr cell' in 'cell.Value <- cell.Value + 1'. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 2a493955d6f..037d187f45f 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -72,6 +72,11 @@ F# ライブラリからの 'incr' の使用は非推奨です。https://aka.ms/fsharp-refcell-ops を参照してください。たとえば、'incr cell' を 'cell.Value <- cell.Value +1' に変更してください。 + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index ef266833a3d..84b210a4443 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -72,6 +72,11 @@ F# 라이브러리의 'incr' 사용은 더 이상 사용되지 않습니다. https://aka.ms/fsharp-refcell-ops를 참조하세요. 예를 들어 'incr cell'을 'cell.Value <- cell.Value + 1'로 변경하세요. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 9ac9aab7e10..2922e8a570c 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -72,6 +72,11 @@ Użycie elementu „incr” z biblioteki języka F# jest przestarzałe. Sprawdź stronę https://aka.ms/fsharp-refcell-ops. Na przykład zmień wyrażenie „incr cell” na „cell.Value <- cell.Value + 1”. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 15594c8ad01..d3cab9a58e2 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -72,6 +72,11 @@ O uso de 'incr' da biblioteca F# foi preterido. Consulte https://aka.ms/fsharp-refcell-ops. Por exemplo, altere a célula 'incr cell' para 'cell.Value <- cell.Value + 1'. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 5da5e9edb15..80ab5cea029 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -72,6 +72,11 @@ Использование "incr" из библиотеки F# является нерекомендуемым. См. https://aka.ms/fsharp-refcell-ops. Например, замените "incr cell" на "cell.Value <- cell.Value + 1". + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 9cbd059ab60..2b7d71a09a0 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -72,6 +72,11 @@ F# kitaplığından gelen 'incr' kullanımı kullanım dışı. https://aka.ms/fsharp-refcell-ops’a bakın. Örneğin, lütfen 'incr cell' ifadesini 'cell.Value <- cell.Value + 1' olarak değiştirin. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index f01de0338e6..c02a539f370 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -72,6 +72,11 @@ 已弃用 F# 库中的“incr”。请参阅 https://aka.ms/fsharp-refcell-ops。 例如,请将“incr cell”更改为“cell.Value <- cell.Value + 1”。 + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 8d34c0cf216..b48c8eb8d7a 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -72,6 +72,11 @@ 透過 F# 程式庫使用 'incr' 的方式已淘汰。請參閱 https://aka.ms/fsharp-refcell-ops。舉例來說,請將 'incr cell' 變更為 'cell.Value <- cell.Value + 1'。 + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed. + + If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed. diff --git a/tests/FSharp.Compiler.ComponentTests/Language/StaticClassTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/StaticClassTests.fs index b6a2f32e2f1..f96bea3fbae 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/StaticClassTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/StaticClassTests.fs @@ -249,6 +249,108 @@ type T() = type T() = static member M() = () static member X = T.M() + """ + |> withLangVersionPreview + |> compile + |> shouldSucceed + + [] + let ``Sealed and AbstractClass on a type with static and non static let bindings in lang 70`` () = + Fsx """ +[] +type C() = + let a = 1 + static let x = 1 + """ + |> withLangVersion70 + |> compile + |> shouldSucceed + + [] + let ``Sealed and AbstractClass on a type with static and non static recursive let bindings in lang 70`` () = + Fsx """ +[] +type C() = + let rec a = 1 + static let x = 1 + """ + |> withLangVersion70 + |> compile + |> shouldSucceed + + [] + let ``Sealed and AbstractClass on a type with static let bindings in lang 70`` () = + Fsx """ +[] +type C() = + static let a = 1 + static let x = a + """ + |> withLangVersion70 + |> compile + |> shouldSucceed + + [] + let ``Sealed and AbstractClass on a type with recursive static let bindings in lang 70`` () = + Fsx """ +[] +type C() = + static let rec a = 1 + static let x = a + """ + |> withLangVersion70 + |> compile + |> shouldSucceed + + [] + let ``Sealed and AbstractClass with static and non static let bindings in lang preview`` () = + Fsx """ +[] +type C() = + let a = 1 + static let X = 1 + """ + |> withLangVersionPreview + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 3555, Line 4, Col 5, Line 4, Col 14, "If a type uses both [] and [] attributes, it means it is static. Instance let bindings are not allowed.") + ] + + [] + let ``Sealed and AbstractClass with static and non static recursive let bindings in lang preview`` () = + Fsx """ +[] +type C() = + let rec a = 1 + static let X = 1 + """ + |> withLangVersionPreview + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 3555, Line 4, Col 5, Line 4, Col 18, "If a type uses both [] and [] attributes, it means it is static. Instance let bindings are not allowed.") + ] + + [] + let ``Sealed and AbstractClass with static let bindings in lang preview`` () = + Fsx """ +[] +type C() = + static let a = 1 + static let X = a + """ + |> withLangVersionPreview + |> compile + |> shouldSucceed + + [] + let ``Sealed and AbstractClass with recursive static let bindings in lang preview`` () = + Fsx """ +[] +type C() = + static let rec a = 1 + static let X = a """ |> withLangVersionPreview |> compile