dotnet / dotnet/fsharp

Warning FS0044 (type abbreviation to a less accessible type) should not be incorrectly triggered when using signature files

Open
#3,998 1 comment 0 reactions 0 assignees View on GitHub
Area-Compiler-Checking Area-Compiler-Checking-Accessibility Bug Impact-Low
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

When a type abbreviation, which is going to be private or internal because of an associated signature file, points to a non public type, a compiler warning is generated.

#### Repro steps

`A.fsi`:
```fsi
module internal A

type [] Foobar =
member Baz : int
```

`A.fs`:
```fs
module A

type Foobar = F with
member __.Baz = 42
```

`B.fsi`:
```fsi
module internal B
```

`B.fs`:
```fs
module B

type Ok = Ok of A.Foobar // Works as you'd expect
type Oops = A.Foobar // FS0044

let test (x:A.Foobar) = x.Baz // Works too
```
#### Expected behavior

The code should compile with no warnings.

#### Actual behavior

I get the following warning:

```
B.fs(4,6): warning FS0044: This construct is deprecated. The type 'Foobar' is less accessible than the value, member or type 'Oops' it is used in.As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.
```

#### Known workarounds

A explicit visibility annotation in the implementation file makes the problem go away. This makes it merely a minor inconvenience.

#### Related information

Using fsc.exe 4.1 as bundled with VS2017 (v15.4.4).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.