diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-05-10 17:06:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-10 11:06:14 +0200 |
commit | deaf6843752112cfaadc688302c94779d633c686 (patch) | |
tree | 6a15079afca37a564ea73b4e1ee1bf51055c319b /tests | |
parent | 4b76037e5fe14f75ac5381a0d08ad509f450cf56 (diff) | |
download | Nim-deaf6843752112cfaadc688302c94779d633c686.tar.gz |
fix #9423 followup #17594: distinct generics now work in VM (#21816)
* fix #9423 distinct generics now work in vm * fixes cpp tests --------- Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/distinct/tdistinct.nim | 26 | ||||
-rw-r--r-- | tests/stdlib/tjsonutils.nim | 3 |
2 files changed, 26 insertions, 3 deletions
diff --git a/tests/distinct/tdistinct.nim b/tests/distinct/tdistinct.nim index 8ec083020..b6ba7aa99 100644 --- a/tests/distinct/tdistinct.nim +++ b/tests/distinct/tdistinct.nim @@ -159,7 +159,7 @@ block: #17322 type Foo = distinct string -template main() = +proc main() = # proc instead of template because of MCS/UFCS. # xxx put everything here to test under RT + VM block: # bug #12282 block: @@ -199,5 +199,29 @@ template main() = var c: B + block: # bug #9423 + block: + type Foo = seq[int] + type Foo2 = distinct Foo + template fn() = + var a = Foo2(@[1]) + a.Foo.add 2 + doAssert a.Foo == @[1, 2] + fn() + + block: + type Stack[T] = distinct seq[T] + proc newStack[T](): Stack[T] = + Stack[T](newSeq[T]()) + proc push[T](stack: var Stack[T], elem: T) = + seq[T](stack).add(elem) + proc len[T](stack: Stack[T]): int = + seq[T](stack).len + proc fn() = + var stack = newStack[int]() + stack.push(5) + doAssert stack.len == 1 + fn() + static: main() main() diff --git a/tests/stdlib/tjsonutils.nim b/tests/stdlib/tjsonutils.nim index d6f902301..9acf4c9e5 100644 --- a/tests/stdlib/tjsonutils.nim +++ b/tests/stdlib/tjsonutils.nim @@ -61,8 +61,7 @@ template fn() = testRoundtrip(pointer(nil)): """0""" testRoundtrip(cast[pointer](nil)): """0""" - # causes workaround in `fromJson` potentially related to - # https://github.com/nim-lang/Nim/issues/12282 + # refs bug #9423 testRoundtrip(Foo(1.5)): """1.5""" block: # OrderedTable |