Skip to content

Commit a766f25

Browse files
authored
Include end in nested sig module range. (#15117)
1 parent f69e2f5 commit a766f25

File tree

5 files changed

+76
-5
lines changed

5 files changed

+76
-5
lines changed

src/Compiler/pars.fsy

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -662,11 +662,13 @@ moduleSpfn:
662662
if isRec then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsInvalidUseOfRec())
663663
let info = SynComponentInfo($1 @ attribs2, None, [], path, xmlDoc, false, vis, rhs parseState 3)
664664
if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2))
665-
let m = (rhs2 parseState 1 4, $5)
665+
let decls, mOptEnd = $5
666+
let m = (rhs2 parseState 1 4, decls)
666667
||> unionRangeWithListBy (fun (d: SynModuleSigDecl) -> d.Range)
667668
|> unionRangeWithXmlDoc xmlDoc
669+
let m = match mOptEnd with | None -> m | Some mEnd -> unionRanges m mEnd
668670
let trivia: SynModuleSigDeclNestedModuleTrivia = { ModuleKeyword = Some mModule; EqualsRange = $4 }
669-
SynModuleSigDecl.NestedModule(info, isRec, $5, m, trivia) }
671+
SynModuleSigDecl.NestedModule(info, isRec, decls, m, trivia) }
670672

671673
| opt_attributes opt_access moduleIntro error
672674
{ let mModule, isRec, path, vis, attribs2 = $3
@@ -743,15 +745,17 @@ moduleSpecBlock:
743745

744746
/* #light-syntax, with no sig/end or begin/end */
745747
| OBLOCKBEGIN moduleSpfns oblockend
746-
{ $2 }
748+
{ $2, None }
747749

748750
/* #light-syntax, with sig/end or begin/end */
749751
| OBLOCKBEGIN sigOrBegin moduleSpfnsPossiblyEmpty END oblockend
750-
{ $3 }
752+
{ let mEnd = rhs parseState 4
753+
$3, Some mEnd }
751754

752755
/* non-#light-syntax, with sig/end or begin/end */
753756
| sigOrBegin moduleSpfnsPossiblyEmpty END
754-
{ $2 }
757+
{ let mEnd = rhs parseState 3
758+
$2, Some mEnd }
755759

756760

757761
tyconSpfnList:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace X
2+
3+
module Y =
4+
begin
5+
val a: int
6+
type B = string
7+
end
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
SigFile
2+
(ParsedSigFileInput
3+
("/root/NestedModule/NestedModuleWithBeginEndAndDecls.fsi",
4+
QualifiedNameOfFile NestedModuleWithBeginEndAndDecls, [], [],
5+
[SynModuleOrNamespaceSig
6+
([X], false, DeclaredNamespace,
7+
[NestedModule
8+
(SynComponentInfo
9+
([], None, [], [Y],
10+
PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), false,
11+
None, (3,0--3,8)), false,
12+
[Val
13+
(SynValSig
14+
([], SynIdent (a, None), SynValTyparDecls (None, true),
15+
LongIdent (SynLongIdent ([int], [], [None])),
16+
SynValInfo ([], SynArgInfo ([], false, None)), false, false,
17+
PreXmlDoc ((5,8), FSharp.Compiler.Xml.XmlDocCollector),
18+
None, None, (5,8--5,18), { LeadingKeyword = Val (5,8--5,11)
19+
InlineKeyword = None
20+
WithKeyword = None
21+
EqualsRange = None }),
22+
(5,8--5,18));
23+
Types
24+
([SynTypeDefnSig
25+
(SynComponentInfo
26+
([], None, [], [B],
27+
PreXmlDoc ((6,8), FSharp.Compiler.Xml.XmlDocCollector),
28+
false, None, (6,13--6,14)),
29+
Simple
30+
(TypeAbbrev
31+
(Ok, LongIdent (SynLongIdent ([string], [], [None])),
32+
(6,17--6,23)), (6,17--6,23)), [], (6,13--6,23),
33+
{ LeadingKeyword = Type (6,8--6,12)
34+
EqualsRange = Some (6,15--6,16)
35+
WithKeyword = None })], (6,8--6,23))], (3,0--7,7),
36+
{ ModuleKeyword = Some (3,0--3,6)
37+
EqualsRange = Some (3,9--3,10) })], PreXmlDocEmpty, [], None,
38+
(1,0--7,7), { LeadingKeyword = Namespace (1,0--1,9) })],
39+
{ ConditionalDirectives = []
40+
CodeComments = [] }, set []))
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace X
2+
3+
module Y =
4+
begin end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
SigFile
2+
(ParsedSigFileInput
3+
("/root/NestedModule/RangeOfBeginEnd.fsi",
4+
QualifiedNameOfFile RangeOfBeginEnd, [], [],
5+
[SynModuleOrNamespaceSig
6+
([X], false, DeclaredNamespace,
7+
[NestedModule
8+
(SynComponentInfo
9+
([], None, [], [Y],
10+
PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), false,
11+
None, (3,0--3,8)), false, [], (3,0--4,13),
12+
{ ModuleKeyword = Some (3,0--3,6)
13+
EqualsRange = Some (3,9--3,10) })], PreXmlDocEmpty, [], None,
14+
(1,0--4,13), { LeadingKeyword = Namespace (1,0--1,9) })],
15+
{ ConditionalDirectives = []
16+
CodeComments = [] }, set []))

0 commit comments

Comments
 (0)