From beb1af044dc5d00089d7886d2ea6e679fa5f775e Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Wed, 13 May 2026 11:45:02 +0200 Subject: [PATCH] Parser: recover on unfinished 'match' expressions --- src/Compiler/FSComp.txt | 1 + src/Compiler/pars.fsy | 51 ++++++++++++------- src/Compiler/xlf/FSComp.txt.cs.xlf | 25 +++++---- src/Compiler/xlf/FSComp.txt.de.xlf | 25 +++++---- src/Compiler/xlf/FSComp.txt.es.xlf | 25 +++++---- src/Compiler/xlf/FSComp.txt.fr.xlf | 25 +++++---- src/Compiler/xlf/FSComp.txt.it.xlf | 25 +++++---- src/Compiler/xlf/FSComp.txt.ja.xlf | 25 +++++---- src/Compiler/xlf/FSComp.txt.ko.xlf | 25 +++++---- src/Compiler/xlf/FSComp.txt.pl.xlf | 25 +++++---- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 25 +++++---- src/Compiler/xlf/FSComp.txt.ru.xlf | 25 +++++---- src/Compiler/xlf/FSComp.txt.tr.xlf | 25 +++++---- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 25 +++++---- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 25 +++++---- .../data/SyntaxTree/Expression/Match 01.fs | 4 ++ .../SyntaxTree/Expression/Match 01.fs.bsl | 19 +++++++ .../data/SyntaxTree/Expression/Match 02.fs | 5 ++ .../SyntaxTree/Expression/Match 02.fs.bsl | 21 ++++++++ .../data/SyntaxTree/Expression/Match 03.fs | 6 +++ .../SyntaxTree/Expression/Match 03.fs.bsl | 23 +++++++++ .../data/SyntaxTree/Expression/Match 04.fs | 6 +++ .../SyntaxTree/Expression/Match 04.fs.bsl | 22 ++++++++ .../data/SyntaxTree/Expression/Match 05.fs | 6 +++ .../SyntaxTree/Expression/Match 05.fs.bsl | 23 +++++++++ .../data/SyntaxTree/Expression/Match 06.fs | 5 ++ .../SyntaxTree/Expression/Match 06.fs.bsl | 18 +++++++ .../data/SyntaxTree/Expression/Match 07.fs | 5 ++ .../SyntaxTree/Expression/Match 07.fs.bsl | 18 +++++++ .../data/SyntaxTree/Expression/Match 08.fs | 7 +++ .../SyntaxTree/Expression/Match 08.fs.bsl | 20 ++++++++ 31 files changed, 436 insertions(+), 149 deletions(-) create mode 100644 tests/service/data/SyntaxTree/Expression/Match 01.fs create mode 100644 tests/service/data/SyntaxTree/Expression/Match 01.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Expression/Match 02.fs create mode 100644 tests/service/data/SyntaxTree/Expression/Match 02.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Expression/Match 03.fs create mode 100644 tests/service/data/SyntaxTree/Expression/Match 03.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Expression/Match 04.fs create mode 100644 tests/service/data/SyntaxTree/Expression/Match 04.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Expression/Match 05.fs create mode 100644 tests/service/data/SyntaxTree/Expression/Match 05.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Expression/Match 06.fs create mode 100644 tests/service/data/SyntaxTree/Expression/Match 06.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Expression/Match 07.fs create mode 100644 tests/service/data/SyntaxTree/Expression/Match 07.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Expression/Match 08.fs create mode 100644 tests/service/data/SyntaxTree/Expression/Match 08.fs.bsl diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 7ca8f0a7f8..6b5c62311d 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1818,3 +1818,4 @@ featurePreprocessorElif,"#elif preprocessor directive" 3885,parsLetBangCannotBeLastInCE,"'%s' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression." 3886,tcListLiteralWithSingleTupleElement,"This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements?" 3887,ilCustomAttrInvalidArrayElemType,"The type '%s' is not a valid custom attribute argument type. Custom attribute arrays must have elements of primitive types, enums, string, System.Type, or System.Object." +3888,parsExpectingWith,"Expecting 'with'" \ No newline at end of file diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 99870fe2b9..355ea41cf0 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -4218,29 +4218,17 @@ declExpr: | anonLambdaExpr %prec expr_fun { $1 } - | MATCH typedSequentialExpr withClauses %prec expr_match + | MATCH matchExprCore { let mMatch = rhs parseState 1 - let mWith, (clauses, mLast) = $3 - let spBind = DebugPointAtBinding.Yes(unionRanges mMatch mWith) + let spBind, expr, clauses, mWith, mWhole = $2 mMatch let trivia = { MatchKeyword = mMatch; WithKeyword = mWith } - SynExpr.Match(spBind, $2, clauses, unionRanges mMatch mLast, trivia) } - - | MATCH typedSequentialExpr recover %prec expr_match - { if not $3 then reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnexpectedEndOfFileMatch()) - // Produce approximate expression during error recovery - exprFromParseError $2 } + SynExpr.Match(spBind, expr, clauses, mWhole, trivia) } - | MATCH_BANG typedSequentialExpr withClauses %prec expr_match - { let mMatch = (rhs parseState 1) - let mWith, (clauses, mLast) = $3 - let spBind = DebugPointAtBinding.Yes(unionRanges mMatch mWith) + | MATCH_BANG matchExprCore + { let mMatch = rhs parseState 1 + let spBind, expr, clauses, mWith, mWhole = $2 mMatch let trivia = { MatchBangKeyword = mMatch; WithKeyword = mWith } - SynExpr.MatchBang(spBind, $2, clauses, unionRanges mMatch mLast, trivia) } - - | MATCH_BANG typedSequentialExpr recover %prec expr_match - { if not $3 then reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnexpectedEndOfFileMatch()) - // Produce approximate expression during error recovery - exprFromParseError $2 } + SynExpr.MatchBang(spBind, expr, clauses, mWhole, trivia) } | TRY typedSequentialExprBlockR withClauses %prec expr_try { let mTry = rhs parseState 1 @@ -4838,6 +4826,31 @@ declExpr: | minusExpr %prec expr_prefix_plus_minus { $1 } +matchExprCore: + | typedSequentialExpr withClauses %prec expr_match + { fun mMatch -> + let mWith, (clauses, mLast) = $2 + let mWhole = unionRanges mMatch mLast + let spBind = DebugPointAtBinding.Yes(unionRanges mMatch mWith) + spBind, $1, clauses, mWith, mWhole } + + | declExpr %prec expr_match + { fun mMatch -> + let mExpr = $1.Range + let mWhole = unionRanges mMatch mExpr + let mEnd = mWhole.EndRange + reportParseErrorAt mEnd (FSComp.SR.parsExpectingWith ()) + let spBind = DebugPointAtBinding.Yes(unionRanges mMatch mEnd) + spBind, $1, [], mEnd, mWhole } + + | %prec prec_recover + { fun mMatch -> + let spBind = DebugPointAtBinding.Yes(mMatch) + let expr = arbExpr ("match3", mMatch) + let mEnd = mMatch.EndRange + reportParseErrorAt mEnd (FSComp.SR.parsExpectingExpression ()) + spBind, expr, [], mEnd, mMatch } + whileExprCore: | declExpr doToken typedSequentialExprBlock doneDeclEnd { fun mKeyword -> diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 811bc1b86b..463d628fd7 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -1202,6 +1202,11 @@ Expecting union case field + + Expecting 'with' + Expecting 'with' + + 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) @@ -8972,16 +8977,16 @@ This expression is a function value. When used in an interpolated string it will be formatted using its 'ToString' method, which is likely not the intended behavior. Consider applying the function to its arguments. - - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - - - - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - - + + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + + + + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + + \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 994f29280b..2755dddab8 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -1202,6 +1202,11 @@ Expecting union case field + + Expecting 'with' + Expecting 'with' + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Unvollständiges Zeichenliteral (Beispiel: „Q“) oder qualifizierter Typaufruf (Beispiel: „T.Name“) @@ -8972,16 +8977,16 @@ This expression is a function value. When used in an interpolated string it will be formatted using its 'ToString' method, which is likely not the intended behavior. Consider applying the function to its arguments. - - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - - - - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - - + + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + + + + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + + \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 670163d0f8..7c35d376fc 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -1202,6 +1202,11 @@ Expecting union case field + + Expecting 'with' + Expecting 'with' + + 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) @@ -8972,16 +8977,16 @@ This expression is a function value. When used in an interpolated string it will be formatted using its 'ToString' method, which is likely not the intended behavior. Consider applying the function to its arguments. - - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - - - - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - - + + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + + + + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + + \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index de16952cee..0b386f026d 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -1202,6 +1202,11 @@ Expecting union case field + + Expecting 'with' + Expecting 'with' + + 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) @@ -8972,16 +8977,16 @@ This expression is a function value. When used in an interpolated string it will be formatted using its 'ToString' method, which is likely not the intended behavior. Consider applying the function to its arguments. - - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - - - - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - - + + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + + + + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + + \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 5b52ef2ebb..ab04402fb8 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -1202,6 +1202,11 @@ Expecting union case field + + Expecting 'with' + Expecting 'with' + + 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) @@ -8972,16 +8977,16 @@ This expression is a function value. When used in an interpolated string it will be formatted using its 'ToString' method, which is likely not the intended behavior. Consider applying the function to its arguments. - - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - - - - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - - + + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + + + + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + + \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 5eef9cc71a..b79b6e4145 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -1202,6 +1202,11 @@ Expecting union case field + + Expecting 'with' + Expecting 'with' + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) 不完全な文字リテラル (例: 'Q') または修飾型の呼び出し (例: 'T.Name) @@ -8972,16 +8977,16 @@ This expression is a function value. When used in an interpolated string it will be formatted using its 'ToString' method, which is likely not the intended behavior. Consider applying the function to its arguments. - - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - - - - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - - + + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + + + + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + + \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index ae7ca4394f..af8a1f025f 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -1202,6 +1202,11 @@ Expecting union case field + + Expecting 'with' + Expecting 'with' + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) 불완전한 문자 리터럴(예: 'Q') 또는 정규화된 형식 호출(예: 'T.Name) @@ -8972,16 +8977,16 @@ This expression is a function value. When used in an interpolated string it will be formatted using its 'ToString' method, which is likely not the intended behavior. Consider applying the function to its arguments. - - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - - - - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - - + + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + + + + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + + \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 5ed8950550..ce8b94de08 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -1202,6 +1202,11 @@ Expecting union case field + + Expecting 'with' + Expecting 'with' + + 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”) @@ -8972,16 +8977,16 @@ This expression is a function value. When used in an interpolated string it will be formatted using its 'ToString' method, which is likely not the intended behavior. Consider applying the function to its arguments. - - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - - - - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - - + + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + + + + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + + \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 30f75e12c8..9b0caaaefc 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -1202,6 +1202,11 @@ Expecting union case field + + Expecting 'with' + Expecting 'with' + + 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) @@ -8972,16 +8977,16 @@ This expression is a function value. When used in an interpolated string it will be formatted using its 'ToString' method, which is likely not the intended behavior. Consider applying the function to its arguments. - - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - - - - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - - + + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + + + + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + + \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 2f60668143..e1d6d7f494 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -1202,6 +1202,11 @@ Expecting union case field + + Expecting 'with' + Expecting 'with' + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) Неполный символьный литерал (например: "Q") или вызов квалифицированного типа (например: "T.Name) @@ -8972,16 +8977,16 @@ This expression is a function value. When used in an interpolated string it will be formatted using its 'ToString' method, which is likely not the intended behavior. Consider applying the function to its arguments. - - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - - - - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - - + + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + + + + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + + \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 4e89b343fe..e3543eb414 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -1202,6 +1202,11 @@ Expecting union case field + + Expecting 'with' + Expecting 'with' + + 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) @@ -8972,16 +8977,16 @@ This expression is a function value. When used in an interpolated string it will be formatted using its 'ToString' method, which is likely not the intended behavior. Consider applying the function to its arguments. - - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - - - - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - - + + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + + + + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + + \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 3485c64f09..2d08e67be7 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -1202,6 +1202,11 @@ Expecting union case field + + Expecting 'with' + Expecting 'with' + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) 字符文本不完整(示例: "Q")或限定类型调用(示例: "T.Name") @@ -8972,16 +8977,16 @@ This expression is a function value. When used in an interpolated string it will be formatted using its 'ToString' method, which is likely not the intended behavior. Consider applying the function to its arguments. - - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - - - - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - - + + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + + + + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + + \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 2c60a0abcf..3f396a6a50 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -1202,6 +1202,11 @@ Expecting union case field + + Expecting 'with' + Expecting 'with' + + Incomplete character literal (example: 'Q') or qualified type invocation (example: 'T.Name) 不完整的字元文字 (範例: 'Q') 或限定類型調用 (範例: 'T.Name) @@ -8972,16 +8977,16 @@ This expression is a function value. When used in an interpolated string it will be formatted using its 'ToString' method, which is likely not the intended behavior. Consider applying the function to its arguments. - - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. - - - - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? - - + + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + '{0}' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression. + + + + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements? + + \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/Expression/Match 01.fs b/tests/service/data/SyntaxTree/Expression/Match 01.fs new file mode 100644 index 0000000000..5a35220e98 --- /dev/null +++ b/tests/service/data/SyntaxTree/Expression/Match 01.fs @@ -0,0 +1,4 @@ +module Module + +match () with +| _ -> () diff --git a/tests/service/data/SyntaxTree/Expression/Match 01.fs.bsl b/tests/service/data/SyntaxTree/Expression/Match 01.fs.bsl new file mode 100644 index 0000000000..d60dc282cf --- /dev/null +++ b/tests/service/data/SyntaxTree/Expression/Match 01.fs.bsl @@ -0,0 +1,19 @@ +ImplFile + (ParsedImplFileInput + ("/root/Expression/Match 01.fs", false, QualifiedNameOfFile Module, [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Expr + (Match + (Yes (3,0--3,13), Const (Unit, (3,6--3,8)), + [SynMatchClause + (Wild (4,2--4,3), None, Const (Unit, (4,7--4,9)), (4,2--4,9), + Yes, { ArrowRange = Some (4,4--4,6) + BarRange = Some (4,0--4,1) })], (3,0--4,9), + { MatchKeyword = (3,0--3,5) + WithKeyword = (3,9--3,13) }), (3,0--4,9))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--4,9), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Expression/Match 02.fs b/tests/service/data/SyntaxTree/Expression/Match 02.fs new file mode 100644 index 0000000000..2f5a9f4ffb --- /dev/null +++ b/tests/service/data/SyntaxTree/Expression/Match 02.fs @@ -0,0 +1,5 @@ +module Module + +do + match () with + | _ -> () diff --git a/tests/service/data/SyntaxTree/Expression/Match 02.fs.bsl b/tests/service/data/SyntaxTree/Expression/Match 02.fs.bsl new file mode 100644 index 0000000000..b587369d0e --- /dev/null +++ b/tests/service/data/SyntaxTree/Expression/Match 02.fs.bsl @@ -0,0 +1,21 @@ +ImplFile + (ParsedImplFileInput + ("/root/Expression/Match 02.fs", false, QualifiedNameOfFile Module, [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Expr + (Do + (Match + (Yes (4,4--4,17), Const (Unit, (4,10--4,12)), + [SynMatchClause + (Wild (5,6--5,7), None, Const (Unit, (5,11--5,13)), + (5,6--5,13), Yes, { ArrowRange = Some (5,8--5,10) + BarRange = Some (5,4--5,5) })], + (4,4--5,13), { MatchKeyword = (4,4--4,9) + WithKeyword = (4,13--4,17) }), (3,0--5,13)), + (3,0--5,13))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--5,13), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Expression/Match 03.fs b/tests/service/data/SyntaxTree/Expression/Match 03.fs new file mode 100644 index 0000000000..315fc29727 --- /dev/null +++ b/tests/service/data/SyntaxTree/Expression/Match 03.fs @@ -0,0 +1,6 @@ +module Module + +do + match 1 with + + 2 diff --git a/tests/service/data/SyntaxTree/Expression/Match 03.fs.bsl b/tests/service/data/SyntaxTree/Expression/Match 03.fs.bsl new file mode 100644 index 0000000000..17c130bb58 --- /dev/null +++ b/tests/service/data/SyntaxTree/Expression/Match 03.fs.bsl @@ -0,0 +1,23 @@ +ImplFile + (ParsedImplFileInput + ("/root/Expression/Match 03.fs", false, QualifiedNameOfFile Module, [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Expr + (Do + (Match + (Yes (4,4--4,16), Const (Int32 1, (4,10--4,11)), + [SynMatchClause + (Const (Int32 2, (6,4--6,5)), None, + ArbitraryAfterError ("patternClauses2", (6,5--6,5)), + (6,4--6,5), Yes, { ArrowRange = None + BarRange = None })], (4,4--6,5), + { MatchKeyword = (4,4--4,9) + WithKeyword = (4,12--4,16) }), (3,0--6,5)), (3,0--6,5))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--6,5), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(7,0)-(7,0) parse error Incomplete structured construct at or before this point in pattern matching. Expected '->' or other token. diff --git a/tests/service/data/SyntaxTree/Expression/Match 04.fs b/tests/service/data/SyntaxTree/Expression/Match 04.fs new file mode 100644 index 0000000000..3b729d098b --- /dev/null +++ b/tests/service/data/SyntaxTree/Expression/Match 04.fs @@ -0,0 +1,6 @@ +module Module + +do + match 1 + + 2 diff --git a/tests/service/data/SyntaxTree/Expression/Match 04.fs.bsl b/tests/service/data/SyntaxTree/Expression/Match 04.fs.bsl new file mode 100644 index 0000000000..b9719c2d10 --- /dev/null +++ b/tests/service/data/SyntaxTree/Expression/Match 04.fs.bsl @@ -0,0 +1,22 @@ +ImplFile + (ParsedImplFileInput + ("/root/Expression/Match 04.fs", false, QualifiedNameOfFile Module, [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Expr + (Do + (Sequential + (SuppressNeither, true, + Match + (Yes (4,4--4,11), Const (Int32 1, (4,10--4,11)), [], + (4,4--4,11), { MatchKeyword = (4,4--4,9) + WithKeyword = (4,11--4,11) }), + Const (Int32 2, (6,4--6,5)), (4,4--6,5), + { SeparatorRange = None }), (3,0--6,5)), (3,0--6,5))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--6,5), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(4,11)-(4,11) parse error Expecting 'with' diff --git a/tests/service/data/SyntaxTree/Expression/Match 05.fs b/tests/service/data/SyntaxTree/Expression/Match 05.fs new file mode 100644 index 0000000000..e9df3df907 --- /dev/null +++ b/tests/service/data/SyntaxTree/Expression/Match 05.fs @@ -0,0 +1,6 @@ +module Module + +do + match + + 1 diff --git a/tests/service/data/SyntaxTree/Expression/Match 05.fs.bsl b/tests/service/data/SyntaxTree/Expression/Match 05.fs.bsl new file mode 100644 index 0000000000..af494b0a88 --- /dev/null +++ b/tests/service/data/SyntaxTree/Expression/Match 05.fs.bsl @@ -0,0 +1,23 @@ +ImplFile + (ParsedImplFileInput + ("/root/Expression/Match 05.fs", false, QualifiedNameOfFile Module, [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Expr + (Do + (Sequential + (SuppressNeither, true, + Match + (Yes (4,4--4,9), + ArbitraryAfterError ("match3", (4,4--4,9)), [], + (4,4--4,9), { MatchKeyword = (4,4--4,9) + WithKeyword = (4,9--4,9) }), + Const (Int32 1, (6,4--6,5)), (4,4--6,5), + { SeparatorRange = None }), (3,0--6,5)), (3,0--6,5))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--6,5), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(4,9)-(4,9) parse error Expecting expression diff --git a/tests/service/data/SyntaxTree/Expression/Match 06.fs b/tests/service/data/SyntaxTree/Expression/Match 06.fs new file mode 100644 index 0000000000..ffb75d473c --- /dev/null +++ b/tests/service/data/SyntaxTree/Expression/Match 06.fs @@ -0,0 +1,5 @@ +module Module + +match 1 + +2 diff --git a/tests/service/data/SyntaxTree/Expression/Match 06.fs.bsl b/tests/service/data/SyntaxTree/Expression/Match 06.fs.bsl new file mode 100644 index 0000000000..b52e8e1b06 --- /dev/null +++ b/tests/service/data/SyntaxTree/Expression/Match 06.fs.bsl @@ -0,0 +1,18 @@ +ImplFile + (ParsedImplFileInput + ("/root/Expression/Match 06.fs", false, QualifiedNameOfFile Module, [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Expr + (Match + (Yes (3,0--3,7), Const (Int32 1, (3,6--3,7)), [], (3,0--3,7), + { MatchKeyword = (3,0--3,5) + WithKeyword = (3,7--3,7) }), (3,0--3,7)); + Expr (Const (Int32 2, (5,0--5,1)), (5,0--5,1))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--5,1), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(3,7)-(3,7) parse error Expecting 'with' diff --git a/tests/service/data/SyntaxTree/Expression/Match 07.fs b/tests/service/data/SyntaxTree/Expression/Match 07.fs new file mode 100644 index 0000000000..82a28bc862 --- /dev/null +++ b/tests/service/data/SyntaxTree/Expression/Match 07.fs @@ -0,0 +1,5 @@ +module Module + +match + +1 diff --git a/tests/service/data/SyntaxTree/Expression/Match 07.fs.bsl b/tests/service/data/SyntaxTree/Expression/Match 07.fs.bsl new file mode 100644 index 0000000000..0eb293c7f8 --- /dev/null +++ b/tests/service/data/SyntaxTree/Expression/Match 07.fs.bsl @@ -0,0 +1,18 @@ +ImplFile + (ParsedImplFileInput + ("/root/Expression/Match 07.fs", false, QualifiedNameOfFile Module, [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Expr + (Match + (Yes (3,0--3,5), ArbitraryAfterError ("match3", (3,0--3,5)), [], + (3,0--3,5), { MatchKeyword = (3,0--3,5) + WithKeyword = (3,5--3,5) }), (3,0--3,5)); + Expr (Const (Int32 1, (5,0--5,1)), (5,0--5,1))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--5,1), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(3,5)-(3,5) parse error Expecting expression diff --git a/tests/service/data/SyntaxTree/Expression/Match 08.fs b/tests/service/data/SyntaxTree/Expression/Match 08.fs new file mode 100644 index 0000000000..f1ccffdb9b --- /dev/null +++ b/tests/service/data/SyntaxTree/Expression/Match 08.fs @@ -0,0 +1,7 @@ +module Module + +do + match 1 with + + let x = 1 + () diff --git a/tests/service/data/SyntaxTree/Expression/Match 08.fs.bsl b/tests/service/data/SyntaxTree/Expression/Match 08.fs.bsl new file mode 100644 index 0000000000..ca86dceef4 --- /dev/null +++ b/tests/service/data/SyntaxTree/Expression/Match 08.fs.bsl @@ -0,0 +1,20 @@ +ImplFile + (ParsedImplFileInput + ("/root/Expression/Match 08.fs", false, QualifiedNameOfFile Module, [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Expr + (Do + (Match + (Yes (4,4--4,16), Const (Int32 1, (4,10--4,11)), [], + (4,4--4,16), { MatchKeyword = (4,4--4,9) + WithKeyword = (4,12--4,16) }), (3,0--4,16)), + (3,0--4,16))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--4,16), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(6,4)-(6,7) parse error Unexpected keyword 'let' or 'use' in expression +(7,4)-(7,5) parse error Unexpected symbol '(' in definition. Expected incomplete structured construct at or before this point or other token.