@@ -3732,22 +3732,22 @@ declExpr:
37323732 $3 $2 mIf false }
37333733
37343734 | IF declExpr recover %prec expr_if
3735- { reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsIncompleteIf())
3736- // Produce an approximate expression during error recovery.
3737- // Include expressions to make sure they get type checked in case that generates useful results for intellisense.
3738- // Generate a throwAway for the expression so it isn't forced to have a type 'bool'
3739- // from the context it is used in.
3740- exprFromParseError $2 }
3735+ { errorR (Error(FSComp.SR.parsIncompleteIf (), rhs parseState 1))
3736+ let ifExpr = $2
3737+ let mIf = rhs parseState 1
3738+ let mThen = ifExpr.Range.EndRange
3739+ let m = unionRanges mIf mThen
3740+ let spIfToThen = DebugPointAtBinding.Yes m
3741+ let trivia = { IfKeyword = mIf; IsElif = false; ThenKeyword = mThen; ElseKeyword = None; IfToThenRange = m }
3742+ SynExpr.IfThenElse($2, arbExpr ("if1", mThen), None, spIfToThen, true, m, trivia) }
37413743
37423744 | IF recover %prec expr_if
3743- { reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsIncompleteIf())
3744- // Produce an approximate expression during error recovery. There can still be value in doing this even
3745- // for this pathological case.
3745+ { errorR (Error(FSComp.SR.parsIncompleteIf (), rhs parseState 1))
37463746 let m = rhs parseState 1
37473747 let mEnd = m.EndRange
37483748 let spIfToThen = DebugPointAtBinding.Yes mEnd
37493749 let trivia = { IfKeyword = m; IsElif = false; ThenKeyword = m; ElseKeyword = None; IfToThenRange = m }
3750- exprFromParseError ( SynExpr.IfThenElse(arbExpr ("ifGuard1 ", mEnd), arbExpr ("thenBody1 ", mEnd), None, spIfToThen, true, m, trivia) ) }
3750+ SynExpr.IfThenElse(arbExpr ("if2 ", mEnd), arbExpr ("if3 ", mEnd), None, spIfToThen, true, m, trivia) }
37513751
37523752 | LAZY declExpr %prec expr_lazy
37533753 { SynExpr.Lazy($2, unionRanges (rhs parseState 1) $2.Range) }
@@ -4318,13 +4318,25 @@ ifExprThen:
43184318 | THEN declExpr %prec prec_then_if
43194319 { $2, rhs parseState 1 }
43204320
4321+ | THEN recover %prec prec_then_if
4322+ { let mThen = rhs parseState 1
4323+ arbExpr ("ifThen1", mThen.EndRange), mThen }
4324+
43214325 | OTHEN OBLOCKBEGIN typedSequentialExpr oblockend %prec prec_then_if
43224326 { $3, rhs parseState 1 }
43234327
43244328 | OTHEN OBLOCKBEGIN typedSequentialExpr recover %prec prec_then_if
43254329 { if not $4 then reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnexpectedEndOfFileThen())
43264330 exprFromParseError $3, rhs parseState 1 }
43274331
4332+ | OTHEN recover %prec prec_then_if
4333+ { let mThen = rhs parseState 1
4334+ arbExpr ("ifThen2", mThen.EndRange), mThen }
4335+
4336+ | OTHEN OBLOCKBEGIN recover %prec prec_then_if
4337+ { let mThen = rhs parseState 1
4338+ arbExpr ("ifThen3", mThen.EndRange), mThen }
4339+
43284340ifExprElifs:
43294341 | /* EMPTY */
43304342 { None, None }
0 commit comments