Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
zah committed Mar 21, 2018
1 parent 9606c1f commit d4d5bd2
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/metatype/ttypeselectors.nim
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
discard """
output: "8\n8\n4"
"""

import
macros, typetraits

Expand Down Expand Up @@ -70,3 +74,28 @@ static:
assert m2.lo.type.name == "uint32"
assert m3.type.name == "MpUintBase[system.uint32]"

# https://github.com/nim-lang/Nim/issues/7379

import macros, typetraits

macro works(): untyped =
result = getType(int64)

macro fails(bits: static[int]): untyped =
if bits > 64:
result = getType(int64)
else:
result = getType(int32)

type
Foo*[bits: static[int]] = works()
Bar*[bits: static[int]] = fails(bits)

var a: Foo[16]
var b: Bar[256]
var c: Bar[32]

echo sizeof(a)
echo sizeof(b)
echo sizeof(c)

0 comments on commit d4d5bd2

Please sign in to comment.