Warum gibt der Wert fail
eine Ausnahme aus? fine
Wert funktioniert. Wenn ich inline
entferne oder wenn ich 't
in float
umwandele, dann funktioniert es.Inline-Plus-Operator in Struktur löst eine Ausnahme aus (F #)
[<Struct>]
type Test<'t> =
val x: 't
val y: 't
new (x,y) = { x = x; y = y }
static member inline (+) ((x,y), a: _ Test) = 0
static member inline (-) ((x,y), a: _ Test) = 0
let a = 1.,2.
let b = Test(1.,2.)
let fine = a - b
let fail = a + b
Fehlermeldung:
Unbehandelte Ausnahme: System.TypeInitializationException: Die Typeninitialisierer fo r ‚AdditionDynamicImplTable
3' threw an exception. ---> System.NotSupportedExcep tion: Dynamic invocation of op_Addition involving coercions is not supported. at [email protected][a,b,c](Type aty, Type bt y, Unit unitVar0) at Microsoft.FSharp.Core.LanguagePrimitives.AdditionDynamicImplTable
3..cctor () --- Ende der Ausnahmestapelüberwachung - - bei Microsoft.FSharp.Core.LanguagePrimitives.AdditionDynamic [T1, T2, TResult] (T1 x, T2 y) um. $ Program.main @() in C: \ Benutzer \ olsv \ Docume nts \ Visual Studio 2012 \ Projekte \ Consol eApplication1 \ ConsoleApplication1 \ Programm. fs: line 14 Drücken Sie eine beliebige Taste, um fortzufahren. . .