mirror of
https://github.com/hanzoai/yaegi.git
synced 2026-10-01 00:49:47 +00:00
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.
22 lines
320 B
Go
22 lines
320 B
Go
package main
|
|
|
|
func main() {
|
|
println(test()) // Go prints true, Yaegi false
|
|
}
|
|
|
|
func test() bool {
|
|
if true {
|
|
goto label
|
|
}
|
|
goto label
|
|
label:
|
|
println("Go continues here")
|
|
return true
|
|
println("Yaegi goes straight to this return (this line is never printed)")
|
|
return false
|
|
}
|
|
|
|
// Output:
|
|
// Go continues here
|
|
// true
|