[swift-users] Inconsistent behaviour of forward declarations

Dan Cutting dan at cutting.io
Sat Jan 9 15:44:06 CST 2016


This code builds and runs fine:

func foo() -> Int { return soon + 1 }
let soon = 1

But the following code has a compilation error (“Use of unresolved identifier ‘soon’”):

func foo() -> Int { return soon + 1 }
let wat = true
let soon = 1

Any ideas why? Is this a bug in Swift or intended behaviour?

I might expect either or neither of these to work, but to have one work and one fail is perplexing.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160109/326ee6d5/attachment.html>

More information about the swift-users mailing list