phylanx icon indicating copy to clipboard operation
phylanx copied to clipboard

Cannot use `return`s with different indention

Open taless474 opened this issue 6 years ago • 2 comments

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

taless474 avatar Mar 20 '19 15:03 taless474

@stevenrbrandt do you think this is fixable?

hkaiser avatar Mar 20 '19 22:03 hkaiser

@hkaiser - this looks related to my issue. #889

ct-clmsn avatar Mar 20 '19 23:03 ct-clmsn