Open staycoolcall911 opened 2 years ago
@yoav-steinberg , I understand that we want to support function forward deceleration, but I am not so sure about this example.
Can you explain why we want to support this?
In this case it's a variable forward declarations (not a function):
x
is defined in the outer scope after the functions f
is defined. So, currently, the compiler will complain that x
is an undefined symbol when accessing it in f
even though it's actually defined - just in the outer scope.
Hi,
This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!
Hi,
This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!
Here's another snippet showing the same thing which might be clearer:
class Foo {
my_method() {
x = 1;
//^ Symbol "x" used before being defined
}
}
let x = 2;
The exact same code in TypeScript works, because TS doesn't care that x
is defined after Foo
.
This, for example, should be supported:
This was split from https://github.com/winglang/wing/issues/25