[swift-users] Inconsistent behaviour of forward declarations

Victor Guerra vguerra at gmail.com
Sat Jan 9 16:41:12 CST 2016


hi Dan,

Seems to work when using Swift 2.2 Snapshot from 6th of jan:

Welcome to Apple Swift version 2.2-dev (LLVM 3ebdbb2c7e, Clang f66c5bb67b,
Swift 54dcd16759). Type :help for assistance.
  1> func foo() -> Int { return soon + 1 }
  2. let wat = true
  3. let soon = 1
wat: Bool = true
soon: Int = 1
  4> foo()
$R0: Int = 2

I am able to reproduce the bug on a playground though where swift 2.1 is
used I guess.

On Sat, Jan 9, 2016 at 10:44 PM Dan Cutting via swift-users <
swift-users at swift.org> wrote:

> Hi,
>
> 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.
>
> Thanks,
> Dan
>
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160109/698a4628/attachment.html>


More information about the swift-users mailing list