Access modifier `type private X with ...` type extensions is ignored
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
A private type extension `type private X with` inside a module will be in scope after the module is opened.
#### Repro steps
```fsharp
module Test
module Inner =
type private System.String with
member _this.ExtensionOnString () = ()
"".ExtensionOnString () // Works here.
open Inner
"".ExtensionOnString () // Works too. [A]
```
#### Expected behavior
The line marked [A] should fail to compile, since the type extension is private to the `Inner` module.
#### Actual behavior
The code works.
#### Known workarounds
Placing all extensions in another private module works.
```fsharp
module Test
module Inner =
module private Extensions =
type System.String with
member _this.ExtensionOnString () = ()
open Extensions
"".ExtensionOnString () // Works here.
open Inner
// "".ExtensionOnString () but no longer here.
```
#### Related information
The same on .NET and Mono.
Contributor guide
Assessment
This issue has not been assessed yet.