You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-2727 Script mode rules for top-level bindings are confusing and broken
Issue Description:
The following code snippet successful compiles and runs without infinite looping.
funcfoo() -> Int {
returnx
}
letx = foo()
It seems that `x` is uninitialized when returned from `foo` so `x` is assigned to an uninitiated value. In this example, printing `x` will output `0`, but if we change `Int` to a more complicated type like `[Int]`, printing will crash the program for obvious reasons.
I would expect this code to not compile since `x` is declared after `foo`. If it is intended to compile, then I think it ought to infinite loop. I definitely think the former behavior is much more intuitive than the latter.
The text was updated successfully, but these errors were encountered:
Environment
Swift 3
Additional Detail from JIRA
md5: 61eabde96dfa157dcf6729f925cf4571
duplicates:
Issue Description:
The following code snippet successful compiles and runs without infinite looping.
It seems that `x` is uninitialized when returned from `foo` so `x` is assigned to an uninitiated value. In this example, printing `x` will output `0`, but if we change `Int` to a more complicated type like `[Int]`, printing will crash the program for obvious reasons.
I would expect this code to not compile since `x` is declared after `foo`. If it is intended to compile, then I think it ought to infinite loop. I definitely think the former behavior is much more intuitive than the latter.
The text was updated successfully, but these errors were encountered: