dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.83k stars 773 forks source link

Inline warning resulting in run time error (NotSupportedException) #17216

Closed sualitu closed 1 month ago

sualitu commented 1 month ago

I've been following the discussions around the stricter visibility handling around inline functions, but haven't been able to find anyone mentioning what I've encountered.

If this has been fixed by https://github.com/dotnet/fsharp/pull/17201 then feel free to close and ignore this.

Repro steps

Provide the steps required to reproduce the problem:

  1. Create a project with the following: https://gist.github.com/sualitu/bf4b12fcfb00e16e435b4d3365f05f11
  2. Ensure that TreatWarningsAsErrors is not turned on
  3. dotnet run

Doing that I get the following:

Unhandled exception. System.NotSupportedException: Dynamic invocation of op_Dollar is not supported
   at Program.privateFoo[a](a x) in /Users/sunea/dev/playground/PrivateInline/Program.fs:line 21
   at <StartupCode$PrivateInline>.$Program.main@() in /Users/sunea/dev/playground/PrivateInline/Program.fs:line 25

Expected behavior

I expect this to either work as normal, or for this to be an error.

I know and appreciate that warnings as errors is considered best practice, and I only stumbled upon this because one of our project didn't have it set, even though it should (so hey, it helped me there!).

Actual behavior

System.NotSupportedException

Known workarounds

Removing the privates

Related information

Provide any related information (optional):

dotnet --version
8.0.300
sw_vers
ProductName:        macOS
ProductVersion:     14.4.1
BuildVersion:       23E224
vzarytovskii commented 1 month ago

@sualitu Seems to be fixed

image

And as a sanity check, with commented out custom one:

image
sualitu commented 1 month ago

Fantastic, great work as usual! I'll close this.