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
At least as currently implemented, Dada distinguishes declaring a new variable (p = expr) from re-assigning the value of an existing variable (p := expr). This can easily be confusing. Consider this program:
fn main() {
n = 0
while n < 3 {
n = n + 1
}
}
This program will never terminate because the n = n + 1 declares a new variable.
We should either get rid of the idea of :=or have a lint that detects when you shadow a live variable (variable may be accessed again later on). Therefore the above code would warn. This code would not:
async fn main() {
n = 0
print(n).await
n = 1
print(n).await
}
and neither would this
async fn main() {
n = 0
print(n).await
if n > 0 {
n = 5
print(n).await
}
n := 1 # ignores current value of `n`
print(n).await
}
but this would:
async fn main() {
n = 0
print(n).await
if n > 0 {
n = 5
print(n).await
}
n += 1 # uses current value of `n`
print(n).await
}
I would do this analysis on the validated tree.
The text was updated successfully, but these errors were encountered:
At least as currently implemented, Dada distinguishes declaring a new variable (
p = expr
) from re-assigning the value of an existing variable (p := expr
). This can easily be confusing. Consider this program:This program will never terminate because the
n = n + 1
declares a new variable.We should either get rid of the idea of
:=
or have a lint that detects when you shadow a live variable (variable may be accessed again later on). Therefore the above code would warn. This code would not:and neither would this
but this would:
I would do this analysis on the validated tree.
The text was updated successfully, but these errors were encountered: