Skip to content

Commit

Permalink
fix: impl empty statement exec (#3252)
Browse files Browse the repository at this point in the history
Implement empty statement in the runtime exec.

Closes #3202
  • Loading branch information
petar-dambovaliev authored Dec 4, 2024
1 parent 78f0e20 commit 6585cad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gnovm/pkg/gnolang/go2gno.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ func Go2Gno(fs *token.FileSet, gon ast.Node) (n Node) {
PkgName: pkgName,
Decls: decls,
}
case *ast.EmptyStmt:
return &EmptyStmt{}
default:
panic(fmt.Sprintf("unknown Go type %v: %s\n",
reflect.TypeOf(gon),
Expand Down
1 change: 1 addition & 0 deletions gnovm/pkg/gnolang/op_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,7 @@ EXEC_SWITCH:
}
m.PushOp(OpBody)
m.PushStmt(b.GetBodyStmt())
case *EmptyStmt:
default:
panic(fmt.Sprintf("unexpected statement %#v", s))
}
Expand Down
10 changes: 10 additions & 0 deletions gnovm/tests/files/goto_empty_stmt.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package main

func main() {
println("Hi")
goto done
done:
}

// Output:
// Hi

0 comments on commit 6585cad

Please sign in to comment.