Files
Nim/tests/js/tneginthash.nim
metagn f718f295df fix VM uint conversion size bug, stricter int gen on JS (#22150)
* fix VM uint conversion bug, stricter int gen on JS

fixes #19929

* fix float -> uint64 conversion too

* no need to mask to source type

* simpler diff with explanation, add test for described issue
2023-06-25 00:01:08 +02:00

22 lines
363 B
Nim

# issue #19929
import std/[tables, hashes]
type Foo = object
a: int
proc hash(f: Foo): Hash =
var h: Hash = 0
h = h !& hash(f.a)
result = !$h
proc transpose[T, S](data: array[T, S]): Table[S, T] =
for i, x in data:
result[x] = i
const xs = [Foo(a: 5), Foo(a: -5)]
const x = transpose(xs)
doAssert x[Foo(a: -5)] == 1
doAssert x[Foo(a: 5)] == 0