Skip to content

InternalsVisibleTo + internal module + inline function error message could be improved #7110

Description

@ForNeVeR

Repro steps

  1. Create two F# projects, LibProject and TestProject, where TestProject references LibProject
  2. In LibProject, write the following code:
    module internal LibProject.Tools
    
    open System.Net
    open System.Runtime.CompilerServices
    
    [<assembly: InternalsVisibleTo("TestProject")>]
    do ()
    
    let inline int32FromBigEndian(num : int) =
        IPAddress.NetworkToHostOrder(num)
  3. In TestProject, write the following code:
    module TestProject.Tests
    
    open LibProject.Tools
    
    let testTheFunction() =
        let xx = int32FromBigEndian 100
        0

The repro solution is attached: ReproTestProject.zip

Expected behavior

I think that the code should compile successfully. But even if it isn't, then the compiler should print a sensible error message.

Actual behavior

The code doesn't compile and the compiler provides rather cryptic messages:

LibProject\LibProject.fs(9,12): Error FS1113 : The value 'int32FromBigEndian' was marked inline but its implementation makes use of an internal or private function which is not sufficiently accessible
TestProject\TestProject.fs(6,14): Warning FS1116 : A value marked as 'inline' has an unexpected value
TestProject\TestProject.fs(6,14): Error FS1118 : Failed to inline the value 'int32FromBigEndian' marked 'inline', perhaps because a recursive value was marked 'inline'

Known workarounds

Well, don't use inline functions within internal modules with the InternalsVisibleTo attribute :)

Related information

Reproduced using .NET Core SDK:

$ dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.2.300
 Commit:    73efd5bd87

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18362
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.2.300\

Host (useful for support):
  Version: 2.2.5
  Commit:  0a3c9209c0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions