From d8226e4e56f24007094610384ba3d2e110ec82d3 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Mon, 27 Nov 2023 13:45:57 +0100 Subject: [PATCH 1/4] Make 'static meme' fail as it should --- src/Compiler/pars.fsy | 4 +- tests/service/SyntaxTreeTests.fs | 2 +- .../Member/MemberMispelledToMeme.fs | 2 + .../Member/MemberMispelledToMeme.fs.bsl | 62 +++++++++++++++++++ .../data/SyntaxTree/Member/Static 01.fs.bsl | 32 +++------- .../data/SyntaxTree/Member/Static 02.fs.bsl | 40 ++---------- 6 files changed, 82 insertions(+), 60 deletions(-) create mode 100644 tests/service/data/SyntaxTree/Member/MemberMispelledToMeme.fs create mode 100644 tests/service/data/SyntaxTree/Member/MemberMispelledToMeme.fs.bsl diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 2532bd8558d..aca41ee98ea 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -1548,9 +1548,9 @@ memberFlags: let mMember = rhs parseState 2 StaticMemberFlags, SynLeadingKeyword.StaticMember(mStatic, mMember) } - | STATIC + | STATIC recover { let mStatic = rhs parseState 1 - // todo: it should be possible to make it work better for both `abstract` and `member` in the type checker + // todo: it should be possible to make it work better for both `abstract` and `member` in the type checker StaticMemberFlags, SynLeadingKeyword.Static(mStatic) } | MEMBER diff --git a/tests/service/SyntaxTreeTests.fs b/tests/service/SyntaxTreeTests.fs index b72b20d77d9..e40c4999010 100644 --- a/tests/service/SyntaxTreeTests.fs +++ b/tests/service/SyntaxTreeTests.fs @@ -190,7 +190,7 @@ let ParseFile fileName = let equals = expected = actual let testUpdateBSLEnv = System.Environment.GetEnvironmentVariable("TEST_UPDATE_BSL") - if not (isNull testUpdateBSLEnv) && testUpdateBSLEnv.Trim() = "1" then + if not (isNull testUpdateBSLEnv) && testUpdateBSLEnv.Trim() = "1" && (not equals) then File.WriteAllText(bslPath, actual) elif not equals then File.WriteAllText(actualPath, actual) diff --git a/tests/service/data/SyntaxTree/Member/MemberMispelledToMeme.fs b/tests/service/data/SyntaxTree/Member/MemberMispelledToMeme.fs new file mode 100644 index 00000000000..3343108a07b --- /dev/null +++ b/tests/service/data/SyntaxTree/Member/MemberMispelledToMeme.fs @@ -0,0 +1,2 @@ +type Seq = + static meme average (x: int seq) = x \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/Member/MemberMispelledToMeme.fs.bsl b/tests/service/data/SyntaxTree/Member/MemberMispelledToMeme.fs.bsl new file mode 100644 index 00000000000..df1dbf35837 --- /dev/null +++ b/tests/service/data/SyntaxTree/Member/MemberMispelledToMeme.fs.bsl @@ -0,0 +1,62 @@ +ImplFile + (ParsedImplFileInput + ("/root/Member/MemberMispelledToMeme.fs", false, + QualifiedNameOfFile MemberMispelledToMeme, [], [], + [SynModuleOrNamespace + ([MemberMispelledToMeme], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [Seq], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,8)), + ObjectModel + (Unspecified, + [Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((2,3), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = false + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, Some average)]; + [SynArgInfo ([], false, Some x)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent ([meme], [], [None]), None, None, + Pats + [Named + (SynIdent (average, None), false, None, + (2,15--2,22)); + Paren + (Typed + (Named + (SynIdent (x, None), false, None, + (2,24--2,25)), + App + (LongIdent + (SynLongIdent ([seq], [], [None])), + None, + [LongIdent + (SynLongIdent ([int], [], [None]))], + [], None, true, (2,27--2,34)), + (2,24--2,34)), (2,23--2,35))], None, + (2,10--2,35)), None, Ident x, (2,10--2,35), + NoneAtInvisible, + { LeadingKeyword = Static (2,3--2,9) + InlineKeyword = None + EqualsRange = Some (2,36--2,37) }), (2,3--2,39))], + (2,3--2,39)), [], None, (1,5--2,39), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,9--1,10) + WithKeyword = None })], (1,0--2,39))], PreXmlDocEmpty, [], + None, (1,0--2,39), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(2,10)-(2,14) parse error Unexpected identifier in type definition diff --git a/tests/service/data/SyntaxTree/Member/Static 01.fs.bsl b/tests/service/data/SyntaxTree/Member/Static 01.fs.bsl index 7c47ccf95ec..f31643e8647 100644 --- a/tests/service/data/SyntaxTree/Member/Static 01.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Static 01.fs.bsl @@ -24,32 +24,20 @@ ImplFile MemberKind = Member }, SynValInfo ([[]], SynArgInfo ([], false, None)), None), - FromParseError (Wild (5,10--5,10), (5,10--5,10)), - None, - ArbitraryAfterError - ("classDefnMember1", (5,10--5,10)), (5,4--5,10), - NoneAtInvisible, + Paren (Const (Unit, (7,7--7,9)), (7,7--7,9)), None, + ArbitraryAfterError ("memberCore2", (7,9--7,9)), + (7,7--7,9), NoneAtInvisible, { LeadingKeyword = Static (5,4--5,10) InlineKeyword = None - EqualsRange = None }), (5,4--5,10)); - LetBindings - ([SynBinding - (None, Do, false, false, [], PreXmlDocEmpty, - SynValData - (None, - SynValInfo ([], SynArgInfo ([], false, None)), - None), Const (Unit, (7,4--7,9)), None, - Const (Unit, (7,7--7,9)), (7,4--7,9), NoneAtDo, - { LeadingKeyword = Do (7,4--7,6) - InlineKeyword = None - EqualsRange = None })], false, false, (7,4--7,9))], - (5,4--7,9)), [], None, (3,5--7,9), - { LeadingKeyword = Type (3,0--3,4) - EqualsRange = Some (3,7--3,8) - WithKeyword = None })], (3,0--7,9))], + EqualsRange = None }), (5,4--7,9))], (5,4--7,9)), + [], None, (3,5--7,9), { LeadingKeyword = Type (3,0--3,4) + EqualsRange = Some (3,7--3,8) + WithKeyword = None })], (3,0--7,9))], PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, (1,0--7,9), { LeadingKeyword = Module (1,0--1,6) })], (true, true), { ConditionalDirectives = [] CodeComments = [] }, set [])) -(5,11)-(7,4) parse error Incomplete structured construct at or before this point in member definition +(5,11)-(7,4) parse error Incomplete structured construct at or before this point in type definition +(8,0)-(8,0) parse error Incomplete structured construct at or before this point in member definition. Expected 'with', '=' or other token. +(8,0)-(8,0) parse error Incomplete structured construct at or before this point in definition. Expected incomplete structured construct at or before this point or other token. diff --git a/tests/service/data/SyntaxTree/Member/Static 02.fs.bsl b/tests/service/data/SyntaxTree/Member/Static 02.fs.bsl index ecf86c4e1f6..8973f05f1f1 100644 --- a/tests/service/data/SyntaxTree/Member/Static 02.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Static 02.fs.bsl @@ -61,44 +61,14 @@ ImplFile MemberKind = Member }, SynValInfo ([[]], SynArgInfo ([], false, None)), None), - FromParseError (Wild (5,16--5,16), (5,16--5,16)), - None, - ArbitraryAfterError - ("classDefnMember1", (5,16--5,16)), (5,4--5,16), - NoneAtInvisible, - { LeadingKeyword = Static (5,10--5,16) - InlineKeyword = None - EqualsRange = None }), (5,4--5,16)); - Member - (SynBinding - (None, Normal, false, false, - [{ Attributes = - [{ TypeName = SynLongIdent ([C], [], [None]) - ArgExpr = Const (Unit, (6,6--6,7)) - Target = None - AppliesToGetterAndSetter = false - Range = (6,6--6,7) }] - Range = (6,4--6,9) }], - PreXmlDoc ((6,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Member }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), LongIdent - (SynLongIdent - ([this; P3], [(6,21--6,22)], [None; None]), - None, None, Pats [], None, (6,17--6,24)), None, - Const (Int32 3, (6,27--6,28)), (6,4--6,24), + (SynLongIdent ([C], [], [None]), None, None, + Pats [], None, (6,6--6,7)), None, + Const (Int32 3, (6,27--6,28)), (5,4--6,7), NoneAtInvisible, - { LeadingKeyword = Member (6,10--6,16) + { LeadingKeyword = Static (5,10--5,16) InlineKeyword = None - EqualsRange = Some (6,25--6,26) }), (6,4--6,28))], + EqualsRange = Some (6,25--6,26) }), (5,4--6,28))], (4,4--6,28)), [], None, (3,5--6,28), { LeadingKeyword = Type (3,0--3,4) EqualsRange = Some (3,7--3,8) From 20e4de8616d88aa0bcaea03e48155c52ddfd4670 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Mon, 27 Nov 2023 16:27:19 +0100 Subject: [PATCH 2/4] New attempt --- src/Compiler/FSComp.txt | 3 +- src/Compiler/pars.fsy | 7 +++- 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 +++ .../Member/MemberMispelledToMeme.fs.bsl | 2 +- .../data/SyntaxTree/Member/Static 01.fs.bsl | 32 ++++++++++----- .../data/SyntaxTree/Member/Static 02.fs.bsl | 40 ++++++++++++++++--- 18 files changed, 130 insertions(+), 19 deletions(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 35f5dbf06f1..ea1d6e948a9 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1733,4 +1733,5 @@ featureUnmanagedConstraintCsharpInterop,"Interop between C#'s and F#'s unmanaged 3855,tcNoStaticMemberFoundForOverride,"No static abstract member was found that corresponds to this override" 3859,tcNoStaticPropertyFoundForOverride,"No static abstract property was found that corresponds to this override" 3860,chkStaticMembersOnObjectExpressions,"Object expressions cannot implement interfaces with static abstract members or declare static members." -3861,chkTailCallAttrOnNonRec,"The TailCall attribute should only be applied to recursive functions." \ No newline at end of file +3861,chkTailCallAttrOnNonRec,"The TailCall attribute should only be applied to recursive functions." +3862,parsStaticMemberImcompleteSyntax,"Incomplete static member declaration. Use the keywords 'static member' to declare a new member." \ No newline at end of file diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index aca41ee98ea..a4a77de3bf5 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -1548,9 +1548,9 @@ memberFlags: let mMember = rhs parseState 2 StaticMemberFlags, SynLeadingKeyword.StaticMember(mStatic, mMember) } - | STATIC recover + | STATIC { let mStatic = rhs parseState 1 - // todo: it should be possible to make it work better for both `abstract` and `member` in the type checker + // todo: it should be possible to make it work better for both `abstract` and `member` in the type checker StaticMemberFlags, SynLeadingKeyword.Static(mStatic) } | MEMBER @@ -1988,6 +1988,9 @@ classDefnMember: if Option.isSome $2 then errorR (Error (FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier (), rhs parseState 2)) let flags = $3 + match flags with + | _, SynLeadingKeyword.Static(mStatic) -> errorR (Error (FSComp.SR.parsStaticMemberImcompleteSyntax (), mStatic)) + | _ -> () $4 $2 flags $1 rangeStart } | opt_attributes opt_access memberFlags recover diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index a9f06c45ead..5cb657516a3 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -942,6 +942,11 @@ Tento přístup člena je nejednoznačný. Při vytváření objektu použijte závorky, např. (new SomeType(args)).MemberName' + + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + + Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif <expr> then <expr>' or 'else if <expr> then <expr>'. Neočekávaný konec vstupu ve větvi else if nebo elif podmíněného výrazu Očekávalo se elif <expr> then <expr> nebo else if <expr> then <expr>. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index a94265a5913..a4116c8f365 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -942,6 +942,11 @@ Dieser Memberzugriff ist mehrdeutig. Setzen Sie Klammern um die Objekterstellung, z. B. "(new SomeType(args)). MemberName“ + + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + + Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif <expr> then <expr>' or 'else if <expr> then <expr>'. Unerwartetes Ende der Eingabe im "else if"- oder "elif"-Branch des bedingten Ausdrucks. Erwartet wird: "elif <expr> then <expr>" oder "else if <expr> then <expr>". diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 9be392ac59c..606fd0d2cc2 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -942,6 +942,11 @@ Este acceso de miembro es ambiguo. Use paréntesis alrededor de la creación del objeto, por ejemplo, '(nuevo AlgúnTipo(args)).NombreMiembro' + + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + + Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif <expr> then <expr>' or 'else if <expr> then <expr>'. Fin de entrada inesperado en la rama "else if" o "elif" de una expresión condicional. Se espera "elif <expr> then <expr>" o "else if <expr> then <expr>". diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 9c511cc41e9..9e80bb769a5 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -942,6 +942,11 @@ L’accès à ce membre est ambigu. Utilisez des parenthèses autour de la création de l’objet, par exemple' (New SomeType (args)). MemberName + + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + + Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif <expr> then <expr>' or 'else if <expr> then <expr>'. Fin d'entrée inattendue dans la branche 'else if' ou 'elif' de l'expression conditionnelle. Attendu 'elif <expr> then <expr>' ou 'else if <expr> then <expr>'. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 000c2b00a51..a2ba3df83d4 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -942,6 +942,11 @@ L'accesso ai membri è ambiguo. Utilizzare le parentesi intorno alla creazione oggetto, ad esempio “(New SomeType (args)). MemberName” + + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + + Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif <expr> then <expr>' or 'else if <expr> then <expr>'. Fine dell'input imprevista nel ramo 'else if' o 'elif' dell'espressione condizionale. È previsto 'elif <expr> then <expr>' o 'else if <expr> then <expr>'. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 56d4e17511a..22be7596752 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -942,6 +942,11 @@ このメンバーへのアクセスはあいまいです。オブジェクト作成の前後にはかっこを使用してください。例: '(new SomeType(args)).MemberName' + + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + + Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif <expr> then <expr>' or 'else if <expr> then <expr>'. 条件式の 'else if' または 'elif' 分岐の入力が予期しない形式で終了しています。'elif <expr> then <expr>' または 'else if <expr> then <expr>' が必要でした。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 6a00f11b763..b929ff1f795 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -942,6 +942,11 @@ 이 구성원 액세스가 모호합니다. 개체 생성 주위에 괄호를 사용하세요. 예: '(새로운 SomeType(인수)).MemberName' + + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + + Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif <expr> then <expr>' or 'else if <expr> then <expr>'. 조건식의 'else if' 또는 'elif' 분기에서 입력이 예기치 않게 끝났습니다. 'elif <expr> then <expr>' 또는 'else if <expr> then <expr>'이 필요합니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index d8c2d0d5361..c52324b5f02 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -942,6 +942,11 @@ Dostęp tego elementu członkowskiego jest niejednoznaczny. W celu utworzenia obiektu użyj nawiasów, na przykład „(nowy SomeType(args)).MemberName” + + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + + Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif <expr> then <expr>' or 'else if <expr> then <expr>'. Nieoczekiwane zakończenie danych wejściowych w gałęzi „else” wyrażenia warunkowego. Oczekiwano konstrukcji „elif <expr> then <expr>” lub „else if <expr> then <expr>”. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 456e9026a53..11ac0bd0918 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -942,6 +942,11 @@ Este acesso de membro é ambíguo. Use parênteses em torno da criação do objeto, por exemplo, '(new SomeType(args)).MemberName''. + + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + + Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif <expr> then <expr>' or 'else if <expr> then <expr>'. Fim inesperado de entrada no branch 'else if' ou 'elif' da expressão condicional. Esperado 'elif <expr> em seguida, <expr>' ou 'else if <expr> then <expr>'. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 8794eb00a3e..b99f9bafaf9 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -942,6 +942,11 @@ Неоднозначный доступ к этому элементу. Заключите операцию создания объекта в круглые скобки, например (new Объект(аргументы)).Элемент + + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + + Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif <expr> then <expr>' or 'else if <expr> then <expr>'. Неожиданное завершение входных данных ветви "else if" или "elif" условного выражения. Ожидается "elif <expr> then <expr> " или "else if <expr> then <expr>" diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index f783780369c..aedd526d891 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -942,6 +942,11 @@ Bu üye erişimi belirsiz. Lütfen nesne oluşturma etrafında parantez kullanın, örneğin '(yeni SomeType (args)).MemberName’ + + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + + Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif <expr> then <expr>' or 'else if <expr> then <expr>'. Koşullu ifadenin 'else if' veya 'elif' dalında beklenmeyen giriş sonu. 'elif <expr> then <expr>' veya 'else if <expr> then <expr>' bekleniyordu. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 893e35707bc..98ae2c227a2 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -942,6 +942,11 @@ 此成员访问权限不明确。请在对象创建周围使用括号,例如 “(new SomeType(args)).MemberName” + + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + + Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif <expr> then <expr>' or 'else if <expr> then <expr>'. 条件表达式的 "else if" 或 "elif" 分支中的输入意外结束。应为 "elif <expr> then <expr>" 或 "else if <expr> then <expr>"。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index a1342c08486..c73582b3725 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -942,6 +942,11 @@ 此成員存取不明確。請在物件建立前後加上括弧,例如「(new SomeType(args)).MemberName」 + + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + + Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif <expr> then <expr>' or 'else if <expr> then <expr>'. 條件運算式的 'else if' 或 'elif' 分支中出現未預期的輸入結尾。 預期為 'elif <expr> then <expr>' 或 'else if <expr> then <expr>'. diff --git a/tests/service/data/SyntaxTree/Member/MemberMispelledToMeme.fs.bsl b/tests/service/data/SyntaxTree/Member/MemberMispelledToMeme.fs.bsl index df1dbf35837..827d8d6bd79 100644 --- a/tests/service/data/SyntaxTree/Member/MemberMispelledToMeme.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/MemberMispelledToMeme.fs.bsl @@ -59,4 +59,4 @@ ImplFile { ConditionalDirectives = [] CodeComments = [] }, set [])) -(2,10)-(2,14) parse error Unexpected identifier in type definition +(2,3)-(2,9) parse error Incomplete static member declaration. Use the keywords 'static member' to declare a new member. diff --git a/tests/service/data/SyntaxTree/Member/Static 01.fs.bsl b/tests/service/data/SyntaxTree/Member/Static 01.fs.bsl index f31643e8647..7c47ccf95ec 100644 --- a/tests/service/data/SyntaxTree/Member/Static 01.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Static 01.fs.bsl @@ -24,20 +24,32 @@ ImplFile MemberKind = Member }, SynValInfo ([[]], SynArgInfo ([], false, None)), None), - Paren (Const (Unit, (7,7--7,9)), (7,7--7,9)), None, - ArbitraryAfterError ("memberCore2", (7,9--7,9)), - (7,7--7,9), NoneAtInvisible, + FromParseError (Wild (5,10--5,10), (5,10--5,10)), + None, + ArbitraryAfterError + ("classDefnMember1", (5,10--5,10)), (5,4--5,10), + NoneAtInvisible, { LeadingKeyword = Static (5,4--5,10) InlineKeyword = None - EqualsRange = None }), (5,4--7,9))], (5,4--7,9)), - [], None, (3,5--7,9), { LeadingKeyword = Type (3,0--3,4) - EqualsRange = Some (3,7--3,8) - WithKeyword = None })], (3,0--7,9))], + EqualsRange = None }), (5,4--5,10)); + LetBindings + ([SynBinding + (None, Do, false, false, [], PreXmlDocEmpty, + SynValData + (None, + SynValInfo ([], SynArgInfo ([], false, None)), + None), Const (Unit, (7,4--7,9)), None, + Const (Unit, (7,7--7,9)), (7,4--7,9), NoneAtDo, + { LeadingKeyword = Do (7,4--7,6) + InlineKeyword = None + EqualsRange = None })], false, false, (7,4--7,9))], + (5,4--7,9)), [], None, (3,5--7,9), + { LeadingKeyword = Type (3,0--3,4) + EqualsRange = Some (3,7--3,8) + WithKeyword = None })], (3,0--7,9))], PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, (1,0--7,9), { LeadingKeyword = Module (1,0--1,6) })], (true, true), { ConditionalDirectives = [] CodeComments = [] }, set [])) -(5,11)-(7,4) parse error Incomplete structured construct at or before this point in type definition -(8,0)-(8,0) parse error Incomplete structured construct at or before this point in member definition. Expected 'with', '=' or other token. -(8,0)-(8,0) parse error Incomplete structured construct at or before this point in definition. Expected incomplete structured construct at or before this point or other token. +(5,11)-(7,4) parse error Incomplete structured construct at or before this point in member definition diff --git a/tests/service/data/SyntaxTree/Member/Static 02.fs.bsl b/tests/service/data/SyntaxTree/Member/Static 02.fs.bsl index 8973f05f1f1..ecf86c4e1f6 100644 --- a/tests/service/data/SyntaxTree/Member/Static 02.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Static 02.fs.bsl @@ -61,14 +61,44 @@ ImplFile MemberKind = Member }, SynValInfo ([[]], SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent ([C], [], [None]), None, None, - Pats [], None, (6,6--6,7)), None, - Const (Int32 3, (6,27--6,28)), (5,4--6,7), + FromParseError (Wild (5,16--5,16), (5,16--5,16)), + None, + ArbitraryAfterError + ("classDefnMember1", (5,16--5,16)), (5,4--5,16), NoneAtInvisible, { LeadingKeyword = Static (5,10--5,16) InlineKeyword = None - EqualsRange = Some (6,25--6,26) }), (5,4--6,28))], + EqualsRange = None }), (5,4--5,16)); + Member + (SynBinding + (None, Normal, false, false, + [{ Attributes = + [{ TypeName = SynLongIdent ([C], [], [None]) + ArgExpr = Const (Unit, (6,6--6,7)) + Target = None + AppliesToGetterAndSetter = false + Range = (6,6--6,7) }] + Range = (6,4--6,9) }], + PreXmlDoc ((6,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([this; P3], [(6,21--6,22)], [None; None]), + None, None, Pats [], None, (6,17--6,24)), None, + Const (Int32 3, (6,27--6,28)), (6,4--6,24), + NoneAtInvisible, + { LeadingKeyword = Member (6,10--6,16) + InlineKeyword = None + EqualsRange = Some (6,25--6,26) }), (6,4--6,28))], (4,4--6,28)), [], None, (3,5--6,28), { LeadingKeyword = Type (3,0--3,4) EqualsRange = Some (3,7--3,8) From 111b00e99b0e9b2bdba5220b32f83f1ca05a28c2 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Mon, 27 Nov 2023 16:54:24 +0100 Subject: [PATCH 3/4] Change error message --- src/Compiler/FSComp.txt | 2 +- src/Compiler/xlf/FSComp.txt.cs.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.de.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.es.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.fr.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.it.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.ja.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.ko.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.pl.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.ru.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.tr.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 4 ++-- .../data/SyntaxTree/Member/MemberMispelledToMeme.fs.bsl | 2 +- 15 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index ea1d6e948a9..2b3bedf0128 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1734,4 +1734,4 @@ featureUnmanagedConstraintCsharpInterop,"Interop between C#'s and F#'s unmanaged 3859,tcNoStaticPropertyFoundForOverride,"No static abstract property was found that corresponds to this override" 3860,chkStaticMembersOnObjectExpressions,"Object expressions cannot implement interfaces with static abstract members or declare static members." 3861,chkTailCallAttrOnNonRec,"The TailCall attribute should only be applied to recursive functions." -3862,parsStaticMemberImcompleteSyntax,"Incomplete static member declaration. Use the keywords 'static member' to declare a new member." \ No newline at end of file +3862,parsStaticMemberImcompleteSyntax,"Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration." \ 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 5cb657516a3..5e83abdf5fa 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -943,8 +943,8 @@ - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index a4116c8f365..449ca86f043 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -943,8 +943,8 @@ - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 606fd0d2cc2..787a11fd08a 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -943,8 +943,8 @@ - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 9e80bb769a5..993f5e4006b 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -943,8 +943,8 @@ - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index a2ba3df83d4..ada128d621e 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -943,8 +943,8 @@ - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 22be7596752..24bb54b8f0b 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -943,8 +943,8 @@ - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index b929ff1f795..ddc9480a5fe 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -943,8 +943,8 @@ - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index c52324b5f02..0adb71c9885 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -943,8 +943,8 @@ - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 11ac0bd0918..8ebafcdfd3e 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -943,8 +943,8 @@ - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index b99f9bafaf9..c79a5a05f2f 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -943,8 +943,8 @@ - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index aedd526d891..4a8521f86c7 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -943,8 +943,8 @@ - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 98ae2c227a2..45c5485e556 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -943,8 +943,8 @@ - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index c73582b3725..8d8949632f0 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -943,8 +943,8 @@ - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. - Incomplete static member declaration. Use the keywords 'static member' to declare a new member. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. + Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. diff --git a/tests/service/data/SyntaxTree/Member/MemberMispelledToMeme.fs.bsl b/tests/service/data/SyntaxTree/Member/MemberMispelledToMeme.fs.bsl index 827d8d6bd79..13e0c26b915 100644 --- a/tests/service/data/SyntaxTree/Member/MemberMispelledToMeme.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/MemberMispelledToMeme.fs.bsl @@ -59,4 +59,4 @@ ImplFile { ConditionalDirectives = [] CodeComments = [] }, set [])) -(2,3)-(2,9) parse error Incomplete static member declaration. Use the keywords 'static member' to declare a new member. +(2,3)-(2,9) parse error Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration. From 42c010f4bd704d4711db5e4de76493771a2ed521 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 30 Nov 2023 11:39:21 +0100 Subject: [PATCH 4/4] Update tests/service/SyntaxTreeTests.fs Co-authored-by: Adam Boniecki <20281641+abonie@users.noreply.github.com> --- tests/service/SyntaxTreeTests.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/service/SyntaxTreeTests.fs b/tests/service/SyntaxTreeTests.fs index e40c4999010..a386e25e9e8 100644 --- a/tests/service/SyntaxTreeTests.fs +++ b/tests/service/SyntaxTreeTests.fs @@ -190,7 +190,7 @@ let ParseFile fileName = let equals = expected = actual let testUpdateBSLEnv = System.Environment.GetEnvironmentVariable("TEST_UPDATE_BSL") - if not (isNull testUpdateBSLEnv) && testUpdateBSLEnv.Trim() = "1" && (not equals) then + if not (isNull testUpdateBSLEnv) && testUpdateBSLEnv.Trim() = "1" && not equals then File.WriteAllText(bslPath, actual) elif not equals then File.WriteAllText(actualPath, actual)