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
If the goto inst2 immediately before the inst2: label is removed the problem disappears, even though that goto is unreachable and therefore never executed.
Sorry for the verbosity of the sample, the code is automatically generated.
The text was updated successfully, but these errors were encountered:
I managed to isolate this issue into a smaller snippet for easier debugging:
package main
import"log"funcmain() {
print(test()) // Go prints true, Yaegi false
}
functest() bool {
iftrue {
goto label
}
goto label
label:
log.Println("Go continues here")
returntruelog.Println("Yaegi goes straight to this return (this line is never printed)")
returnfalse
}
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.
Fixestraefik#1354.
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.
* Fix continue label, detect invalid labels for break and continue
* fix multiple goto, break, continue to the same label
Fixes#1354.
The following program
sample.go
triggers an unexpected resultExpected result
[0] 2 true
Got
[] 0 false
Yaegi Version
14acf61
Additional Notes
If the
goto inst2
immediately before theinst2:
label is removed the problem disappears, even though thatgoto
is unreachable and therefore never executed.Sorry for the verbosity of the sample, the code is automatically generated.
The text was updated successfully, but these errors were encountered: