Skip to content

Commit

Permalink
ruleguard/quasigo: emit implicit return stmt (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
quasilyte authored Nov 18, 2021
1 parent 2d7358b commit 05e5d0c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ruleguard/quasigo/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ func (cl *compiler) compileFunc(fn *ast.FuncDecl) *Func {
}

cl.compileStmt(fn.Body)
if cl.retType == voidType {
cl.emit(opReturn)
}

compiled := &Func{
code: cl.code,
constants: cl.constants,
Expand Down
1 change: 0 additions & 1 deletion ruleguard/quasigo/testdata/voidfunc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ func main() {
println(1)
x := "var"
println(x)
return
}

0 comments on commit 05e5d0c

Please sign in to comment.