-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Minimum code:
import std/bitops
testBit(1, 1.Natural)Compile error message:
f:\temp\nim-1.5.1\lib\pure\bitops.nim(63, 37) Error: 'sizeof' requires '.importc' types to be '.completeStruct'
Minimum code without importing bitops:
type BitsRange[T] = range[0..sizeof(T)*8-1]
proc bar[T](a: T; b: BitsRange[T]) =
discard
bar(1, 2.Natural)Compile error message:
f:\temp\testbitr.nim(1, 36) Error: 'sizeof' requires '.importc' types to be '.completeStruct'
This code also produces same compile error:
type BitsRange[T] = range[0..sizeof(T)*8-1]
proc bar[T](a: T; b: BitsRange[T]) =
discard
bar(1.Natural, 2.Natural)Just converting Natural variable to BitsRange[int] doesn't make compile error.
Following code compiles without erorr.
type BitsRange[T] = range[0..sizeof(T)*8-1]
var x: BitsRange[int] = 0
x = 1.Natural
echo x
var y: BitsRange[Natural] = 0
y = 1.Natural
echo y
y = 2
echo y
proc foo(x: BitsRange[int]) =
discard
foo(1)
foo(1.Natural)
proc foo2(x: BitsRange[Natural]) =
discard
foo2(1)
foo2(1.Natural)
proc bar[T](a: T; b: BitsRange[T]) =
discard
bar(1.Natural, 2)Nim version:
f:\temp>nim -v
Nim Compiler Version 1.5.1 [Windows: amd64]
Compiled at 2021-09-08
Copyright (c) 2006-2021 by Andreas Rumpf
active boot switches: -d:release
ZoomRmc
Metadata
Metadata
Assignees
Labels
No labels