1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: fix a goto error

This commit is contained in:
Kris Cherven 2020-05-11 17:49:08 -04:00 committed by GitHub
parent e6bc18b21b
commit d359a7aefb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -626,7 +626,7 @@ fn (mut g Gen) stmt(node ast.Stmt) {
g.go_stmt(it)
}
ast.GotoLabel {
g.writeln('$it.name:')
g.writeln('$it.name: {}')
}
ast.GotoStmt {
g.writeln('goto $it.name;')

10
vlib/v/tests/goto_test.v Normal file
View File

@ -0,0 +1,10 @@
fn test_goto() {
mut i := 0
a: b := 1
_ = b
i++
if i < 3 {
goto a
}
assert i == 3
}