You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
whentrue:
procbyLent[T](a: T): lent T = a
let b =@[21,23]
doAssertbyLent(b).unsafeAddr == b.unsafeAddr # BUG: fails at RT: Error: Error: unhandled exception:let r =new(float)
r[] =10.0doAssertbyLent(r)[] ==10.0# BUG: fails at RT: Error: Error: unhandled exception:
Current Output
assert fails
Expected Output
works, as in c backend
Example 2
more complex, shows what works, what doesn't at once thanks to check:
nim r -b:js -d:nodejs main
whentrue:
import std/unittest
templatemain2=procbyLent[T](a: T): lent T = a
# proc byLent[T](a: T): lent T = result=alet a = [11,12]
let ss = {1, 2, 3, 5}
doAssertbyLent(a) == [11,12]
doAssertbyLent(a).unsafeAddr == a.unsafeAddr
doAssertbyLent(ss) == {1, 2, 3, 5}
doAssertbyLent(ss).unsafeAddr == ss.unsafeAddr
let b =@[21,23]
doAssertbyLent(b) ==@[21,23]
doAssert b.unsafeAddr == b.unsafeAddr
checkbyLent(b).unsafeAddr == b.unsafeAddr # BUG: fails at RT: Error: Error: unhandled exception:let r =new(float)
r[] =10.0checkbyLent(r)[] ==10.0# BUG: fails at RT: Error: Error: unhandled exception:whennotdefined(js): # bug https://github.com/timotheecour/Nim/issues/372let p =create(float)
p[] =20.0doAssertbyLent(p)[] ==20.0procbyLent2[T](a: openarray[T]): lent T = a[0]
doAssertbyLent2(a) ==11doAssertbyLent2(a).unsafeAddr == a[0].unsafeAddr
doAssertbyLent2(b) ==21doAssertbyLent2(b).unsafeAddr == b[0].unsafeAddr
procbyLent3[T](a: varargs[T]): lent T = a[1]
let
x =10
y =20
z =30doAssertbyLent3(x, y, z) ==20main2()
js: lent doesn't work for seq, ptr
Example 1
Current Output
assert fails
Expected Output
works, as in c backend
Example 2
more complex, shows what works, what doesn't at once thanks to
check
:nim r -b:js -d:nodejs main
Additional Information
lent
doesn't work in iterators with tuple destructuring #14574The text was updated successfully, but these errors were encountered: