[swift-evolution] Inconsistencies in recursive types

John McCall rjmccall at apple.com
Mon Mar 13 11:57:19 CDT 2017


> On Mar 13, 2017, at 10:56 AM, rintaro ishizaki via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 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.

Yes, it should.

John.

> 
> 
> 2017-03-13 23:42 GMT+09:00 Dimitri Racordon <Dimitri.Racordon at unige.ch <mailto: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
>     }
> }
> 
> 
> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170313/271f1ec3/attachment.html>


More information about the swift-evolution mailing list