Files
Nim/tests/ccgbugs2/t25459b.nim
Tomohiro 88e7adfcb7 fixes #25459; hashType returns different hash from instantiated generics with distinct types (#25471)
`hashType` proc returned the same hash value from different instanced
generics types like `D[int64]` and `D[F]`.
That caused the struct type with wrong field types.

object/tuple type size check code is generated when it is compiled with
`-d:checkAbi` option.
2026-02-01 07:01:55 +01:00

32 lines
539 B
Nim

discard """
targets: "c cpp"
matrix: "-d:checkAbi"
"""
proc v[T](_: typedesc[T]): int =
if T is int64: 2 else: 1
type
D[T] = object
k: array[v(T), int]
E[T] = object
k: array[v(T), int]
F = distinct int64
W = object
a: D[int64]
b: D[F]
proc csizeof[T](x {.bycopy.} : T): cint {.importc: "sizeof", nodecl.}
var w: W
assert sizeof(w) == csizeof(w)
var
e0: E[F]
e1: E[int64]
assert sizeof(e0) == csizeof(e0)
assert sizeof(e1) == csizeof(e1)
var tup: (E[F], E[int64])
assert sizeof(tup) == csizeof(tup)