mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 23:02:27 +00:00
compiler: do not emit RET twice for nested BlockStmt
When function finishes with `*ast.BlockStmt`, last return in that block should be looked for.
This commit is contained in:
parent
6445e4be91
commit
1f238ce6fd
2 changed files with 11 additions and 5 deletions
|
@ -440,7 +440,7 @@ func (c *codegen) convertFuncDecl(file ast.Node, decl *ast.FuncDecl, pkg *types.
|
|||
// If we have reached the end of the function without encountering `return` statement,
|
||||
// we should clean alt.stack manually.
|
||||
// This can be the case with void and named-return functions.
|
||||
if !isInit && !isDeploy && !lastStmtIsReturn(decl) {
|
||||
if !isInit && !isDeploy && !lastStmtIsReturn(decl.Body) {
|
||||
c.saveSequencePoint(decl.Body)
|
||||
emit.Opcodes(c.prog.BinWriter, opcode.RET)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue