No worries, if I understand you correctly, you're saying essentially the following.
Since this compiles (and runs, printing bar)
func foo() {
{
bar()
}()
if Bool.random() { return }
func bar() {
print("bar")
}
}
foo()
then why shouldn't this:
func foo() {
{
bar()
}()
return
func bar() {
print("bar")
}
}
foo()
(which crashes the compiler)
or this:
func foo() {
bar() // ERROR: Use of local variable 'bar' before its declaration
return
func bar() {
print("bar")
}
}
foo()
I think this error is inconsistent given that the first program compiles and runs.
I've filed SR-12243 for this inconsistent behavior and the related compiler crash.