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 calling Seq.toArray on a generic Dictionary. The resulting values are typed as KeyValuePair, but only contain the key. Accessing .Key and .Value properties is transpiled as .[0] and .[1], therefore returning the first and second element of the key value, instead of returning key and value. In the case of a string key, these are the first and second char:
I have investigated this and it's because in Fable we translate Dictionary to Python dict which will only give you the keys when you iterate it. I don't want to wrap it, so need to figure out how we can intercept the Seq.toList and know we are dealing with a Dictionary. It's currently not obvious for me how to fix this.
@dbrattli Seq.toList dict results in Coerce (i.e. TypeCast) expr from Dictionary<K,V> to IEnumerable<KeyValuePair<K, V>>, so you should be able to intercept it by inspecting the left and right types in the casting around here in Fable2Python.
Description
When calling
Seq.toArray
on a genericDictionary
. The resulting values are typed asKeyValuePair
, but only contain the key. Accessing.Key
and.Value
properties is transpiled as.[0]
and.[1]
, therefore returning the first and second element of the key value, instead of returning key and value. In the case of a string key, these are the first and second char:Repro code
test.fsx
test.cmd
dotnet fable . --lang python python test.py
Expected and actual results
For the array case, expecting the same result as for the list case.
Related information
dotnet fable --version
: 4.13.0dotnet tool list/update/install
: 4.13.0We got a performant workaround skipping the
toArray
step and instead initiating an Array usingArray.zeroCreate
.@Freymaurer
The text was updated successfully, but these errors were encountered: