[bugfix] owned closures (#11544)

This commit is contained in:
Andreas Rumpf 2019-06-20 07:40:45 +02:00 • committed by GitHub
commit c65a5d754b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 102 additions and 30 deletions

View file

@ -1,6 +1,6 @@
discard """
cmd: '''nim c --newruntime $file'''
errormsg: "'=' is not available for type <owned Widget>; requires a copy because it's not the last read of ':env.b1()'; another read is done here: tuse_ownedref_after_move.nim(53, 4)"
errormsg: "'=' is not available for type <owned Widget>; requires a copy because it's not the last read of ':envAlt.b1()'; another read is done here: tuse_ownedref_after_move.nim(53, 4)"
line: 49
"""

View file

@ -63,7 +63,7 @@ proc main =
var b = newButton("button", nil)
let u: Button = b
b.onclick = proc () =
b.caption = "clicked!"
u.caption = "clicked!"
w.add b
w.draw()

View file

@ -2,7 +2,7 @@ discard """
cmd: '''nim c --newruntime $file'''
output: '''button
clicked!
3 3 alloc/dealloc pairs: 0'''
6 6 alloc/dealloc pairs: 0'''
"""
import core / allocators
@ -52,8 +52,10 @@ proc main =
var b = newButton("button", nil)
let u = unown b
var clicked = "clicked"
b.onclick = proc () =
b.caption = "clicked!"
clicked.add "!"
u.caption = clicked
w.add b
w.draw()