Skip to content

Commit

Permalink
workaround nim-lang#14578
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Jun 6, 2020
1 parent e626e7c commit 3efb129
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions tests/js/taddr.nim
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ block:
doAssert (x,y) == a

block:
let a = 10
doAssert byLent(a) == 10
let a2 = byLent(a)
doAssert a2 == 10
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:
let a = [11,12]
Expand All @@ -102,12 +106,15 @@ block:
doAssert byLent(a2) == (11,)

block:
var a = @[12]
doAssert byPtr(a)[] == @[12]
let a2 = [13]
doAssert byPtr(a2)[] == [13]
let a3 = 14
doAssert byPtr(a3)[] == 14
when defined(c) and defined(release):
discard # probably not a bug since optimizer is free to pass by value, and `unsafeAddr` is used
else:
var a = @[12]
doAssert byPtr(a)[] == @[12]
let a2 = [13]
doAssert byPtr(a2)[] == [13]
let a3 = 14
doAssert byPtr(a3)[] == 14

block:
proc byLent2[T](a: seq[T]): lent T = a[1]
Expand Down

0 comments on commit 3efb129

Please sign in to comment.