Registry Mirror
Skip to content

Optional parameters for delegates #5171

Closed

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

Activity

  1. added
    Impact-Low
    on Jun 19, 2018
  2. added this to the Unknown milestone on Aug 25, 2018
  3. added
    Area-Compiler-CodeGen
    and removed on Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-CodeGenBugImpact-Low

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions