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
If a record type with custom equality and hashcode is included in another type, calling the hashcode on the upper type fails, stating that the record type with custom hashcode is unhashable.
Repro code
test.fsx
[<CustomEquality; NoComparison>]typeX={
ID :int
Name :string }overridex.GetHashCode()= x.ID
overridethis.Equals(other :obj)=match other with|:? X as other -> this.ID = other.ID
|_->falsetypeY=| X ofXletx={ID =1; Name ="a"}// Works
printfn $"x:{x.GetHashCode()}"lety= X x
// Fails
printfn $"y:{y.GetHashCode()}"
test.cmd
dotnet fable . --lang python
python test.py
Expected and actual results
Expected result: Should return a hashcode for x and y
Actual result: Only returns a hashcode for x but fails for y
x:1
Traceback (most recent call last):
File "C:\Users\HLWei\Downloads\fable-testing\test.py", line 51, in <module>
to_console(("y:" + str(safe_hash(y))) + "")
^^^^^^^^^^^^
File "C:\Users\HLWei\Downloads\fable-testing\fable_modules\fable_library\util.py", line 2632, in safe_hash
else hash(x)
^^^^^^^
File "C:\Users\HLWei\Downloads\fable-testing\fable_modules\fable_library\types.py", line 85, in __hash__
return hash((hash(self.tag), *hashes))
^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unhashable type: 'X'
Description
If a record type with custom equality and hashcode is included in another type, calling the hashcode on the upper type fails, stating that the record type with custom hashcode is unhashable.
Repro code
test.fsx
test.cmd
dotnet fable . --lang python python test.py
Expected and actual results
Expected result: Should return a hashcode for
x
andy
Actual result: Only returns a hashcode for
x
but fails fory
Related information
dotnet fable --version
: 4.9.0dotnet tool list/update/install
: 4.9.0@Freymaurer
The text was updated successfully, but these errors were encountered: