@@ -136,7 +136,7 @@ let parse_error_rich = Some(fun (ctxt: ParseErrorContext<_>) ->
136136 - just after '->' in any context
137137 - when opening CtxtNamespaceHead, CtxtModuleHead
138138 */
139- %token OBLOCKSEP /* LexFilter #light inserts when transforming CtxtSeqBlock(NotFirstInSeqBlock, _, AddBlockEnd) to CtxtSeqBlock(FirstInSeqBlock, _, AddBlockEnd) on exact alignment */
139+ %token <range * bool> OBLOCKSEP /* LexFilter #light inserts when transforming CtxtSeqBlock(NotFirstInSeqBlock, _, AddBlockEnd) to CtxtSeqBlock(FirstInSeqBlock, _, AddBlockEnd) on exact alignment - bool indicates if implicit (true) */
140140
141141/* LexFilter #light inserts these tokens when closing offside contexts */
142142%token OEND // CtxtFun, CtxtMatchClauses, CtxtWithAsLet _
@@ -3668,14 +3668,13 @@ namePatPairs:
36683668 { let (id: Ident), mEq, (pat: SynPat) = $1
36693669 let m = unionRanges id.idRange pat.Range
36703670 let lid = SynLongIdent([id], [], [None])
3671- NamePatPairField(lid, mEq, m, pat, Some $2) :: $3 }
3671+ NamePatPairField(lid, mEq, m, pat, $2) :: $3 }
36723672
36733673 | namePatPair seps_block seps_block namePatPairs
3674- { reportParseErrorAt (rhs parseState 3) (FSComp.SR.parsExpectingPattern ())
3675- let (id: Ident), mEq, (pat: SynPat) = $1
3674+ { let (id: Ident), mEq, (pat: SynPat) = $1
36763675 let m = unionRanges id.idRange pat.Range
36773676 let lid = SynLongIdent([id], [], [None])
3678- NamePatPairField(lid, mEq, m, pat, Some $2) :: $4 }
3677+ NamePatPairField(lid, mEq, m, pat, $2) :: $4 }
36793678
36803679namePatPair:
36813680 | ident EQUALS parenPattern
@@ -4016,13 +4015,13 @@ recordPatternElementsAux:
40164015 | recordPatternElement seps_block recordPatternElementsAux
40174016 { let (lid: SynLongIdent), mEq, (pat: SynPat) = $1
40184017 let m = unionRanges lid.Range pat.Range
4019- NamePatPairField(lid, mEq, m, pat, Some $2) :: $3 }
4018+ NamePatPairField(lid, mEq, m, pat, $2) :: $3 }
40204019
40214020 | recordPatternElement seps_block seps_block recordPatternElementsAux
40224021 { reportParseErrorAt (rhs parseState 3) (FSComp.SR.parsExpectingPattern ())
40234022 let (lid: SynLongIdent), mEq, (pat: SynPat) = $1
40244023 let m = unionRanges lid.Range pat.Range
4025- NamePatPairField(lid, mEq, m, pat, Some $2) :: $4 }
4024+ NamePatPairField(lid, mEq, m, pat, $2) :: $4 }
40264025
40274026recordPatternElement:
40284027 | path EQUALS parenPattern
@@ -5709,7 +5708,11 @@ recdExprCore:
57095708 | appExpr
57105709 { let mExpr = rhs parseState 1
57115710 reportParseErrorAt mExpr (FSComp.SR.parsFieldBinding ())
5712- Some($1, BlockSeparator.Offside(mExpr.EndRange, None)), [] }
5711+ // Today SynExpr.Record requires copyInfo: (SynExpr * BlockSeparator) option.
5712+ // In this error-recovery branch we want to indicate “this looked like a copy-and-update base expression,
5713+ // but there was no WITH and no fields. The dummy BlockSeparator is the smallest way to keep the AST well-formed.
5714+ let dummySep = BlockSeparator.Semicolon(mExpr.EndRange, mExpr.EndRange.End)
5715+ (Some($1, dummySep), []) }
57135716
57145717/*
57155718 handles cases when identifier can start from the underscore
@@ -5743,36 +5746,46 @@ recdExprCore:
57435746 | appExpr WITH recdBinding recdExprBindings opt_seps_block
57445747 { let l = List.rev $4
57455748 let l = rebindRanges $3 l $5
5746- (Some($1, BlockSeparator.Offside(rhs parseState 2, None)), l) }
5749+ // Use WITH token range for the separator (convention for copy-and-update)
5750+ let withSep = BlockSeparator.Semicolon(rhs parseState 2, (rhs parseState 2).End)
5751+ (Some($1, withSep), l) }
57475752
57485753 | appExpr OWITH opt_seps_block OEND
5749- { (Some($1, BlockSeparator.Offside(rhs parseState 2, None)), []) }
5754+ { // Use OWITH token range for the separator (convention for copy-and-update)
5755+ let withSep = BlockSeparator.Semicolon(rhs parseState 2, (rhs parseState 2).End)
5756+ (Some($1, withSep), []) }
57505757
57515758 | appExpr OWITH recdBinding recdExprBindings opt_seps_block OEND
57525759 { let l = List.rev $4
57535760 let l = rebindRanges $3 l $5
5754- (Some($1, BlockSeparator.Offside(rhs parseState 2, None)), l) }
5761+ // Use OWITH token range for the separator (convention for copy-and-update)
5762+ let withSep = BlockSeparator.Semicolon(rhs parseState 2, (rhs parseState 2).End)
5763+ (Some($1, withSep), l) }
57555764
57565765opt_seps_block:
57575766 | seps_block
5758- { Some $1 }
5767+ { $1 }
57595768
57605769 | /* EMPTY */
57615770 { None }
57625771
57635772seps_block:
57645773 | OBLOCKSEP
5765- { BlockSeparator.Offside((rhs parseState 1), None) }
5774+ {
5775+ // OBLOCKSEP is purely syntactic: do not produce a BlockSeparator value
5776+ // Treat it as absence of an explicit separator
5777+ None
5778+ }
57665779
57675780 | SEMICOLON
57685781 { let m = (rhs parseState 1)
5769- BlockSeparator.Semicolon(m, Some m.End) }
5782+ Some ( BlockSeparator.Semicolon(m, m.End) ) }
57705783
57715784 | SEMICOLON OBLOCKSEP
5772- { BlockSeparator.Semicolon((rhs2 parseState 1 2), Some (rhs parseState 1).End) }
5785+ { Some ( BlockSeparator.Semicolon((rhs2 parseState 1 2), (rhs parseState 1).End) ) }
57735786
57745787 | OBLOCKSEP SEMICOLON
5775- { BlockSeparator.Semicolon((rhs2 parseState 1 2), Some (rhs parseState 2).End) }
5788+ { Some ( BlockSeparator.Semicolon((rhs2 parseState 1 2), (rhs parseState 2).End) ) }
57765789
57775790
57785791/* identifier can start from the underscore */
@@ -5787,7 +5800,7 @@ pathOrUnderscore :
57875800
57885801recdExprBindings:
57895802 | recdExprBindings seps_block recdBinding
5790- { ($3, Some $2) :: $1 }
5803+ { ($3, $2) :: $1 }
57915804
57925805 | /* EMPTY */
57935806 { [] }
0 commit comments