<div dir="ltr">The actual death is happening when setting the parent:<div><br></div><div><div>do {</div><div> let frank = Person(name: "Frank")</div><div> print("frank\(frank)")</div><div> let lisa = Person(name: "Lisa")</div><div> frank.parent = lisa // Dies here with EXC_BAD_ACCESS</div></div><div><br></div><div>You can click the eye to get a stack trace. (not included here because of rdar://27263098 - can't get a copyable stack trace from a hard error in playgrounds). </div><div><br></div><div>My bet it's something playground related - about 9 frames down in the stack trace has a reference to the Playground Logger doing the Mirror thing.</div><div><br></div><div>Putting your code in to a standalone swift executable lets it work.</div><div><br></div><div>Cheers,</div><div>++md</div><div><br></div><div> </div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jul 9, 2016 at 10:18 AM, Ray Fix via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi!<br>
<br>
When I make a variable weak in Xcode 8 (both beta 1 and beta 2) I get a access violation. I think this is a bug, but want to make sure I am not missing something.<br>
<br>
Best regards,<br>
Ray<br>
<br>
//: Playground - noun: a place where people can play<br>
<br>
import UIKit<br>
<br>
class Person: CustomStringConvertible {<br>
var name: String<br>
weak var parent: Person? /// If I remove weak, no crash in Xcode 8 beta 2, but leaks<br>
var children: [Person] = [] {<br>
didSet {<br>
children.forEach { $0.parent = self }<br>
}<br>
}<br>
<br>
init(name: String) {<br>
<a href="http://self.name" rel="noreferrer" target="_blank">self.name</a> = name<br>
print("initialized \(name)")<br>
}<br>
deinit {<br>
print("deinit \(name)")<br>
}<br>
var description: String {<br>
return name<br>
}<br>
}<br>
<br>
do {<br>
let frank = Person(name: "Frank")<br>
let lisa = Person(name: "Lisa")<br>
frank.children = [lisa] /// KABOOM!<br>
}<br>
<br>
_______________________________________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
</blockquote></div><br></div>