-
Notifications
You must be signed in to change notification settings - Fork 358
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
interp: fix the behaviour of goto, continue and break #1392
Conversation
The logic of goto was false due to mixing break label and goto label, despite being opposite. In case of break, jump to node (the exit point) instead of node.start. Also always define label symbols before their use is parsed. Fixes traefik#1354.
Are you aware that even after this PR, it seems that
the behavior of incontinue() is not the same with Go and with Yaegi. |
interp/cfg.go
Outdated
err = n.cfgErrorf("invalid continue label %s", n.child[0].ident) | ||
break | ||
} | ||
for _, c := range n.sym.from { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remark as above.
interp/cfg.go
Outdated
if n.sym.node == nil { | ||
break | ||
} | ||
for _, c := range n.sym.from { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same remark as in break and continue.
interp/cfg.go
Outdated
gotoLabel(n.sym) | ||
for _, c := range n.sym.from { | ||
if c.kind == gotoStmt { | ||
c.tnext = n.start |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are not in a forward case, it seems useless to do that, since the code in the goto case (L887) will overwrite c.tnext.
If we are in the forward case, we are overwriting c.tnext here. Is that what we want to do?
The logic of goto was false due to mixing break label and goto
label, despite being opposite. In case of break, jump to node (the
exit point) instead of node.start. Also always define label symbols
before their use is parsed.
Fixes #1354.