-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Description
proc log2trunc(x: uint64 | uint64): int =
if x == 0: int(0) else: int(0)
template maxChunkIdx(T: type): int64 = 0'i64
template layer(vIdx: int64): int = log2trunc(0'u64)
template int2(x: int): int = x
type HashList[T] = object
indices: array[int(layer(maxChunkIdx(T))), int]
does not compile (see current output section) but
proc log2trunc(x: uint64 | uint64): int =
if x == 0: int(0) else: int(0)
template maxChunkIdx(T: type): int64 = 0'i64
template layer(vIdx: int64): int = log2trunc(0'u64)
template int2(x: int): int = x
type HashList[T] = object
indices: array[int2(layer(maxChunkIdx(T))), int]
does compile, on Nim 2.0 and Nim devel, as does
proc log2trunc(x: uint64 | uint64): int =
if x == 0: int(0) else: int(0)
template maxChunkIdx(T: type): int64 = 0'i64
template layer(vIdx: int64): int = log2trunc(0'u64)
template int2(x: int): int = x
type HashList[T] = object
indices: array[layer(maxChunkIdx(T)), int]
There's both
- a strange error message (
maxChunkIdx
returnsint64
andlayer
takes anint64
) and - an inconsistency between whether apparently equivalent (
layer()
is a function fromint64
toint
, soint(layer(...))
should be equivalent tolayer(...)
) code builds or not.
Nim 1.6 has a different problem with this, evidently addressed in 2.0 already:
a.nim(2, 8) Error: cannot generate VM code for ==
Nim Version
Nim Compiler Version 2.0.1 [Linux: amd64]
Compiled at 2023-08-16
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: 037f536e7ee25c4baf23dff8a4525825c506442c
active boot switches: -d:release
Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2023-08-16
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: ade75a148332e670244a719202f7f0337d2e469a
active boot switches: -d:release
Current Output
a.nim(7, 27) Error: type mismatch
Expression: layer(maxChunkIdx(T))
[1] maxChunkIdx(T): typeof(maxChunkIdx(T))
Expected one of (first mismatch at [position]):
[1] template layer(vIdx: int64): int
Expected Output
Consistently build or consistently don't build
Possible Solution
No response
Additional Information
No response
Metadata
Metadata
Assignees
Labels
No labels