Redefining nested function from other function overrides original nested function
BPYap opened this issue · comments
Consider the following codes saved in Test.py
:
def func():
def nested_func():
print("Hello World from func")
nested_func()
def func2():
def nested_func():
print("Hello World from func2")
nested_func()
func()
func2()
Running the codes in voc results in following outputs:
Hello World from func2
Hello World from func2
However, the intended outputs from Python 3.6 are:
Hello World from func
Hello World from func2
Upon investigation, nested_function
is overwritten during transpilation as voc generates new class file for nested function:
Compiling Test.py ...
Writing .\python\Test.class ...
Writing .\python\Test\nested_func.class ...
Writing .\python\Test\nested_func.class ...
The last write overwrites the first nested function.
One potential way to solve it would be generating class files for each nested function marked with enclosing function's name and instruct voc to look for the correct class file when invoking nested function.