From b0c8113ed1f6a6f73222133b0f2d511b26223181 Mon Sep 17 00:00:00 2001 From: nojaf Date: Tue, 28 Mar 2023 11:42:10 +0200 Subject: [PATCH 1/3] Add parser recovery for incomplete named pat pair. --- src/Compiler/FSComp.txt | 3 ++- src/Compiler/SyntaxTree/SyntaxTree.fs | 2 +- src/Compiler/SyntaxTree/SyntaxTree.fsi | 2 +- src/Compiler/pars.fsy | 9 ++++++- 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 ++++ ...ervice.SurfaceArea.netstandard20.debug.bsl | 6 ++--- ...vice.SurfaceArea.netstandard20.release.bsl | 6 ++--- .../Pattern/NamedPatPairRecoverAfterEquals.fs | 2 ++ .../NamedPatPairRecoverAfterEquals.fs.bsl | 24 +++++++++++++++++ .../NamedPatPairRecoverAfterIdentifier.fs | 2 ++ .../NamedPatPairRecoverAfterIdentifier.fs.bsl | 26 +++++++++++++++++++ ...ParenthesesOfSynArgPatsNamePatPairs.fs.bsl | 2 +- ...airsContainsTheRangeOfTheEqualsSign.fs.bsl | 2 +- 25 files changed, 139 insertions(+), 12 deletions(-) create mode 100644 tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterEquals.fs create mode 100644 tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterEquals.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterIdentifier.fs create mode 100644 tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterIdentifier.fs.bsl diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 9d26318039c..eb955fd8343 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1683,4 +1683,5 @@ featureEscapeBracesInFormattableString,"Escapes curly braces before calling Form 3559,typrelNeverRefinedAwayFromTop,"A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'." 3560,tcCopyAndUpdateRecordChangesAllFields,"This copy-and-update record expression changes all fields of record type '%s'. Consider using the record construction syntax instead." 3561,chkAutoOpenAttributeInTypeAbbrev,"FSharp.Core.AutoOpenAttribute should not be aliased." -3562,parsUnexpectedEndOfFileElif,"Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif then ' or 'else if then '." \ No newline at end of file +3562,parsUnexpectedEndOfFileElif,"Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif then ' or 'else if then '." +3563,parsIncompleteNamedPatPair,"Incomplete named pattern pair. Expected 'name = pattern'." \ No newline at end of file diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index e02559815a3..452d174c73c 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -881,7 +881,7 @@ type SynSimplePats = type SynArgPats = | Pats of pats: SynPat list - | NamePatPairs of pats: (Ident * range * SynPat) list * range: range * trivia: SynArgPatsNamePatPairsTrivia + | NamePatPairs of pats: (Ident * range option * SynPat) list * range: range * trivia: SynArgPatsNamePatPairsTrivia member x.Patterns = match x with diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index c9619454ded..575673804f5 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -1025,7 +1025,7 @@ type SynSimplePats = type SynArgPats = | Pats of pats: SynPat list - | NamePatPairs of pats: (Ident * range * SynPat) list * range: range * trivia: SynArgPatsNamePatPairsTrivia + | NamePatPairs of pats: (Ident * range option * SynPat) list * range: range * trivia: SynArgPatsNamePatPairsTrivia member Patterns: SynPat list diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 64223ea75be..f33b4f21fbc 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -3133,7 +3133,14 @@ namePatPairs: namePatPair: | ident EQUALS parenPattern { let mEquals = rhs parseState 2 - ($1, mEquals, $3) } + ($1, Some mEquals, $3) } + | ident EQUALS recover + { let mEquals = rhs parseState 2 + reportParseErrorAt mEquals.EndRange (FSComp.SR.parsIncompleteNamedPatPair()) + ($1, Some mEquals, patFromParseError (SynPat.Wild mEquals.EndRange)) } + | ident recover + { reportParseErrorAt $1.idRange.EndRange (FSComp.SR.parsIncompleteNamedPatPair()) + ($1, None, patFromParseError (SynPat.Wild $1.idRange.EndRange)) } constrPattern: | atomicPatternLongIdent explicitValTyparDecls diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 320b459c903..a9a9b721256 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -757,6 +757,11 @@ Očekává se vzorek. + + Incomplete named pattern pair. Expected 'name = pattern'. + Incomplete named pattern pair. Expected 'name = pattern'. + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Neúplný znakový literál (příklad: Q) nebo volání kvalifikovaného typu (příklad: T.Name) diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index d86df46773c..488435485e3 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -757,6 +757,11 @@ Muster wird erwartet + + Incomplete named pattern pair. Expected 'name = pattern'. + Incomplete named pattern pair. Expected 'name = pattern'. + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Unvollständiges Zeichenliteral (Beispiel: „Q“) oder qualifizierter Typaufruf (Beispiel: „T.Name“) diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index ac269771a6d..cb47d50d1fd 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -757,6 +757,11 @@ Se espera un patrón + + Incomplete named pattern pair. Expected 'name = pattern'. + Incomplete named pattern pair. Expected 'name = pattern'. + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Literal de carácter incompleto (ejemplo: 'Q') o invocación de tipo completo (ejemplo: 'T.Name) diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 159d0019bb2..efa98e41b37 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -757,6 +757,11 @@ Modèle attendu + + Incomplete named pattern pair. Expected 'name = pattern'. + Incomplete named pattern pair. Expected 'name = pattern'. + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Littéral de caractère incomplet (exemple : 'Q') ou appel de type qualifié (exemple : 'T.Name) diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 4635d6dd726..e1288eb6874 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -757,6 +757,11 @@ Criterio previsto + + Incomplete named pattern pair. Expected 'name = pattern'. + Incomplete named pattern pair. Expected 'name = pattern'. + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Valore letterale carattere incompleto (ad esempio: 'Q') o chiamata di tipo qualificato (ad esempio: 'T.Name) diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 2550dbfad8f..a54f3735111 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -757,6 +757,11 @@ 必要なパターン + + Incomplete named pattern pair. Expected 'name = pattern'. + Incomplete named pattern pair. Expected 'name = pattern'. + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 1bc06b905dd..09dadc7bc57 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -757,6 +757,11 @@ 예상되는 패턴 + + Incomplete named pattern pair. Expected 'name = pattern'. + Incomplete named pattern pair. Expected 'name = pattern'. + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) 불완전한 문자 리터럴(예: 'Q') 또는 정규화된 형식 호출(예: 'T.Name) diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 36776db2fa1..ac2bf3f89b0 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -757,6 +757,11 @@ Oczekiwano wzorca + + Incomplete named pattern pair. Expected 'name = pattern'. + Incomplete named pattern pair. Expected 'name = pattern'. + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Niekompletny literał znaku (przykład: „Q”) lub wywołanie typu kwalifikowanego (przykład: „T.Name”) diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index a4d95d27520..57a586dd3ca 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -757,6 +757,11 @@ Padrão esperado + + Incomplete named pattern pair. Expected 'name = pattern'. + Incomplete named pattern pair. Expected 'name = pattern'. + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Literal de caractere incompleto (exemplo: 'Q') ou invocação de tipo qualificado (exemplo: 'T.Name) diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 4d530c832fb..cafa070a0ce 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -757,6 +757,11 @@ Ожидается шаблон + + Incomplete named pattern pair. Expected 'name = pattern'. + Incomplete named pattern pair. Expected 'name = pattern'. + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Неполный символьный литерал (например: "Q") или вызов квалифицированного типа (например: "T.Name) diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 5800ab3d4d1..e64a4fd7029 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -757,6 +757,11 @@ Desen bekleniyor + + Incomplete named pattern pair. Expected 'name = pattern'. + Incomplete named pattern pair. Expected 'name = pattern'. + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Eksik karakter değişmez değeri (örnek: 'Q') veya tam tür çağrısı (örnek: 'T.Name) diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 4d76e98c8a6..d9a5d074df5 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -757,6 +757,11 @@ 预期模式 + + Incomplete named pattern pair. Expected 'name = pattern'. + Incomplete named pattern pair. Expected 'name = pattern'. + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) 字符文本不完整(示例: "Q")或限定类型调用(示例: "T.Name") diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 73bf94e9489..929d0f5d5ec 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -757,6 +757,11 @@ 必須是模式 + + Incomplete named pattern pair. Expected 'name = pattern'. + Incomplete named pattern pair. Expected 'name = pattern'. + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) 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 86a216e066b..af07cb1e4aa 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 @@ -5769,8 +5769,8 @@ FSharp.Compiler.Syntax.SynArgPats+NamePatPairs: FSharp.Compiler.SyntaxTrivia.Syn FSharp.Compiler.Syntax.SynArgPats+NamePatPairs: FSharp.Compiler.SyntaxTrivia.SynArgPatsNamePatPairsTrivia trivia FSharp.Compiler.Syntax.SynArgPats+NamePatPairs: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynArgPats+NamePatPairs: FSharp.Compiler.Text.Range range -FSharp.Compiler.Syntax.SynArgPats+NamePatPairs: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[FSharp.Compiler.Syntax.Ident,FSharp.Compiler.Text.Range,FSharp.Compiler.Syntax.SynPat]] get_pats() -FSharp.Compiler.Syntax.SynArgPats+NamePatPairs: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[FSharp.Compiler.Syntax.Ident,FSharp.Compiler.Text.Range,FSharp.Compiler.Syntax.SynPat]] pats +FSharp.Compiler.Syntax.SynArgPats+NamePatPairs: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[FSharp.Compiler.Syntax.Ident,Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range],FSharp.Compiler.Syntax.SynPat]] get_pats() +FSharp.Compiler.Syntax.SynArgPats+NamePatPairs: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[FSharp.Compiler.Syntax.Ident,Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range],FSharp.Compiler.Syntax.SynPat]] pats FSharp.Compiler.Syntax.SynArgPats+Pats: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynPat] get_pats() FSharp.Compiler.Syntax.SynArgPats+Pats: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynPat] pats FSharp.Compiler.Syntax.SynArgPats+Tags: Int32 NamePatPairs @@ -5779,7 +5779,7 @@ FSharp.Compiler.Syntax.SynArgPats: Boolean IsNamePatPairs FSharp.Compiler.Syntax.SynArgPats: Boolean IsPats FSharp.Compiler.Syntax.SynArgPats: Boolean get_IsNamePatPairs() FSharp.Compiler.Syntax.SynArgPats: Boolean get_IsPats() -FSharp.Compiler.Syntax.SynArgPats: FSharp.Compiler.Syntax.SynArgPats NewNamePatPairs(Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[FSharp.Compiler.Syntax.Ident,FSharp.Compiler.Text.Range,FSharp.Compiler.Syntax.SynPat]], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynArgPatsNamePatPairsTrivia) +FSharp.Compiler.Syntax.SynArgPats: FSharp.Compiler.Syntax.SynArgPats NewNamePatPairs(Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[FSharp.Compiler.Syntax.Ident,Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range],FSharp.Compiler.Syntax.SynPat]], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynArgPatsNamePatPairsTrivia) FSharp.Compiler.Syntax.SynArgPats: FSharp.Compiler.Syntax.SynArgPats NewPats(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynPat]) FSharp.Compiler.Syntax.SynArgPats: FSharp.Compiler.Syntax.SynArgPats+NamePatPairs FSharp.Compiler.Syntax.SynArgPats: FSharp.Compiler.Syntax.SynArgPats+Pats 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 86a216e066b..af07cb1e4aa 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 @@ -5769,8 +5769,8 @@ FSharp.Compiler.Syntax.SynArgPats+NamePatPairs: FSharp.Compiler.SyntaxTrivia.Syn FSharp.Compiler.Syntax.SynArgPats+NamePatPairs: FSharp.Compiler.SyntaxTrivia.SynArgPatsNamePatPairsTrivia trivia FSharp.Compiler.Syntax.SynArgPats+NamePatPairs: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynArgPats+NamePatPairs: FSharp.Compiler.Text.Range range -FSharp.Compiler.Syntax.SynArgPats+NamePatPairs: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[FSharp.Compiler.Syntax.Ident,FSharp.Compiler.Text.Range,FSharp.Compiler.Syntax.SynPat]] get_pats() -FSharp.Compiler.Syntax.SynArgPats+NamePatPairs: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[FSharp.Compiler.Syntax.Ident,FSharp.Compiler.Text.Range,FSharp.Compiler.Syntax.SynPat]] pats +FSharp.Compiler.Syntax.SynArgPats+NamePatPairs: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[FSharp.Compiler.Syntax.Ident,Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range],FSharp.Compiler.Syntax.SynPat]] get_pats() +FSharp.Compiler.Syntax.SynArgPats+NamePatPairs: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[FSharp.Compiler.Syntax.Ident,Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range],FSharp.Compiler.Syntax.SynPat]] pats FSharp.Compiler.Syntax.SynArgPats+Pats: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynPat] get_pats() FSharp.Compiler.Syntax.SynArgPats+Pats: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynPat] pats FSharp.Compiler.Syntax.SynArgPats+Tags: Int32 NamePatPairs @@ -5779,7 +5779,7 @@ FSharp.Compiler.Syntax.SynArgPats: Boolean IsNamePatPairs FSharp.Compiler.Syntax.SynArgPats: Boolean IsPats FSharp.Compiler.Syntax.SynArgPats: Boolean get_IsNamePatPairs() FSharp.Compiler.Syntax.SynArgPats: Boolean get_IsPats() -FSharp.Compiler.Syntax.SynArgPats: FSharp.Compiler.Syntax.SynArgPats NewNamePatPairs(Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[FSharp.Compiler.Syntax.Ident,FSharp.Compiler.Text.Range,FSharp.Compiler.Syntax.SynPat]], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynArgPatsNamePatPairsTrivia) +FSharp.Compiler.Syntax.SynArgPats: FSharp.Compiler.Syntax.SynArgPats NewNamePatPairs(Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[FSharp.Compiler.Syntax.Ident,Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range],FSharp.Compiler.Syntax.SynPat]], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynArgPatsNamePatPairsTrivia) FSharp.Compiler.Syntax.SynArgPats: FSharp.Compiler.Syntax.SynArgPats NewPats(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynPat]) FSharp.Compiler.Syntax.SynArgPats: FSharp.Compiler.Syntax.SynArgPats+NamePatPairs FSharp.Compiler.Syntax.SynArgPats: FSharp.Compiler.Syntax.SynArgPats+Pats diff --git a/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterEquals.fs b/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterEquals.fs new file mode 100644 index 00000000000..ad0c46afcfc --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterEquals.fs @@ -0,0 +1,2 @@ +match x with +| Y(z = ) -> () diff --git a/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterEquals.fs.bsl b/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterEquals.fs.bsl new file mode 100644 index 00000000000..d3c31b70c45 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterEquals.fs.bsl @@ -0,0 +1,24 @@ +ImplFile + (ParsedImplFileInput + ("/root/Pattern/NamedPatPairRecoverAfterEquals.fs", false, + QualifiedNameOfFile NamedPatPairRecoverAfterEquals, [], [], + [SynModuleOrNamespace + ([NamedPatPairRecoverAfterEquals], false, AnonModule, + [Expr + (Match + (Yes (1,0--1,12), Ident x, + [SynMatchClause + (LongIdent + (SynLongIdent ([Y], [], [None]), None, None, + NamePatPairs + ([(z, Some (2,6--2,7), + FromParseError (Wild (2,7--2,7), (2,7--2,7)))], + (2,4--2,9), { ParenRange = (2,3--2,9) }), None, + (2,2--2,9)), None, Const (Unit, (2,13--2,15)), + (2,2--2,15), Yes, { ArrowRange = Some (2,10--2,12) + BarRange = Some (2,0--2,1) })], + (1,0--2,15), { MatchKeyword = (1,0--1,5) + WithKeyword = (1,8--1,12) }), (1,0--2,15))], + PreXmlDocEmpty, [], None, (1,0--3,0), { LeadingKeyword = None })], + (true, false), { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterIdentifier.fs b/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterIdentifier.fs new file mode 100644 index 00000000000..9c207d700e3 --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterIdentifier.fs @@ -0,0 +1,2 @@ +match x with +| Y(a = 1; b = 2; c) -> () diff --git a/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterIdentifier.fs.bsl b/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterIdentifier.fs.bsl new file mode 100644 index 00000000000..188ebd7939e --- /dev/null +++ b/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterIdentifier.fs.bsl @@ -0,0 +1,26 @@ +ImplFile + (ParsedImplFileInput + ("/root/Pattern/NamedPatPairRecoverAfterIdentifier.fs", false, + QualifiedNameOfFile NamedPatPairRecoverAfterIdentifier, [], [], + [SynModuleOrNamespace + ([NamedPatPairRecoverAfterIdentifier], false, AnonModule, + [Expr + (Match + (Yes (1,0--1,12), Ident x, + [SynMatchClause + (LongIdent + (SynLongIdent ([Y], [], [None]), None, None, + NamePatPairs + ([(a, Some (2,6--2,7), Const (Int32 1, (2,8--2,9))); + (b, Some (2,13--2,14), Const (Int32 2, (2,15--2,16))); + (c, None, + FromParseError (Wild (2,19--2,19), (2,19--2,19)))], + (2,4--2,20), { ParenRange = (2,3--2,20) }), None, + (2,2--2,20)), None, Const (Unit, (2,24--2,26)), + (2,2--2,26), Yes, { ArrowRange = Some (2,21--2,23) + BarRange = Some (2,0--2,1) })], + (1,0--2,26), { MatchKeyword = (1,0--1,5) + WithKeyword = (1,8--1,12) }), (1,0--2,26))], + PreXmlDocEmpty, [], None, (1,0--3,0), { LeadingKeyword = None })], + (true, false), { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Pattern/ParenthesesOfSynArgPatsNamePatPairs.fs.bsl b/tests/service/data/SyntaxTree/Pattern/ParenthesesOfSynArgPatsNamePatPairs.fs.bsl index a875ebd4c57..e260f077c31 100644 --- a/tests/service/data/SyntaxTree/Pattern/ParenthesesOfSynArgPatsNamePatPairs.fs.bsl +++ b/tests/service/data/SyntaxTree/Pattern/ParenthesesOfSynArgPatsNamePatPairs.fs.bsl @@ -11,7 +11,7 @@ ImplFile (LongIdent (SynLongIdent ([OnePartData], [], [None]), None, None, NamePatPairs - ([(part1, (4,10--4,11), + ([(part1, Some (4,10--4,11), Named (SynIdent (p1, None), false, None, (4,12--4,14)))], (4,4--5,13), { ParenRange = (3,13--5,13) }), None, diff --git a/tests/service/data/SyntaxTree/Pattern/SynArgPatsNamePatPairsContainsTheRangeOfTheEqualsSign.fs.bsl b/tests/service/data/SyntaxTree/Pattern/SynArgPatsNamePatPairsContainsTheRangeOfTheEqualsSign.fs.bsl index b82db10dce3..61afba6c7a8 100644 --- a/tests/service/data/SyntaxTree/Pattern/SynArgPatsNamePatPairsContainsTheRangeOfTheEqualsSign.fs.bsl +++ b/tests/service/data/SyntaxTree/Pattern/SynArgPatsNamePatPairsContainsTheRangeOfTheEqualsSign.fs.bsl @@ -14,7 +14,7 @@ ImplFile (LongIdent (SynLongIdent ([X], [], [None]), None, None, NamePatPairs - ([(Y, (3,7--3,8), + ([(Y, Some (3,7--3,8), Named (SynIdent (y, None), false, None, (3,9--3,10)))], (3,4--3,11), { ParenRange = (3,3--3,11) }), None, From 79a939f7e0a8c84f9c9ce6e3c287dacee8997c9e Mon Sep 17 00:00:00 2001 From: nojaf Date: Tue, 28 Mar 2023 13:13:50 +0200 Subject: [PATCH 2/3] Remove newly added parser error. --- src/Compiler/FSComp.txt | 3 +-- src/Compiler/pars.fsy | 4 +--- 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 ----- 15 files changed, 2 insertions(+), 70 deletions(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index eb955fd8343..9d26318039c 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1683,5 +1683,4 @@ featureEscapeBracesInFormattableString,"Escapes curly braces before calling Form 3559,typrelNeverRefinedAwayFromTop,"A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'." 3560,tcCopyAndUpdateRecordChangesAllFields,"This copy-and-update record expression changes all fields of record type '%s'. Consider using the record construction syntax instead." 3561,chkAutoOpenAttributeInTypeAbbrev,"FSharp.Core.AutoOpenAttribute should not be aliased." -3562,parsUnexpectedEndOfFileElif,"Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif then ' or 'else if then '." -3563,parsIncompleteNamedPatPair,"Incomplete named pattern pair. Expected 'name = pattern'." \ No newline at end of file +3562,parsUnexpectedEndOfFileElif,"Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif then ' or 'else if then '." \ No newline at end of file diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index f33b4f21fbc..496d70bae62 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -3136,11 +3136,9 @@ namePatPair: ($1, Some mEquals, $3) } | ident EQUALS recover { let mEquals = rhs parseState 2 - reportParseErrorAt mEquals.EndRange (FSComp.SR.parsIncompleteNamedPatPair()) ($1, Some mEquals, patFromParseError (SynPat.Wild mEquals.EndRange)) } | ident recover - { reportParseErrorAt $1.idRange.EndRange (FSComp.SR.parsIncompleteNamedPatPair()) - ($1, None, patFromParseError (SynPat.Wild $1.idRange.EndRange)) } + { ($1, None, patFromParseError (SynPat.Wild $1.idRange.EndRange)) } constrPattern: | atomicPatternLongIdent explicitValTyparDecls diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index a9a9b721256..320b459c903 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -757,11 +757,6 @@ Očekává se vzorek. - - Incomplete named pattern pair. Expected 'name = pattern'. - Incomplete named pattern pair. Expected 'name = pattern'. - - Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Neúplný znakový literál (příklad: Q) nebo volání kvalifikovaného typu (příklad: T.Name) diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 488435485e3..d86df46773c 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -757,11 +757,6 @@ Muster wird erwartet - - Incomplete named pattern pair. Expected 'name = pattern'. - Incomplete named pattern pair. Expected 'name = pattern'. - - Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Unvollständiges Zeichenliteral (Beispiel: „Q“) oder qualifizierter Typaufruf (Beispiel: „T.Name“) diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index cb47d50d1fd..ac269771a6d 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -757,11 +757,6 @@ Se espera un patrón - - Incomplete named pattern pair. Expected 'name = pattern'. - Incomplete named pattern pair. Expected 'name = pattern'. - - Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Literal de carácter incompleto (ejemplo: 'Q') o invocación de tipo completo (ejemplo: 'T.Name) diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index efa98e41b37..159d0019bb2 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -757,11 +757,6 @@ Modèle attendu - - Incomplete named pattern pair. Expected 'name = pattern'. - Incomplete named pattern pair. Expected 'name = pattern'. - - Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Littéral de caractère incomplet (exemple : 'Q') ou appel de type qualifié (exemple : 'T.Name) diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index e1288eb6874..4635d6dd726 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -757,11 +757,6 @@ Criterio previsto - - Incomplete named pattern pair. Expected 'name = pattern'. - Incomplete named pattern pair. Expected 'name = pattern'. - - Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Valore letterale carattere incompleto (ad esempio: 'Q') o chiamata di tipo qualificato (ad esempio: 'T.Name) diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index a54f3735111..2550dbfad8f 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -757,11 +757,6 @@ 必要なパターン - - Incomplete named pattern pair. Expected 'name = pattern'. - Incomplete named pattern pair. Expected 'name = pattern'. - - Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 09dadc7bc57..1bc06b905dd 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -757,11 +757,6 @@ 예상되는 패턴 - - Incomplete named pattern pair. Expected 'name = pattern'. - Incomplete named pattern pair. Expected 'name = pattern'. - - Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) 불완전한 문자 리터럴(예: 'Q') 또는 정규화된 형식 호출(예: 'T.Name) diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index ac2bf3f89b0..36776db2fa1 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -757,11 +757,6 @@ Oczekiwano wzorca - - Incomplete named pattern pair. Expected 'name = pattern'. - Incomplete named pattern pair. Expected 'name = pattern'. - - Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Niekompletny literał znaku (przykład: „Q”) lub wywołanie typu kwalifikowanego (przykład: „T.Name”) diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 57a586dd3ca..a4d95d27520 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -757,11 +757,6 @@ Padrão esperado - - Incomplete named pattern pair. Expected 'name = pattern'. - Incomplete named pattern pair. Expected 'name = pattern'. - - Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Literal de caractere incompleto (exemplo: 'Q') ou invocação de tipo qualificado (exemplo: 'T.Name) diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index cafa070a0ce..4d530c832fb 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -757,11 +757,6 @@ Ожидается шаблон - - Incomplete named pattern pair. Expected 'name = pattern'. - Incomplete named pattern pair. Expected 'name = pattern'. - - Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Неполный символьный литерал (например: "Q") или вызов квалифицированного типа (например: "T.Name) diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index e64a4fd7029..5800ab3d4d1 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -757,11 +757,6 @@ Desen bekleniyor - - Incomplete named pattern pair. Expected 'name = pattern'. - Incomplete named pattern pair. Expected 'name = pattern'. - - Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Eksik karakter değişmez değeri (örnek: 'Q') veya tam tür çağrısı (örnek: 'T.Name) diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index d9a5d074df5..4d76e98c8a6 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -757,11 +757,6 @@ 预期模式 - - Incomplete named pattern pair. Expected 'name = pattern'. - Incomplete named pattern pair. Expected 'name = pattern'. - - Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) 字符文本不完整(示例: "Q")或限定类型调用(示例: "T.Name") diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 929d0f5d5ec..73bf94e9489 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -757,11 +757,6 @@ 必須是模式 - - Incomplete named pattern pair. Expected 'name = pattern'. - Incomplete named pattern pair. Expected 'name = pattern'. - - Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) From 02309b5528ec33387108af4537d888d80f583da9 Mon Sep 17 00:00:00 2001 From: nojaf Date: Wed, 29 Mar 2023 15:16:29 +0200 Subject: [PATCH 3/3] Update baseline --- .../Pattern/NamedPatPairRecoverAfterEquals.fs.bsl | 6 ++++-- .../Pattern/NamedPatPairRecoverAfterIdentifier.fs.bsl | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterEquals.fs.bsl b/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterEquals.fs.bsl index d3c31b70c45..4549710dfd6 100644 --- a/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterEquals.fs.bsl +++ b/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterEquals.fs.bsl @@ -20,5 +20,7 @@ ImplFile (1,0--2,15), { MatchKeyword = (1,0--1,5) WithKeyword = (1,8--1,12) }), (1,0--2,15))], PreXmlDocEmpty, [], None, (1,0--3,0), { LeadingKeyword = None })], - (true, false), { ConditionalDirectives = [] - CodeComments = [] }, set [])) + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(2,8)-(2,9) parse error Unexpected symbol ')' in pattern diff --git a/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterIdentifier.fs.bsl b/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterIdentifier.fs.bsl index 188ebd7939e..c288ee9ea72 100644 --- a/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterIdentifier.fs.bsl +++ b/tests/service/data/SyntaxTree/Pattern/NamedPatPairRecoverAfterIdentifier.fs.bsl @@ -22,5 +22,7 @@ ImplFile (1,0--2,26), { MatchKeyword = (1,0--1,5) WithKeyword = (1,8--1,12) }), (1,0--2,26))], PreXmlDocEmpty, [], None, (1,0--3,0), { LeadingKeyword = None })], - (true, false), { ConditionalDirectives = [] - CodeComments = [] }, set [])) + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(2,19)-(2,20) parse error Unexpected symbol ')' in pattern. Expected '=' or other token.