Skip to content

Commit

Permalink
Improved trace (#371)
Browse files Browse the repository at this point in the history
* overriding trace on library defined exprs
  • Loading branch information
barnjamin committed May 31, 2022
1 parent 9646a1a commit db381c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pyteal/ast/subroutine.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,4 +427,6 @@ def var_n_loaded(param):
bodyOps = [var.slot.store() for var in argumentVars[::-1]]
bodyOps.append(subroutineBody)

return SubroutineDeclaration(subroutine, Seq(bodyOps))
sd = SubroutineDeclaration(subroutine, Seq(bodyOps))
sd.trace = subroutineBody.trace
return sd
10 changes: 8 additions & 2 deletions pyteal/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,15 @@ def compileSubroutine(

if not ast.has_return():
if ast.type_of() == TealType.none:
ast = Seq([ast, Return()])
ret_expr = Return()
ret_expr.trace = ast.trace
seq_expr = Seq([ast, ret_expr])
seq_expr.trace = ret_expr.trace
ast = seq_expr
else:
ast = Return(ast)
ret_expr = Return(ast)
ret_expr.trace = ast.trace
ast = ret_expr

options.setSubroutine(currentSubroutine)
start, end = ast.__teal__(options)
Expand Down

0 comments on commit db381c4

Please sign in to comment.