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

Newruntime: owned procs don't implicitly convert to unowned in `==` #11257

jwollen opened this issue May 14, 2019 · 0 comments


None yet
2 participants
Copy link

commented May 14, 2019

The following fails to compile with --newruntime:

var a: owned proc()

if a != nil:


test.nim(3, 4) Error: '=' is not available for type <owned proc (){.closure.}>; requires a copy because it's not the last read of 'a'; another read is done here: test.nim(4, 3)

Similarly, if there is only one usage, the a will get moved. unowning a explicitly makes it work as expected.

This also leads to unexpected behavior like the following assertion failing:

proc test(a: owned proc()): owned proc() =
  if a == nil:
  return a

assert test(proc() = discard) != nil

(This might be a second issue altogether, since a is consumed twice here. When replacing the first return with discard, the compiler issues an error for the double consumption.)

Araq added a commit that referenced this issue May 23, 2019

@Araq Araq closed this in c7de1a2 May 23, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.