Skip to content

Commit 172dc31

Browse files
authored
include accessibility range in SynPat.Named (#18526)
1 parent 05500b8 commit 172dc31

File tree

20 files changed

+267
-1
lines changed

20 files changed

+267
-1
lines changed

docs/release-notes/.FSharp.Compiler.Service/9.0.300.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* Fixed [#18433](https://github.com/dotnet/fsharp/issues/18433), a rare case of an internal error in xml comment processing. ([PR #18436](https://github.com/dotnet/fsharp/pull/18436))
2626
* Fix confusing type inference error in task expression ([Issue #13789](https://github.com/dotnet/fsharp/issues/13789), [PR #18450](https://github.com/dotnet/fsharp/pull/18450))
2727
* Fix missing `null` highlighting in tooltips ([PR #18457](https://github.com/dotnet/fsharp/pull/18457))
28+
* Fix range of SynPat.Named doesn't include accessibility ([PR #18526](https://github.com/dotnet/fsharp/pull/18526))
2829
* Allow `_` in `use!` bindings values (lift FS1228 restriction) ([PR #18487](https://github.com/dotnet/fsharp/pull/18487))
2930
* Make `[<CallerMemberName; Struct>]` combination work([PR #18444](https://github.com/dotnet/fsharp/pull/18444/))
3031
* Fix code completion considers types from own namespace non-imported ([PR #18518](https://github.com/dotnet/fsharp/issues/18518))

src/Compiler/pars.fsy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3776,7 +3776,11 @@ atomicPattern:
37763776
mkSynPatMaybeVar lidwd vis (lhs parseState)
37773777
else
37783778
let synIdent = List.head lidwd.IdentsWithTrivia
3779-
SynPat.Named(synIdent, false, vis, synIdent.Range) }
3779+
let m =
3780+
match vis with
3781+
| Some vis -> unionRanges vis.Range synIdent.Range
3782+
| _ -> synIdent.Range
3783+
SynPat.Named(synIdent, false, vis, m) }
37803784

37813785
| constant
37823786
{ SynPat.Const(fst $1, snd $1) }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module Module
2+
3+
let value = 42
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ImplFile
2+
(ParsedImplFileInput
3+
("/root/SynType/Named 01.fs", false, QualifiedNameOfFile Module, [], [],
4+
[SynModuleOrNamespace
5+
([Module], false, NamedModule,
6+
[Let
7+
(false,
8+
[SynBinding
9+
(None, Normal, false, false, [],
10+
PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector),
11+
SynValData
12+
(None, SynValInfo ([], SynArgInfo ([], false, None)), None),
13+
Named (SynIdent (value, None), false, None, (3,4--3,9)), None,
14+
Const (Int32 42, (3,12--3,14)), (3,4--3,9), Yes (3,0--3,14),
15+
{ LeadingKeyword = Let (3,0--3,3)
16+
InlineKeyword = None
17+
EqualsRange = Some (3,10--3,11) })], (3,0--3,14))],
18+
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
19+
(1,0--3,14), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
20+
{ ConditionalDirectives = []
21+
CodeComments = [] }, set []))
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module Module
2+
3+
let private value = 42
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
ImplFile
2+
(ParsedImplFileInput
3+
("/root/SynType/Named 02.fs", false, QualifiedNameOfFile Module, [], [],
4+
[SynModuleOrNamespace
5+
([Module], false, NamedModule,
6+
[Let
7+
(false,
8+
[SynBinding
9+
(None, Normal, false, false, [],
10+
PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector),
11+
SynValData
12+
(None, SynValInfo ([], SynArgInfo ([], false, None)), None),
13+
Named
14+
(SynIdent (value, None), false, Some (Private (3,4--3,11)),
15+
(3,4--3,17)), None, Const (Int32 42, (3,20--3,22)),
16+
(3,4--3,17), Yes (3,0--3,22),
17+
{ LeadingKeyword = Let (3,0--3,3)
18+
InlineKeyword = None
19+
EqualsRange = Some (3,18--3,19) })], (3,0--3,22))],
20+
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
21+
(1,0--3,22), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
22+
{ ConditionalDirectives = []
23+
CodeComments = [] }, set []))
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module Module
2+
3+
let (|A|) = 0
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
ImplFile
2+
(ParsedImplFileInput
3+
("/root/SynType/Named 03.fs", false, QualifiedNameOfFile Module, [], [],
4+
[SynModuleOrNamespace
5+
([Module], false, NamedModule,
6+
[Let
7+
(false,
8+
[SynBinding
9+
(None, Normal, false, false, [],
10+
PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector),
11+
SynValData
12+
(None, SynValInfo ([], SynArgInfo ([], false, None)), None),
13+
Named
14+
(SynIdent
15+
(|A|, Some (HasParenthesis ((3,4--3,5), (3,8--3,9)))),
16+
false, None, (3,4--3,9)), None,
17+
Const (Int32 0, (3,12--3,13)), (3,4--3,9), Yes (3,0--3,13),
18+
{ LeadingKeyword = Let (3,0--3,3)
19+
InlineKeyword = None
20+
EqualsRange = Some (3,10--3,11) })], (3,0--3,13))],
21+
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
22+
(1,0--3,13), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
23+
{ ConditionalDirectives = []
24+
CodeComments = [] }, set []))
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module Module
2+
3+
let private (|A|) = 0
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
ImplFile
2+
(ParsedImplFileInput
3+
("/root/SynType/Named 04.fs", false, QualifiedNameOfFile Module, [], [],
4+
[SynModuleOrNamespace
5+
([Module], false, NamedModule,
6+
[Let
7+
(false,
8+
[SynBinding
9+
(None, Normal, false, false, [],
10+
PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector),
11+
SynValData
12+
(None, SynValInfo ([], SynArgInfo ([], false, None)), None),
13+
Named
14+
(SynIdent
15+
(|A|, Some (HasParenthesis ((3,12--3,13), (3,16--3,17)))),
16+
false, Some (Private (3,4--3,11)), (3,4--3,17)), None,
17+
Const (Int32 0, (3,20--3,21)), (3,4--3,17), Yes (3,0--3,21),
18+
{ LeadingKeyword = Let (3,0--3,3)
19+
InlineKeyword = None
20+
EqualsRange = Some (3,18--3,19) })], (3,0--3,21))],
21+
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
22+
(1,0--3,21), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
23+
{ ConditionalDirectives = []
24+
CodeComments = [] }, set []))

0 commit comments

Comments
 (0)