This commit is contained in:
parent
562c6275b8
commit
1a47fc2291
1 changed files with 13 additions and 15 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
targets: "c js"
|
targets: "c cpp js"
|
||||||
|
matrix: "; -d:release"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
type T = object
|
type T = object
|
||||||
|
|
@ -79,7 +80,7 @@ someGlobalPtr[] = 10
|
||||||
doAssert(someGlobal == 10)
|
doAssert(someGlobal == 10)
|
||||||
|
|
||||||
block:
|
block:
|
||||||
# issue #14576
|
# bug #14576
|
||||||
# lots of these used to give: Error: internal error: genAddr: 2
|
# lots of these used to give: Error: internal error: genAddr: 2
|
||||||
proc byLent[T](a: T): lent T = a
|
proc byLent[T](a: T): lent T = a
|
||||||
proc byPtr[T](a: T): ptr T = a.unsafeAddr
|
proc byPtr[T](a: T): ptr T = a.unsafeAddr
|
||||||
|
|
@ -89,24 +90,21 @@ block:
|
||||||
let (x,y) = byLent(a)
|
let (x,y) = byLent(a)
|
||||||
doAssert (x,y) == a
|
doAssert (x,y) == a
|
||||||
|
|
||||||
block:
|
block: # (with -d:release) bug #14578
|
||||||
when defined(c) and defined(release):
|
|
||||||
# bug; pending https://github.com/nim-lang/Nim/issues/14578
|
|
||||||
discard
|
|
||||||
else:
|
|
||||||
let a = 10
|
let a = 10
|
||||||
doAssert byLent(a) == 10
|
doAssert byLent(a) == 10
|
||||||
let a2 = byLent(a)
|
let a2 = byLent(a)
|
||||||
doAssert a2 == 10
|
doAssert a2 == 10
|
||||||
|
|
||||||
block:
|
block:
|
||||||
|
when not defined(cpp): # pending bug #15958
|
||||||
let a = [11,12]
|
let a = [11,12]
|
||||||
doAssert byLent(a) == [11,12]
|
doAssert byLent(a) == [11,12]
|
||||||
let a2 = (11,)
|
let a2 = (11,)
|
||||||
doAssert byLent(a2) == (11,)
|
doAssert byLent(a2) == (11,)
|
||||||
|
|
||||||
block:
|
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
|
discard # probably not a bug since optimizer is free to pass by value, and `unsafeAddr` is used
|
||||||
else:
|
else:
|
||||||
var a = @[12]
|
var a = @[12]
|
||||||
|
|
@ -134,6 +132,6 @@ block:
|
||||||
bar(a2).inc
|
bar(a2).inc
|
||||||
doAssert a2 == 13
|
doAssert a2 == 13
|
||||||
|
|
||||||
block: # xxx: bug this doesn't work
|
block: # pending bug #15959
|
||||||
when false:
|
when false:
|
||||||
proc byLent2[T](a: T): lent type(a[0]) = a[0]
|
proc byLent2[T](a: T): lent type(a[0]) = a[0]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue