> On Sep 21, 2016, at 2:22 PM, Jens Persson via swift-users 
> <swift-users@swift.org> wrote:
> // This little Swift program compiles (and runs) fine:
> func foo() -> Int { return a }
> let a = 1
> let b = 2
> print(foo())
> But if `foo()` returns `b` instead of `a`, I get this compile time error:
> "Use of unresolved identifier `b`"

This looks like a bug to me (cc-ing Jordan, who's thought about global scoping 
issues more than me). In "script mode", it shouldn't be possible to refer to a 
variable before its initialization is executed. However, the way this is 
currently modeled is…problematic, to say the least, among other reasons because 
script globals are still visible to "library" files in the same module.

swift-users mailing list

Reply via email to