phylanx
phylanx copied to clipboard
Cannot use `return`s with different indention
import numpy as np
from phylanx import Phylanx
@Phylanx
def fx_1(x):
if x:
return True
else:
return False
print(fx_1(2)) # Okay
@Phylanx
def fx_2(x):
if x:
return True
return False
print(fx_2(2)) # NotImplementedError
True
Traceback (most recent call last):
File "test26.py", line 13, in <module>
@Phylanx
File "C:\Repos\phylanx\cmake-build-debug\python\build\lib.win-amd64-3.6\phylanx\ast\transducer.py", line 104, in Phylanx
return __PhylanxDecorator(__phylanx_arg)
File "C:\Repos\phylanx\cmake-build-debug\python\build\lib.win-amd64-3.6\phylanx\ast\transducer.py", line 48, in __init__
self.backend = self.backends_map[self.backend](f, python_ast, kwargs)
File "C:\Repos\phylanx\cmake-build-debug\python\build\lib.win-amd64-3.6\phylanx\ast\physl.py", line 351, in __init__
check_return(self.ir)
File "C:\Repos\phylanx\cmake-build-debug\python\build\lib.win-amd64-3.6\phylanx\ast\physl.py", line 314, in check_return
check_return(ir[1])
File "C:\Repos\phylanx\cmake-build-debug\python\build\lib.win-amd64-3.6\phylanx\ast\physl.py", line 317, in check_return
check_return(s)
File "C:\Repos\phylanx\cmake-build-debug\python\build\lib.win-amd64-3.6\phylanx\ast\physl.py", line 307, in check_return
check_hasreturn(ir[1])
File "C:\Repos\phylanx\cmake-build-debug\python\build\lib.win-amd64-3.6\phylanx\ast\physl.py", line 290, in check_hasreturn
check_noreturn(ir[:-1])
File "C:\Repos\phylanx\cmake-build-debug\python\build\lib.win-amd64-3.6\phylanx\ast\physl.py", line 250, in check_noreturn
check_noreturn(ir[0])
File "C:\Repos\phylanx\cmake-build-debug\python\build\lib.win-amd64-3.6\phylanx\ast\physl.py", line 260, in check_noreturn
check_noreturn(ir[1])
File "C:\Repos\phylanx\cmake-build-debug\python\build\lib.win-amd64-3.6\phylanx\ast\physl.py", line 263, in check_noreturn
check_noreturn(s)
File "C:\Repos\phylanx\cmake-build-debug\python\build\lib.win-amd64-3.6\phylanx\ast\physl.py", line 250, in check_noreturn
check_noreturn(ir[0])
File "C:\Repos\phylanx\cmake-build-debug\python\build\lib.win-amd64-3.6\phylanx\ast\physl.py", line 258, in check_noreturn
raise NotImplementedError(msg)
NotImplementedError: Illegal return: line=16, col=2
@stevenrbrandt do you think this is fixable?
@hkaiser - this looks related to my issue. #889