Skip to content

Commit 47072af

Browse files
gustycartermp
authored andcommitted
Consider '_' for members with access modifiers (#7631)
* Consider '_' for members with access modifiers * Add tests * Revert * Add tests with modifiers
1 parent 3fd44c4 commit 47072af

File tree

2 files changed

+32
-0
lines changed
  • src/fsharp
  • tests/fsharp/core/members/self-identifier/version47

2 files changed

+32
-0
lines changed

src/fsharp/pars.fsy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,11 @@ atomicPatternLongIdent:
19241924
}
19251925
| GLOBAL DOT pathOp { let (LongIdentWithDots(lid,dotms)) = $3 in (None,LongIdentWithDots(ident(MangledGlobalName,rhs parseState 1) :: lid, rhs parseState 2 :: dotms)) }
19261926
| pathOp { (None,$1) }
1927+
| access UNDERSCORE DOT pathOp {
1928+
if not (parseState.LexBuffer.SupportsFeature LanguageFeature.SingleUnderscorePattern) then
1929+
raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsUnexpectedSymbolDot())
1930+
let (LongIdentWithDots(lid,dotms)) = $4 in (Some($1),LongIdentWithDots(ident("_",rhs parseState 1)::lid, rhs parseState 2::dotms))
1931+
}
19271932
| access pathOp { (Some($1), $2) }
19281933

19291934

tests/fsharp/core/members/self-identifier/version47/test.fs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,46 @@ type MyStructWithUnderscoreIdentifier =
2626
member _.MethodWithUnderscoreSelf() = true
2727
member __.MethodWithDoubleUnderscoreSelf() = true
2828
member _E.MethodWithUnderscoreESelf() = true
29+
member private _.PrivateMethodWithUnderscoreSelf() = true
30+
member private __.PrivateMethodWithDoubleUnderscoreSelf() = true
31+
member private _E.PrivateMethodWithUnderscoreESelf() = true
32+
member inline _.InlineMethodWithUnderscoreSelf() = true
33+
member inline __.InlineMethodWithDoubleUnderscoreSelf() = true
34+
member inline _E.InlineMethodWithUnderscoreESelf() = true
35+
member inline private _.InlinePrivateMethodWithUnderscoreSelf() = true
36+
member inline private __.InlinePrivateMethodWithDoubleUnderscoreSelf() = true
37+
member inline private _E.InlinePrivateMethodWithUnderscoreESelf() = true
2938

3039
type MyClassWithUnderscoreIdentifier () =
3140
class
3241
member _.MethodWithUnderscoreSelf() = true
3342
member __.MethodWithDoubleUnderscoreSelf() = true
3443
member _E.MethodWithUnderscoreESelf() = true
44+
member private _.PrivateMethodWithUnderscoreSelf() = true
45+
member private __.PrivateMethodWithDoubleUnderscoreSelf() = true
46+
member private _E.PrivateMethodWithUnderscoreESelf() = true
47+
member inline _.InlineMethodWithUnderscoreSelf() = true
48+
member inline __.InlineMethodWithDoubleUnderscoreSelf() = true
49+
member inline _E.InlineMethodWithUnderscoreESelf() = true
50+
member inline private _.InlinePrivateMethodWithUnderscoreSelf() = true
51+
member inline private __.InlinePrivateMethodWithDoubleUnderscoreSelf() = true
52+
member inline private _E.InlinePrivateMethodWithUnderscoreESelf() = true
3553
end
3654

3755
type MyStructTypeWithUnderscoreIdentifier =
3856
struct
3957
member _.MethodWithUnderscoreSelf() = true
4058
member __.MethodWithDoubleUnderscoreSelf() = true
4159
member _E.MethodWithUnderscoreESelf() = true
60+
member private _.PrivateMethodWithUnderscoreSelf() = true
61+
member private __.PrivateMethodWithDoubleUnderscoreSelf() = true
62+
member private _E.PrivateMethodWithUnderscoreESelf() = true
63+
member inline _.InlineMethodWithUnderscoreSelf() = true
64+
member inline __.InlineMethodWithDoubleUnderscoreSelf() = true
65+
member inline _E.InlineMethodWithUnderscoreESelf() = true
66+
member inline private _.InlinePrivateMethodWithUnderscoreSelf() = true
67+
member inline private __.InlinePrivateMethodWithDoubleUnderscoreSelf() = true
68+
member inline private _E.InlinePrivateMethodWithUnderscoreESelf() = true
4269
end
4370

4471

0 commit comments

Comments
 (0)