diff options
author | metagn <metagngn@gmail.com> | 2023-08-30 08:23:14 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-30 07:23:14 +0200 |
commit | 2e4e2f8f5076b39e5976ba20f231f468b1b5052c (patch) | |
tree | 4c07c4548fe3f9cf42e8b8dbdb24d8d4013138a3 /tests | |
parent | d7634c1bd42dd5367d10283a2efc353a0a83aed2 (diff) | |
download | Nim-2e4e2f8f5076b39e5976ba20f231f468b1b5052c.tar.gz |
handle typedesc params in VM (#22581)
* handle typedesc params in VM fixes #15760 * add test * fix getType(typedesc) test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/vm/ttypedesc.nim | 18 | ||||
-rw-r--r-- | tests/vm/tvmmisc.nim | 5 |
2 files changed, 21 insertions, 2 deletions
diff --git a/tests/vm/ttypedesc.nim b/tests/vm/ttypedesc.nim new file mode 100644 index 000000000..a112584c5 --- /dev/null +++ b/tests/vm/ttypedesc.nim @@ -0,0 +1,18 @@ +block: # issue #15760 + type + Banana = object + SpecialBanana = object + + proc getName(_: type Banana): string = "Banana" + proc getName(_: type SpecialBanana): string = "SpecialBanana" + + proc x[T](): string = + const n = getName(T) # this one works + result = n + + proc y(T: type): string = + const n = getName(T) # this one failed to compile + result = n + + doAssert x[SpecialBanana]() == "SpecialBanana" + doAssert y(SpecialBanana) == "SpecialBanana" diff --git a/tests/vm/tvmmisc.nim b/tests/vm/tvmmisc.nim index 5760422a1..1429ef6e9 100644 --- a/tests/vm/tvmmisc.nim +++ b/tests/vm/tvmmisc.nim @@ -1,10 +1,11 @@ -# bug #4462 import macros import os +# bug #4462 block: proc foo(t: typedesc) {.compileTime.} = - assert sameType(getType(t), getType(int)) + assert sameType(getType(t), getType(typedesc[int])) + assert sameType(getType(t), getType(type int)) static: foo(int) |