NameError with inner functions and variable shadowing
Closed this issue · 3 comments
rtimush commented
The following code snippet
def foo():
def bar():
result = []
result.append("bar")
return result
result = bar()
print(result)
@webhook_trigger("test")
def test():
foo()fails with
Exception in <file.test.test> line 3:
def bar():
^
NameError: name 'result' is not defined
when triggered.
If I rename the outer variable (in foo()) everything works.
If i remove the append call everything works too.
The same code snippet executed without pyscript works fine.
craigbarratt commented
Whoa - definitely a bug. Thanks for reporting.
rtimush commented
Wow, that was quick!
craigbarratt commented
Thanks for reducing it to a simple example and providing a succinct bug report.