Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lent gives wrong results with -d:release #14578

Closed
timotheecour opened this issue Jun 6, 2020 · 2 comments
Closed

lent gives wrong results with -d:release #14578

timotheecour opened this issue Jun 6, 2020 · 2 comments

Comments

@timotheecour
Copy link
Member

lent gives wrong results with -d:release

Example

proc byLent[T](a: T): lent T = a
block:
  let a = 10
  let a2 = byLent(a)
  doAssert a2 == a2, $a2 # ok
  doAssert byLent(a) == a, $byLent(a) # bug

Current Output

nim c -r -d:release -f t10897.nim
Error: unhandled exception: /Users/timothee/git_clone/nim/timn/tests/nim/all/t10897.nim(9, 12) `byLent(a) == a` 140732898775544 [AssertionDefect]

looks like it returns the address instead

Expected Output

works

Additional Information

timotheecour added a commit to timotheecour/Nim that referenced this issue Jun 6, 2020
Araq pushed a commit that referenced this issue Jun 6, 2020
@cooldome
Copy link
Member

cooldome commented Jun 8, 2020

The issue here is the same as #14420

proc byLent[T](a: T): lent T = a

byLent contains stmtListExpr and stmtListExpr involves temporary object in backend

@timotheecour
Copy link
Member Author

timotheecour commented Jun 9, 2020

@cooldome if what you say were true, the same workaround would apply here, but this is not the case:
result = a still gives AssertionDefect

at the very least there is some different here (even if, perhaps, there is a common root cause)

Araq added a commit that referenced this issue Jun 9, 2020
@Araq Araq closed this as completed in b3029ba Jun 9, 2020
timotheecour added a commit to timotheecour/Nim that referenced this issue Nov 13, 2020
narimiran pushed a commit that referenced this issue Nov 16, 2020
PMunch pushed a commit to PMunch/Nim that referenced this issue Jan 6, 2021
mildred pushed a commit to mildred/Nim that referenced this issue Jan 11, 2021
irdassis pushed a commit to irdassis/Nim that referenced this issue Mar 16, 2021
ardek66 pushed a commit to ardek66/Nim that referenced this issue Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants