diff --git a/src/fsharp/CheckExpressions.fs b/src/fsharp/CheckExpressions.fs index 423e26a9894..b30ae9cd30c 100644 --- a/src/fsharp/CheckExpressions.fs +++ b/src/fsharp/CheckExpressions.fs @@ -9755,6 +9755,9 @@ and TcLetBinding cenv isUse env containerInfo declKind tpenv (synBinds, synBinds | _ when inlineFlag.MustInline -> error(Error(FSComp.SR.tcInvalidInlineSpecification(), m)) + | TPat_query _ when HasFSharpAttribute cenv.g cenv.g.attrib_LiteralAttribute attrs -> + error(Error(FSComp.SR.tcLiteralAttributeCannotUseActivePattern(), m)) + | _ -> let tmp, _ = mkCompGenLocal m "patternInput" (generalizedTypars +-> tauTy) diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt index 828dda79289..35001aedfed 100644 --- a/src/fsharp/FSComp.txt +++ b/src/fsharp/FSComp.txt @@ -1552,3 +1552,4 @@ forFormatInvalidForInterpolated4,"Interpolated strings used as type IFormattable 3390,xmlDocDuplicateParameter,"This XML comment is invalid: multiple documentation entries for parameter '%s'" 3390,xmlDocUnresolvedCrossReference,"This XML comment is invalid: unresolved cross-reference '%s'" 3390,xmlDocMissingParameter,"This XML comment is incomplete: no documentation for parameter '%s'" +3391,tcLiteralAttributeCannotUseActivePattern,"A [] declaration cannot use an active pattern for its identifier" \ No newline at end of file diff --git a/src/fsharp/xlf/FSComp.txt.cs.xlf b/src/fsharp/xlf/FSComp.txt.cs.xlf index 9a39a4c95da..44619c85087 100644 --- a/src/fsharp/xlf/FSComp.txt.cs.xlf +++ b/src/fsharp/xlf/FSComp.txt.cs.xlf @@ -367,6 +367,11 @@ use! se nedá kombinovat s and!. + + A [<Literal>] declaration cannot use an active pattern for its identifier + A [<Literal>] declaration cannot use an active pattern for its identifier + + Cannot assign a value to another value marked literal Hodnota se nedá přiřadit k jiné hodnotě, která je označená jako literál. diff --git a/src/fsharp/xlf/FSComp.txt.de.xlf b/src/fsharp/xlf/FSComp.txt.de.xlf index 7f61d7dc8c9..3f079a1f81a 100644 --- a/src/fsharp/xlf/FSComp.txt.de.xlf +++ b/src/fsharp/xlf/FSComp.txt.de.xlf @@ -367,6 +367,11 @@ "use!" darf nicht mit "and!" kombiniert werden. + + A [<Literal>] declaration cannot use an active pattern for its identifier + A [<Literal>] declaration cannot use an active pattern for its identifier + + Cannot assign a value to another value marked literal Ein Wert kann keinem anderen als Literal markierten Wert zugewiesen werden. diff --git a/src/fsharp/xlf/FSComp.txt.es.xlf b/src/fsharp/xlf/FSComp.txt.es.xlf index 5327a952b1a..0d7b149e520 100644 --- a/src/fsharp/xlf/FSComp.txt.es.xlf +++ b/src/fsharp/xlf/FSComp.txt.es.xlf @@ -362,6 +362,11 @@ No se puede combinar use! con and! + + A [<Literal>] declaration cannot use an active pattern for its identifier + A [<Literal>] declaration cannot use an active pattern for its identifier + + Cannot assign a value to another value marked literal No se puede asignar un valor a otro marcado como literal diff --git a/src/fsharp/xlf/FSComp.txt.fr.xlf b/src/fsharp/xlf/FSComp.txt.fr.xlf index 5adced0a990..08c7d6e91bc 100644 --- a/src/fsharp/xlf/FSComp.txt.fr.xlf +++ b/src/fsharp/xlf/FSComp.txt.fr.xlf @@ -367,6 +367,11 @@ use! ne peut pas être combiné avec and! + + A [<Literal>] declaration cannot use an active pattern for its identifier + A [<Literal>] declaration cannot use an active pattern for its identifier + + Cannot assign a value to another value marked literal Impossible d'affecter une valeur à une autre valeur marquée comme littérale diff --git a/src/fsharp/xlf/FSComp.txt.it.xlf b/src/fsharp/xlf/FSComp.txt.it.xlf index 3d038694419..9ac812b241a 100644 --- a/src/fsharp/xlf/FSComp.txt.it.xlf +++ b/src/fsharp/xlf/FSComp.txt.it.xlf @@ -367,6 +367,11 @@ Non è possibile combinare use! con and! + + A [<Literal>] declaration cannot use an active pattern for its identifier + A [<Literal>] declaration cannot use an active pattern for its identifier + + Cannot assign a value to another value marked literal Non è possibile assegnare un valore a un altro valore contrassegnato come letterale diff --git a/src/fsharp/xlf/FSComp.txt.ja.xlf b/src/fsharp/xlf/FSComp.txt.ja.xlf index c6de2f62afe..5a62f6c6eaf 100644 --- a/src/fsharp/xlf/FSComp.txt.ja.xlf +++ b/src/fsharp/xlf/FSComp.txt.ja.xlf @@ -367,6 +367,11 @@ use! を and! と組み合わせて使用することはできません + + A [<Literal>] declaration cannot use an active pattern for its identifier + A [<Literal>] declaration cannot use an active pattern for its identifier + + Cannot assign a value to another value marked literal リテラルとしてマークされた別の値に値を割り当てることはできません diff --git a/src/fsharp/xlf/FSComp.txt.ko.xlf b/src/fsharp/xlf/FSComp.txt.ko.xlf index 94811a157c8..35dddbb2dd6 100644 --- a/src/fsharp/xlf/FSComp.txt.ko.xlf +++ b/src/fsharp/xlf/FSComp.txt.ko.xlf @@ -367,6 +367,11 @@ use!는 and!와 함께 사용할 수 없습니다. + + A [<Literal>] declaration cannot use an active pattern for its identifier + A [<Literal>] declaration cannot use an active pattern for its identifier + + Cannot assign a value to another value marked literal 리터럴로 표시된 다른 값에 값을 할당할 수 없습니다. diff --git a/src/fsharp/xlf/FSComp.txt.pl.xlf b/src/fsharp/xlf/FSComp.txt.pl.xlf index 80d8dbcb56a..ca4efcfb381 100644 --- a/src/fsharp/xlf/FSComp.txt.pl.xlf +++ b/src/fsharp/xlf/FSComp.txt.pl.xlf @@ -367,6 +367,11 @@ Elementu use! nie można łączyć z elementem and! + + A [<Literal>] declaration cannot use an active pattern for its identifier + A [<Literal>] declaration cannot use an active pattern for its identifier + + Cannot assign a value to another value marked literal Nie można przypisać wartości do innej wartości oznaczonej jako literał diff --git a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf index c6a77375b26..49eff2cb7df 100644 --- a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf +++ b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf @@ -367,6 +367,11 @@ use! não pode ser combinado com and! + + A [<Literal>] declaration cannot use an active pattern for its identifier + A [<Literal>] declaration cannot use an active pattern for its identifier + + Cannot assign a value to another value marked literal Não é possível atribuir um valor a outro valor marcado como literal diff --git a/src/fsharp/xlf/FSComp.txt.ru.xlf b/src/fsharp/xlf/FSComp.txt.ru.xlf index 3ccd9d1a9e6..bb1d6cc81fe 100644 --- a/src/fsharp/xlf/FSComp.txt.ru.xlf +++ b/src/fsharp/xlf/FSComp.txt.ru.xlf @@ -367,6 +367,11 @@ use! запрещено сочетать с and! + + A [<Literal>] declaration cannot use an active pattern for its identifier + A [<Literal>] declaration cannot use an active pattern for its identifier + + Cannot assign a value to another value marked literal Невозможно присвоить значение другому значению, помеченному как литерал diff --git a/src/fsharp/xlf/FSComp.txt.tr.xlf b/src/fsharp/xlf/FSComp.txt.tr.xlf index 6f29c319df0..e07977495ac 100644 --- a/src/fsharp/xlf/FSComp.txt.tr.xlf +++ b/src/fsharp/xlf/FSComp.txt.tr.xlf @@ -367,6 +367,11 @@ use!, and! ile birleştirilemez + + A [<Literal>] declaration cannot use an active pattern for its identifier + A [<Literal>] declaration cannot use an active pattern for its identifier + + Cannot assign a value to another value marked literal Sabit değer olarak işaretlenen bir değere başka bir değer atanamaz diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf index daf850cea0e..877a73a789d 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf @@ -367,6 +367,11 @@ use! 不得与 and! 结合使用 + + A [<Literal>] declaration cannot use an active pattern for its identifier + A [<Literal>] declaration cannot use an active pattern for its identifier + + Cannot assign a value to another value marked literal 无法将值分配给标记为文本的其他值 diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf index a466dbe4ee2..cc522863041 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf @@ -367,6 +367,11 @@ use! 不可與 and! 合併 + + A [<Literal>] declaration cannot use an active pattern for its identifier + A [<Literal>] declaration cannot use an active pattern for its identifier + + Cannot assign a value to another value marked literal 無法將值指派給標記為常值的其他值 diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidLiteralTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidLiteralTests.fs new file mode 100644 index 00000000000..f3d62e97410 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidLiteralTests.fs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.ComponentTests.ErrorMessages + +open Xunit +open FSharp.Test.Utilities.Compiler + +module ``Invalid literals`` = + + [] + let ``Using Active Pattern``() = + FSharp """ +let (|A|) x = x + 1 +let [] (A x) = 1 + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 3391, Line 3, Col 17, Line 3, Col 22, "A [] declaration cannot use an active pattern for its identifier") diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index cca3702159f..248e415ce5d 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -31,7 +31,8 @@ - + +