@@ -2485,69 +2485,36 @@ attrUnionCaseDecls:
24852485/* The core of a union case definition */
24862486attrUnionCaseDecl:
24872487  | opt_attributes opt_access unionCaseName
2488-       { if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnionCasesCannotHaveVisibilityDeclarations(), rhs parseState 2))
2489-         let mDecl = rhs parseState 3
2490-         (fun (xmlDoc, mBar) ->
2491-             let trivia: SynUnionCaseTrivia = { BarRange = Some mBar }
2492-             let mDecl = unionRangeWithXmlDoc xmlDoc mDecl
2493-             Choice2Of2 (SynUnionCase ($1, $3, SynUnionCaseKind.Fields [], xmlDoc, None, mDecl, trivia))) }
2488+       { mkSynUnionCase $1 $2 $3 (SynUnionCaseKind.Fields []) (rhs2 parseState 1 3) >> Choice2Of2 }
24942489
24952490  | opt_attributes opt_access recover
2496-       { if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnionCasesCannotHaveVisibilityDeclarations(), rhs parseState 2))
2497-         (fun (xmlDoc, mBar) ->
2498-             let id = SynIdent(mkSynId mBar.EndRange "", None)
2499-             let trivia: SynUnionCaseTrivia = { BarRange = Some mBar }
2500-             let mDecl = unionRangeWithXmlDoc xmlDoc mBar
2501-             Choice2Of2 (SynUnionCase ($1, id, SynUnionCaseKind.Fields [], xmlDoc, None, mDecl, trivia))) }
2491+       { fun (xmlDoc, mBar) -> mkSynUnionCase $1 $2 (SynIdent(mkSynId mBar.EndRange "", None)) (SynUnionCaseKind.Fields []) mBar (xmlDoc, mBar) |> Choice2Of2 }
25022492
25032493  | opt_attributes opt_access unionCaseName OF unionCaseRepr
2504-       { if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnionCasesCannotHaveVisibilityDeclarations(), rhs parseState 2))
2505-         let mDecl = rhs2 parseState 1 5
2506-         (fun (xmlDoc, mBar) ->
2507-             let trivia: SynUnionCaseTrivia = { BarRange = Some mBar }
2508-             let mDecl = unionRangeWithXmlDoc xmlDoc mDecl
2509-             Choice2Of2 (SynUnionCase ($1, $3, SynUnionCaseKind.Fields $5, xmlDoc, None, mDecl, trivia))) }
2494+       { mkSynUnionCase $1 $2 $3 (SynUnionCaseKind.Fields $5) (rhs2 parseState 1 5) >> Choice2Of2 }
2495+ 
2496+   | opt_attributes opt_access unionCaseName unionCaseRepr
2497+       { errorR (Error(FSComp.SR.parsMissingKeyword("of"), rhs2 parseState 3 4))
2498+         mkSynUnionCase $1 $2 $3 (SynUnionCaseKind.Fields $4) (rhs2 parseState 1 4) >> Choice2Of2 }
25102499
25112500  | opt_attributes opt_access OF unionCaseRepr
2512-       { if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnionCasesCannotHaveVisibilityDeclarations(), rhs parseState 2))
2513-         let mOf = rhs parseState 3
2501+       { let mOf = rhs parseState 3
25142502        let mId = mOf.StartRange
25152503        errorR (Error(FSComp.SR.parsMissingUnionCaseName(), mOf))
2516-         let mDecl = rhs2 parseState 1 4
2517-         (fun (xmlDoc, mBar) ->
2518-             let id = SynIdent(mkSynId mId "", None)
2519-             let trivia: SynUnionCaseTrivia = { BarRange = Some mBar }
2520-             let mDecl = unionRangeWithXmlDoc xmlDoc mDecl
2521-             Choice2Of2(SynUnionCase($1, id, SynUnionCaseKind.Fields $4, xmlDoc, None, mDecl, trivia))) }
2504+         mkSynUnionCase $1 $2 (SynIdent(mkSynId mId "", None)) (SynUnionCaseKind.Fields $4) (rhs2 parseState 1 4) >> Choice2Of2 }
25222505
25232506  | opt_attributes opt_access OF recover
2524-       { if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnionCasesCannotHaveVisibilityDeclarations(), rhs parseState 2))
2525-         let mOf = rhs parseState 3
2507+       { let mOf = rhs parseState 3
25262508        let mId = mOf.StartRange
25272509        errorR (Error(FSComp.SR.parsMissingUnionCaseName(), mOf))
2528-         let mDecl = rhs2 parseState 1 3
2529-         (fun (xmlDoc, mBar) ->
2530-             let id = SynIdent(mkSynId mId "", None)
2531-             let trivia: SynUnionCaseTrivia = { BarRange = Some mBar }
2532-             let mDecl = unionRangeWithXmlDoc xmlDoc mDecl
2533-             Choice2Of2(SynUnionCase($1, id, SynUnionCaseKind.Fields [], xmlDoc, None, mDecl, trivia))) }
2510+         mkSynUnionCase $1 $2 (SynIdent(mkSynId mId "", None)) (SynUnionCaseKind.Fields []) (rhs2 parseState 1 3) >> Choice2Of2 }
25342511
25352512  | opt_attributes opt_access unionCaseName OF recover
2536-       { if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnionCasesCannotHaveVisibilityDeclarations(), rhs parseState 2))
2537-         let mDecl = rhs2 parseState 1 4
2538-         (fun (xmlDoc, mBar) ->
2539-             let trivia: SynUnionCaseTrivia = { BarRange = Some mBar }
2540-             let mDecl = unionRangeWithXmlDoc xmlDoc mDecl
2541-             Choice2Of2 (SynUnionCase ($1, $3, SynUnionCaseKind.Fields [], xmlDoc, None, mDecl, trivia))) }
2513+       { mkSynUnionCase $1 $2 $3 (SynUnionCaseKind.Fields []) (rhs2 parseState 1 4) >> Choice2Of2 }
25422514
25432515  | opt_attributes opt_access unionCaseName COLON topType
2544-       { if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnionCasesCannotHaveVisibilityDeclarations(), rhs parseState 2))
2545-         if parseState.LexBuffer.ReportLibraryOnlyFeatures then libraryOnlyWarning(lhs parseState)
2546-         let mDecl = rhs2 parseState 1 5
2547-         (fun (xmlDoc, mBar) ->
2548-             let trivia: SynUnionCaseTrivia = { BarRange = Some mBar }
2549-             let mDecl = unionRangeWithXmlDoc xmlDoc mDecl
2550-             Choice2Of2 (SynUnionCase ($1, $3, SynUnionCaseKind.FullType $5, xmlDoc, None, mDecl, trivia))) }
2516+       { if parseState.LexBuffer.ReportLibraryOnlyFeatures then libraryOnlyWarning(lhs parseState)
2517+         mkSynUnionCase $1 $2 $3 (SynUnionCaseKind.FullType $5) (rhs2 parseState 1 5) >> Choice2Of2 }
25512518
25522519  | opt_attributes opt_access unionCaseName EQUALS atomicExpr
25532520      { if Option.isSome $2 then errorR(Error(FSComp.SR.parsEnumFieldsCannotHaveVisibilityDeclarations(), rhs parseState 2))
0 commit comments