You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Checking case of generic union type throws System.InvalidCastException.
Repro steps
typeMyCase<'T>=| Case1 of'T| Case2
letintCase1= Case1 1
intCase1 |> should be (ofCase <@ Case1 @>)
Expected behavior
The testing should be passed.
Actual behavior
The following exception is throwed.
Failed Test [49 ms]
Error Message:
System.InvalidCastException : Unable to cast object of type 'Case1[System.Int32]' to type 'MyCase`1[System.Object]'.
Stack Trace:
at lambda_method34(Closure , Object )
at FsUnit.Common.isOfCase@50.Invoke(a x)
at FsUnit.CustomConstraints.OfSameCaseConstraint.ApplyTo[TActual](TActual actual)
at NUnit.Framework.Assert.That[TActual](TActual actual, IResolveConstraint expression, String message, Object[] args)
at NUnit.Framework.Assert.That[TActual](TActual actual, IResolveConstraint expression)
at FsUnit.TopLevelOperators.should[a,a](FSharpFunc`2 f, a x, Object y)
Known workarounds
None.
Related information
Windows 11
FsUnit 4.0.6
.NET 5
The text was updated successfully, but these errors were encountered:
wenLiangcan
changed the title
ofCase doesn't support generic union Type
ofCase doesn't support generic union type
Oct 9, 2021
that is how type inference works in F#.
Compiler has no information to identify type of Case1 inside quotation, that is why it uses most generic one MyCase
in this case you have to manually specify type to help compiler
otherwise types are different and they should not be equal
Description
Checking case of generic union type throws
System.InvalidCastException
.Repro steps
Expected behavior
The testing should be passed.
Actual behavior
The following exception is throwed.
Known workarounds
None.
Related information
The text was updated successfully, but these errors were encountered: