Skip to content

Optional parameters for delegates #5171

@wallymathieu

Description

@wallymathieu

Repro steps

  1. Create a new test project dotnet new xunit -lang f#

  2. Add the following code:

open System
type DelegateWithOptionalParam = delegate of ?opt:string -> unit
let instanceOfDelegate = DelegateWithOptionalParam(ignore)

let ``Invoke delegate`` () =
    instanceOfDelegate.Invoke(opt="")

fs_compiler_crash.zip

Expected behavior

The code compiles.

Actual behavior

FSC : error FS2014: A problem occurred writing the binary '/Users/mathieu/src/tmp/fs_compiler_crash/obj/Debug/netcoreapp2.1/fs_compiler_crash.dll': Error in pass3 for type Tests, error: Error in GetMethodRefAsMethodDefIdx for mref = ("Invoke", "DelegateWithOptionalParam"), error: Exception of type 'Microsoft.FSharp.Compiler.AbstractIL.ILBinaryWriter+MethodDefNotFound' was thrown. [/Users/mathieu/src/tmp/fs_compiler_crash/fs_compiler_crash.fsproj]

Known workarounds

This pattern is perhaps not that common, so might not be used that often.

Related information

Provide any related information

  • Operating system: Mac OS X 10.13.5
  • .NET Runtime: CoreCLR 2.1.300
  • Indications of severity: Low

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions