This forum is a read-only archive. Posting, replying and signing in are disabled.

Abstract tree parser has return value of `NoneType`

cc9one
  File "/usr/local/lib/python3.9/site-packages/pyteal/compiler/compiler.py", line 211, in compileTeal
    compileSubroutine(
  File "/usr/local/lib/python3.9/site-packages/pyteal/compiler/compiler.py", line 124, in compileSubroutine
    if not ast.has_return():
AttributeError: 'NoneType' object has no attribute 'has_return'

When I receive this error, does this simply mean there’s incorrect syntax inside my teal program? How can I debug most effectively in this situation?

✔ Solved by fabrice in post #2
fabrice

This is most likely an issue with your PyTEAL program indeed.
First, upgrade pyteal just to be sure:

python3 -m pip install pyteal --upgrade

Then it looks like the issue is inside one of your subroutines.
My wild guess is that one of your subroutine is not returning (using the Python return keyword) a PyTEAL expression.

Compare your code with:
https://pyteal.readthedocs.io/en/stable/control_structures.htm

If you don’t find the error yourself, remove as much code as possible while still triggering the above error and post the resulting code in this forum. You may rename functions and variables if there is anything confidential.

✔ Solution
cc9one

Thank you, and that was a great guess. I was using Return(Int(1)) instead of the Python return Int(1) for my approval_program() function