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
When boxing a byte value, it looses its underlying type information.
Repro code
test.fsx
letintValue= box 1letbyteValue= box 2uy
letmatchType(v :obj)=match v with|:?int as i -> printfn "int: %d" i
|:?byte as u -> printfn "byte: %u" u
|:?uint8 as u -> printfn "uint8: %u" u // equals byte, just for testing against Fable|_-> printfn "other"
matchType intValue // int: 1
matchType byteValue // other
printfn $"{2uy.GetType().Name}"// Byte
printfn $"{byteValue.GetType().Name}"// Object
test.cmd
dotnet fable . --lang python
python test.py
Expected and actual results
Expected result: Boxed byte value should match the reflective match case, and calling GetType().Name should return "Byte"
Actual result: Match case is not hit and "Object" is returned
@HLWeil@Freymaurer, this is a bit tricky since Python really just have int so we need to do some tricks if we want to make this work. Another possibility is that we (Fable) take a dependency on NumPy to have sized and signed integers. Would NumPy as a dependency be acceptable for your application?
Yes, with Python I'm considering removing the int subclasses which would make all integers transpile to variable size int and instead use numpy if more specific integers and reflection handling is needed. That should fix most array problems as well, i.e use list for arrays or numpy arrays if available.
Description
When boxing a
byte
value, it looses its underlying type information.Repro code
test.fsx
test.cmd
dotnet fable . --lang python python test.py
Expected and actual results
Expected result: Boxed byte value should match the reflective match case, and calling
GetType().Name
should return "Byte"Actual result: Match case is not hit and "Object" is returned
Related information
dotnet fable --version
: 4.13.0dotnet tool list/update/install
: 4.13.0@Freymaurer
The text was updated successfully, but these errors were encountered: