-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recognition of _
in Initial Condition of for Loop
#1461
Comments
This test reproduces the case where the loop's initialization condition is underscored, as shown below: func TestForLoopIgnoredInital(t *testing.T) {
m := NewMachine("test", nil)
main := FuncD("main", nil, nil, Ss(
A("i", ":=", "0"),
For(
X("_"),
X("i < 5"),
Inc("i"),
),
))
m.RunDeclaration(main)
m.RunMain()
} However, I'm not sure how to test for an empty value in the initial condition. |
It probably shouldn't accept the syntax and have the same behaviour as Go, there's no good reason why the feature should be accepted in Gno. However, I think it's safe to say that if the only statement accepted in this context |
@thehowl I didn't think there was anything wrong with it, but it was vague. Thanks for the feedback |
still an issue we should fix (I think more likely by not accepting all expressions as statements) |
Description
I'm not sure if this is a bug or a feature. In gno, using
_
(underscore, typically for ignoring values) in the initialization of a for loop is accepted. Such usage is not permitted in Go syntax.Note that, just like in standard Go, gno also allows leaving the initialization part of a for loop blank, as shown below:
May related with op_exec
The text was updated successfully, but these errors were encountered: