Skip to content

Bad image when calling op_Addition on interface #14012

@gusty

Description

@gusty

Calling op_Addition on interface results in a Bad Image error.

Repro steps

  1. open System.Numerics;;

  2. IAdditionOperators.op_Addition (3, 6) ;;

Expected behavior

Compiles with val it: int = 9

Actual behavior

Fails compilation with:

> IAdditionOperators.op_Addition (3, 6) ;;
System.BadImageFormatException: Bad IL format.
   at <StartupCode$FSI_0012>.$FSI_0012.main@()
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
Stopped due to error

Known workarounds

Don't call directly on the interface.

Related information

Other operations, like op_CheckedAddition work fine:

> IAdditionOperators.op_CheckedAddition (3, 6) ;;
val it: int = 9

Test on:

Microsoft (R) F# Interactive version 12.0.5.0 for F# 7.0

Microsoft Visual Studio Community 2022 (64-bit) - Preview
Version 17.4.0 Preview 2.1

Metadata

Metadata

Assignees

Labels

Area-Compiler-ImportAndInteropimport of .NET DLLs and interopBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions