@@ -676,7 +676,7 @@ fileModuleSpec:
676676 | opt_attributes opt_declVisibility moduleIntro moduleSpfnsPossiblyEmptyBlock
677677 { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(),rhs parseState 2))
678678 let m2 = rhs parseState 3
679- let m = (rhs2 parseState 3 4)
679+ let m = (rhs2 parseState 1 4)
680680 let isRec,path2,xml,vis = $3
681681 (fun (isRec2,path,_) ->
682682 if not (isNil path) then errorR(Error(FSComp.SR.parsNamespaceOrModuleNotBoth(),m2))
@@ -745,15 +745,15 @@ moduleSpfn:
745745 if not (isNil $1) then raiseParseErrorAt (rhs parseState 1) (FSComp.SR.parsIgnoreAttributesOnModuleAbbreviation())
746746 match vis with
747747 | Some vis -> raiseParseErrorAt (rhs parseState 1) (FSComp.SR.parsIgnoreVisibilityOnModuleAbbreviationAlwaysPrivate(vis.ToString()))
748- | _ -> SynModuleSigDecl.ModuleAbbrev(List.head path,$5,rhs2 parseState 3 5) }
748+ | _ -> SynModuleSigDecl.ModuleAbbrev(List.head path,$5,rhs2 parseState 1 5) }
749749
750750 | opt_attributes opt_declVisibility moduleIntro colonOrEquals moduleSpecBlock
751751 { let isRec, path, xml, vis = $3
752752 if not (isSingleton path) then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsModuleDefnMustBeSimpleName())
753753 if isRec then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsInvalidUseOfRec())
754754 let info = ComponentInfo($1,[],[],path,xml,false,vis,rhs parseState 3)
755755 if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(),rhs parseState 2))
756- SynModuleSigDecl.NestedModule(info, isRec, $5, rhs2 parseState 3 5) }
756+ SynModuleSigDecl.NestedModule(info, isRec, $5, rhs2 parseState 1 5) }
757757
758758 | opt_attributes opt_declVisibility tyconSpfns
759759 { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(),rhs parseState 2))
@@ -778,7 +778,7 @@ valSpfn:
778778 { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(),rhs parseState 2))
779779 let attr1,attr2,isInline,isMutable,vis2,id,doc,explicitValTyparDecls,(ty,arity),konst = ($1),($4),($5),($6),($7),($8),grabXmlDoc(parseState,3),($9),($11),($12)
780780 if not (isNil attr2) then errorR(Deprecated(FSComp.SR.parsAttributesMustComeBeforeVal(),rhs parseState 4))
781- let m = rhs2 parseState 3 11
781+ let m = rhs2 parseState 1 11
782782 let valSpfn = ValSpfn((attr1@attr2),id,explicitValTyparDecls,ty,arity,isInline,isMutable,doc, vis2,konst,m)
783783 SynModuleSigDecl.Val(valSpfn,m)
784784 }
@@ -965,21 +965,23 @@ classMemberSpfn:
965965 SynMemberSig.Inherit ($4,unionRanges (rhs parseState 3) ($4).Range) }
966966
967967 | opt_attributes opt_declVisibility VAL fieldDecl
968- { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(),rhs parseState 2))
969- let fld = $4 $1 false
970- SynMemberSig.ValField(fld,rhs2 parseState 3 4) }
968+ { let wholeRange = rhs2 parseState 1 4
969+ if Option.isSome $2 then errorR (Error (FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier (), rhs parseState 2))
970+ let fld = $4 $1 false wholeRange
971+ SynMemberSig.ValField (fld, wholeRange) }
971972
972973 | opt_attributes opt_declVisibility STATIC VAL fieldDecl
973- { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(),rhs parseState 2))
974- SynMemberSig.ValField($5 $1 true,rhs2 parseState 3 5) }
974+ { let wholeRange = rhs2 parseState 1 5
975+ if Option.isSome $2 then errorR (Error (FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier (), rhs parseState 2))
976+ SynMemberSig.ValField($5 $1 true wholeRange, wholeRange) }
975977
976978 | opt_attributes opt_declVisibility STATIC typeKeyword tyconSpfn
977979 { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(),rhs parseState 2))
978- SynMemberSig.NestedType($5,rhs2 parseState 3 5) }
980+ SynMemberSig.NestedType($5,rhs2 parseState 1 5) }
979981
980982 | opt_attributes opt_declVisibility NEW COLON topTypeWithTypeConstraints
981983 { let vis,doc,(ty,valSynInfo) = $2,grabXmlDoc(parseState,3),$5
982- let m = unionRanges (rhs parseState 3 ) ty.Range
984+ let m = unionRanges (rhs parseState 1 ) ty.Range
983985 let isInline = false
984986 let valSpfn = ValSpfn ($1, mkSynId (rhs parseState 3) "new", noInferredTypars, ty, valSynInfo, isInline, false, doc, vis, None, m)
985987 SynMemberSig.Member(valSpfn, CtorMemberFlags,m) }
@@ -1254,7 +1256,7 @@ moduleDefn:
12541256 | Choice2Of2 def ->
12551257 if not (isSingleton path) then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsModuleAbbreviationMustBeSimpleName())
12561258 let info = ComponentInfo(attribs,[],[],path,xml,false,vis,rhs parseState 3)
1257- [ SynModuleDecl.NestedModule(info, isRec, def, false,(rhs2 parseState 3 4, def) ||> unionRangeWithListBy (fun d -> d.Range) ) ] }
1259+ [ SynModuleDecl.NestedModule(info, isRec, def, false,(rhs2 parseState 1 4, def) ||> unionRangeWithListBy (fun d -> d.Range) ) ] }
12581260
12591261 /* unattached custom attributes */
12601262 | attributes recover
@@ -1850,8 +1852,8 @@ classDefnMember:
18501852 if Option.isSome $2 then errorR(Error(FSComp.SR.parsInterfacesHaveSameVisibilityAsEnclosingType(),rhs parseState 3))
18511853 let mWhole =
18521854 match $5 with
1853- | None -> rhs2 parseState 3 4
1854- | Some(mems) -> (rhs2 parseState 3 4, mems) ||> unionRangeWithListBy (fun (mem:SynMemberDefn) -> mem.Range)
1855+ | None -> rhs2 parseState 1 4
1856+ | Some(mems) -> (rhs2 parseState 1 4, mems) ||> unionRangeWithListBy (fun (mem:SynMemberDefn) -> mem.Range)
18551857 [ SynMemberDefn.Interface ($4, $5, mWhole) ] }
18561858
18571859 | opt_attributes opt_declVisibility abstractMemberFlags opt_inline nameop opt_explicitValTyparDecls COLON topTypeWithTypeConstraints classMemberSpfnGetSet opt_ODECLEND
@@ -1860,7 +1862,7 @@ classDefnMember:
18601862 let getSetRangeOpt, getSet = $9
18611863 let getSetAdjuster arity = match arity,getSet with SynValInfo([],_),MemberKind.Member -> MemberKind.PropertyGet | _ -> getSet
18621864 let wholeRange =
1863- let m = rhs parseState 3
1865+ let m = rhs parseState 1
18641866 match getSetRangeOpt with
18651867 | None -> unionRanges m ty.Range
18661868 | Some m2 -> unionRanges m m2
@@ -1875,11 +1877,13 @@ classDefnMember:
18751877
18761878 | opt_attributes opt_declVisibility valDefnDecl opt_ODECLEND
18771879 { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(),rhs parseState 2))
1878- $3 None $1 false }
1880+ let rangeStart = rhs parseState 1
1881+ $3 rangeStart $1 false }
18791882
18801883 | opt_attributes opt_declVisibility STATIC valDefnDecl opt_ODECLEND
18811884 { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(),rhs parseState 2))
1882- $4 (Some (rhs parseState 3)) $1 true }
1885+ let rangeStart = rhs parseState 1
1886+ $4 rangeStart $1 true }
18831887
18841888 | opt_attributes opt_declVisibility memberFlags autoPropsDefnDecl opt_ODECLEND
18851889 { let rangeStart = rhs parseState 1
@@ -1889,7 +1893,7 @@ classDefnMember:
18891893 $4 $1 isStatic flags rangeStart }
18901894
18911895 | opt_attributes opt_declVisibility NEW atomicPattern optAsSpec EQUALS typedSeqExprBlock opt_ODECLEND
1892- { let m = unionRanges (rhs2 parseState 3 6) $7.Range
1896+ { let m = unionRanges (rhs2 parseState 1 6) $7.Range
18931897 let expr = $7
18941898 let valSynData = SynValData (Some CtorMemberFlags, SynValInfo([SynInfo.InferSynArgInfoFromPat $4],SynInfo.unnamedRetVal), $5)
18951899 let vis = $2
@@ -1900,7 +1904,7 @@ classDefnMember:
19001904
19011905 | opt_attributes opt_declVisibility STATIC typeKeyword tyconDefn
19021906 { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(),rhs parseState 2))
1903- [ SynMemberDefn.NestedType($5,None,rhs2 parseState 3 5) ] }
1907+ [ SynMemberDefn.NestedType($5,None,rhs2 parseState 1 5) ] }
19041908
19051909
19061910/* A 'val' definition in an object type definition */
@@ -1909,8 +1913,8 @@ valDefnDecl:
19091913 { let mRhs = rhs2 parseState 4 6
19101914 let doc = grabXmlDoc(parseState,4)
19111915 let mValDecl = rhs2 parseState 1 6
1912- (fun mLeft attribs isStatic ->
1913- let mValDecl = match mLeft with None -> mValDecl | Some m -> unionRanges m mValDecl
1916+ (fun rangeStart attribs isStatic ->
1917+ let mValDecl = unionRanges rangeStart mValDecl
19141918 let fld = Field(attribs,isStatic,Some $4,$6,$2,doc,$3,mRhs)
19151919 [ SynMemberDefn.ValField(fld, mValDecl) ]) }
19161920
@@ -2294,20 +2298,20 @@ attrUnionCaseDecl:
22942298
22952299 | opt_attributes opt_access unionCaseName OF unionCaseRepr opt_OBLOCKSEP
22962300 { if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnionCasesCannotHaveVisibilityDeclarations(),rhs parseState 2))
2297- let mDecl = rhs2 parseState 3 5
2301+ let mDecl = rhs2 parseState 1 5
22982302 (fun xmlDoc -> Choice2Of2 (UnionCase ( $1, $3,UnionCaseFields $5,xmlDoc,None,mDecl)))
22992303 }
23002304
23012305 | opt_attributes opt_access unionCaseName COLON topType opt_OBLOCKSEP
23022306 { if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnionCasesCannotHaveVisibilityDeclarations(),rhs parseState 2))
23032307 libraryOnlyWarning(lhs parseState)
2304- let mDecl = rhs2 parseState 3 5
2308+ let mDecl = rhs2 parseState 1 5
23052309 (fun xmlDoc -> Choice2Of2 (UnionCase ( $1, $3,UnionCaseFullType $5,xmlDoc,None,mDecl)))
23062310 }
23072311
23082312 | opt_attributes opt_access unionCaseName EQUALS constant opt_OBLOCKSEP
23092313 { if Option.isSome $2 then errorR(Error(FSComp.SR.parsEnumFieldsCannotHaveVisibilityDeclarations(),rhs parseState 2))
2310- let mDecl = rhs2 parseState 3 5
2314+ let mDecl = rhs2 parseState 1 5
23112315 (fun xmlDoc -> Choice1Of2 (EnumCase ( $1, $3,$5,xmlDoc,mDecl)))
23122316 }
23132317
@@ -2365,18 +2369,18 @@ recdFieldDeclList:
23652369
23662370/* A field declaration in a record type */
23672371recdFieldDecl:
2368- | opt_attributes fieldDecl
2369- { let fld = $2 $1 false
2370- let (Field(a,b,c,d,e,f,vis,g)) = fld
2371- if Option.isSome vis then errorR(Error(FSComp.SR.parsRecordFieldsCannotHaveVisibilityDeclarations(),rhs parseState 2))
2372- Field(a,b,c,d,e,f,None,g) }
2372+ | opt_attributes fieldDecl
2373+ { let wholeRange = rhs2 parseState 1 2
2374+ let fld = $2 $1 false wholeRange
2375+ let (Field (a, b, c, d, e, f, vis, wholeRange)) = fld
2376+ if Option.isSome vis then errorR (Error (FSComp.SR.parsRecordFieldsCannotHaveVisibilityDeclarations (), rhs parseState 2))
2377+ Field (a, b, c, d, e, f, None, wholeRange) }
23732378
23742379/* Part of a field or val declaration in a record type or object type */
23752380fieldDecl:
23762381 | opt_mutable opt_access ident COLON typ
2377- { let mRhs = rhs2 parseState 3 5
2378- let xmlDoc = grabXmlDoc(parseState,3)
2379- (fun attrs stat -> Field(attrs, stat,Some $3,$5,$1,xmlDoc,$2,mRhs)) }
2382+ { let xmlDoc = grabXmlDoc (parseState, 3)
2383+ fun attrs stat wholeRange -> Field(attrs, stat, Some $3, $5, $1, xmlDoc, $2, wholeRange) }
23802384
23812385
23822386/* An exception definition */
0 commit comments