diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2020-11-13 14:44:44 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-13 14:44:44 -0800 |
commit | 1a47fc2291b285ceb6b2f330f45997944b754b3a (patch) | |
tree | f4b7ba7e81167207c350430faa892ad9db39e075 /tests | |
parent | 562c6275b879613efeec6687dd31d3e81807dffd (diff) | |
download | Nim-1a47fc2291b285ceb6b2f330f45997944b754b3a.tar.gz |
strengthen taddr.nim: add test case for #14578; reference other issues; test cpp (#15960)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/misc/taddr.nim (renamed from tests/js/taddr.nim) | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/tests/js/taddr.nim b/tests/misc/taddr.nim index 9c45621a8..4d0aebc01 100644 --- a/tests/js/taddr.nim +++ b/tests/misc/taddr.nim @@ -1,5 +1,6 @@ discard """ - targets: "c js" + targets: "c cpp js" + matrix: "; -d:release" """ type T = object @@ -79,7 +80,7 @@ someGlobalPtr[] = 10 doAssert(someGlobal == 10) block: - # issue #14576 + # bug #14576 # lots of these used to give: Error: internal error: genAddr: 2 proc byLent[T](a: T): lent T = a proc byPtr[T](a: T): ptr T = a.unsafeAddr @@ -89,24 +90,21 @@ block: let (x,y) = byLent(a) doAssert (x,y) == a - block: - when defined(c) and defined(release): - # bug; pending https://github.com/nim-lang/Nim/issues/14578 - discard - else: - let a = 10 - doAssert byLent(a) == 10 - let a2 = byLent(a) - doAssert a2 == 10 + block: # (with -d:release) bug #14578 + let a = 10 + doAssert byLent(a) == 10 + let a2 = byLent(a) + doAssert a2 == 10 block: - let a = [11,12] - doAssert byLent(a) == [11,12] + when not defined(cpp): # pending bug #15958 + let a = [11,12] + doAssert byLent(a) == [11,12] let a2 = (11,) doAssert byLent(a2) == (11,) block: - when defined(c) and defined(release): + when (defined(c) or defined(cpp)) and defined(release): discard # probably not a bug since optimizer is free to pass by value, and `unsafeAddr` is used else: var a = @[12] @@ -134,6 +132,6 @@ block: bar(a2).inc doAssert a2 == 13 - block: # xxx: bug this doesn't work + block: # pending bug #15959 when false: proc byLent2[T](a: T): lent type(a[0]) = a[0] |