@@ -3020,6 +3020,11 @@ simplePattern:
30203020 | simplePattern COLON typeWithTypeConstraints
30213021 { SynPat.Typed($1, $3, lhs parseState) }
30223022
3023+ | simplePattern COLON recover
3024+ { let mColon = rhs parseState 2
3025+ let ty = SynType.FromParseError(mColon.EndRange)
3026+ SynPat.Typed($1, ty, unionRanges $1.Range mColon) }
3027+
30233028 | attributes simplePattern %prec paren_pat_attribs
30243029 { SynPat.Attrib($2, $1, lhs parseState) }
30253030
@@ -3341,9 +3346,14 @@ parenPattern:
33413346 | conjParenPatternElements
33423347 { SynPat.Ands(List.rev $1, rhs2 parseState 1 3) }
33433348
3344- | parenPattern COLON typeWithTypeConstraints %prec paren_pat_colon
3345- { let mLhs = lhs parseState
3346- SynPat.Typed($1, $3, mLhs) }
3349+ | parenPattern COLON typeWithTypeConstraints %prec paren_pat_colon
3350+ { let mLhs = lhs parseState
3351+ SynPat.Typed($1, $3, mLhs) }
3352+
3353+ | parenPattern COLON recover
3354+ { let mColon = rhs parseState 2
3355+ let ty = SynType.FromParseError(mColon.EndRange)
3356+ SynPat.Typed($1, ty, unionRanges $1.Range mColon) }
33473357
33483358 | attributes parenPattern %prec paren_pat_attribs
33493359 { let mLhs = lhs parseState
@@ -5094,15 +5104,20 @@ topTypeWithTypeConstraints:
50945104 // nb. it doesn't matter where the constraints go in the structure of the type.
50955105 SynType.WithGlobalConstraints(ty, List.rev $3, lhs parseState), arity }
50965106
5097- opt_topReturnTypeWithTypeConstraints:
5098- |
5099- { None }
5107+ opt_topReturnTypeWithTypeConstraints:
5108+ |
5109+ { None }
5110+
5111+ | COLON topTypeWithTypeConstraints
5112+ { let mColon = rhs parseState 1
5113+ let ty, arity = $2
5114+ let arity = (match arity with SynValInfo([], rmdata)-> rmdata | _ -> SynInfo.unnamedRetVal)
5115+ Some (Some mColon, SynReturnInfo((ty, arity), rhs parseState 2)) }
51005116
5101- | COLON topTypeWithTypeConstraints
5102- { let mColon = rhs parseState 1
5103- let ty, arity = $2
5104- let arity = (match arity with SynValInfo([], rmdata)-> rmdata | _ -> SynInfo.unnamedRetVal)
5105- Some (Some mColon, SynReturnInfo((ty, arity), rhs parseState 2)) }
5117+ | COLON recover
5118+ { let mColon = rhs parseState 1
5119+ let ty, arity = SynType.FromParseError(mColon.EndRange), SynInfo.unnamedRetVal
5120+ Some (Some mColon, SynReturnInfo((ty, arity), mColon.EndRange)) }
51065121
51075122topType:
51085123 | topTupleType RARROW topType
@@ -5136,31 +5151,61 @@ topTupleTypeElements:
51365151 [ SynTupleTypeSegment.Type t, Some argInfo ] }
51375152
51385153topAppType:
5139- | attributes appType COLON appType
5140- { match $2 with
5141- | SynType.LongIdent(SynLongIdent([id], _, _)) ->
5142- let m = rhs2 parseState 1 4
5143- SynType.SignatureParameter($1, false, Some id, $4, m), SynArgInfo($1, false, Some id)
5144- | _ -> raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsSyntaxErrorInLabeledType()) }
5145-
5146- | attributes QMARK ident COLON appType
5147- { let m = rhs2 parseState 1 5
5148- SynType.SignatureParameter($1, true, Some $3, $5, m), SynArgInfo($1, true, Some $3) }
5149-
5150- | attributes appType
5151- { let m = rhs2 parseState 1 2
5152- SynType.SignatureParameter($1, false, None, $2, m), SynArgInfo($1, false, None) }
5153-
5154- | appType COLON appType
5155- { match $1 with
5156- | SynType.LongIdent(SynLongIdent([id], _, _)) ->
5157- let m = rhs2 parseState 1 3
5158- SynType.SignatureParameter([], false, Some id, $3, m), SynArgInfo([], false, Some id)
5159- | _ -> raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsSyntaxErrorInLabeledType()) }
5160-
5161- | QMARK ident COLON appType
5162- { let m = rhs2 parseState 1 4
5163- SynType.SignatureParameter([], true, Some $2, $4, m), SynArgInfo([], true, Some $2) }
5154+ | attributes appType COLON appType
5155+ { match $2 with
5156+ | SynType.LongIdent(SynLongIdent([id], _, _)) ->
5157+ let m = unionRanges (rhs parseState 1) $4.Range
5158+ SynType.SignatureParameter($1, false, Some id, $4, m), SynArgInfo($1, false, Some id)
5159+ | _ -> raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsSyntaxErrorInLabeledType()) }
5160+
5161+ | attributes appType COLON recover
5162+ { match $2 with
5163+ | SynType.LongIdent(SynLongIdent([id], _, _)) ->
5164+ let mColon = rhs parseState 2
5165+ let m = unionRanges (rhs parseState 1) mColon
5166+ let ty = SynType.FromParseError(mColon.EndRange)
5167+ SynType.SignatureParameter($1, false, Some id, ty, m), SynArgInfo($1, false, Some id)
5168+ | _ -> raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsSyntaxErrorInLabeledType()) }
5169+
5170+ | attributes QMARK ident COLON appType
5171+ { let m = unionRanges (rhs parseState 1) $5.Range
5172+ SynType.SignatureParameter($1, true, Some $3, $5, m), SynArgInfo($1, true, Some $3) }
5173+
5174+ | attributes QMARK ident COLON recover
5175+ { let mColon = rhs parseState 4
5176+ let m = unionRanges (rhs parseState 1) mColon
5177+ let ty = SynType.FromParseError(mColon.EndRange)
5178+ SynType.SignatureParameter($1, true, Some $3, ty, m), SynArgInfo($1, true, Some $3) }
5179+
5180+ | attributes appType
5181+ { let m = unionRanges (rhs parseState 1) $2.Range
5182+ SynType.SignatureParameter($1, false, None, $2, m), SynArgInfo($1, false, None) }
5183+
5184+ | appType COLON appType
5185+ { match $1 with
5186+ | SynType.LongIdent(SynLongIdent([id], _, _)) ->
5187+ let m = unionRanges (rhs parseState 1) $3.Range
5188+ SynType.SignatureParameter([], false, Some id, $3, m), SynArgInfo([], false, Some id)
5189+ | _ -> raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsSyntaxErrorInLabeledType()) }
5190+
5191+ | appType COLON recover
5192+ { match $1 with
5193+ | SynType.LongIdent(SynLongIdent([id], _, _)) ->
5194+ let mColon = rhs parseState 2
5195+ let m = unionRanges $1.Range mColon
5196+ let ty = SynType.FromParseError(mColon.EndRange)
5197+ SynType.SignatureParameter([], false, Some id, ty, m), SynArgInfo([], false, Some id)
5198+ | _ -> raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsSyntaxErrorInLabeledType()) }
5199+
5200+ | QMARK ident COLON appType
5201+ { let m = unionRanges (rhs parseState 1) $4.Range
5202+ SynType.SignatureParameter([], true, Some $2, $4, m), SynArgInfo([], true, Some $2) }
5203+
5204+ | QMARK ident COLON recover
5205+ { let mColon = rhs parseState 3
5206+ let m = unionRanges (rhs parseState 1) mColon
5207+ let ty = SynType.FromParseError(mColon.EndRange)
5208+ SynType.SignatureParameter([], true, Some $2, ty, m), SynArgInfo([], true, Some $2) }
51645209
51655210 | appType
51665211 { $1, SynArgInfo([], false, None) }
0 commit comments