Skip to content

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

@sualitu

Description

@sualitu

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 #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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions