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?
+
+