[swift-evolution] Inconsistencies in recursive types

rintaro ishizaki fs.output at gmail.com
Mon Mar 13 09:56:37 CDT 2017


final class First {
    let item: First
    init(item: First) {
        self.item = item
    }
}

extension First {
    convenience init() {
        self.init(item: self)
    }
}

let a = First()

I'm actually a bit surprised that this compiles.
This should be diagnosed as: "error: 'self' used before self.init call" I
think.


2017-03-13 23:42 GMT+09:00 Dimitri Racordon <Dimitri.Racordon at unige.ch>:

> But then!
>
> The following still shouldn’t compile:
>
> final class First {
>     let item: First
>     init(item: First) {
>         self.item = item
>     }
> }
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170313/e7f674a1/attachment.html>


More information about the swift-evolution mailing list