HashLDash/Photon

variable in a function

EdsonBotton opened this issue · 3 comments

float pi = 3.14
def radian(float grau):
return grau * (pi / 180)
print(radian(45))


> ...
> >>> print(radian(45))
> 0.7850000000000001
> >>>
> Traceback (most recent call last):
>   File "C:\Photon-main\core\photon.py", line 50, in <module>
>     first = sys.argv[1]
> IndexError: list index out of range
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
>   File "C:\Photon-main\core\photon.py", line 53, in <module>
>     Interpreter(standardLibs = os.path.join(PHOTON_INSTALL_PATH, 'libs/'), debug = DEBUG).run()
>   File "C:\Photon-main\core\interpreter.py", line 173, in run
>     self.engine.process(struct)
>   File "C:\Photon-main\core\engines\pyEngine.py", line 14, in process
>     self.transpiler.process(token)
>   File "C:\Photon-main\core\transpilers\baseTranspiler.py", line 86, in process
>     self.instructions[token['opcode']](token)
> TypeError: 'NoneType' object is not subscriptable

The problem is that these Variables in target C are not globally available when transpilled. Thinking on a solution that will scale well.


> ...
> >>> print(radian(45))
> 0.7850000000000001
> >>>
> Traceback (most recent call last):
>   File "C:\Photon-main\core\photon.py", line 50, in <module>
>     first = sys.argv[1]
> IndexError: list index out of range
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
>   File "C:\Photon-main\core\photon.py", line 53, in <module>
>     Interpreter(standardLibs = os.path.join(PHOTON_INSTALL_PATH, 'libs/'), debug = DEBUG).run()
>   File "C:\Photon-main\core\interpreter.py", line 173, in run
>     self.engine.process(struct)
>   File "C:\Photon-main\core\engines\pyEngine.py", line 14, in process
>     self.transpiler.process(token)
>   File "C:\Photon-main\core\transpilers\baseTranspiler.py", line 86, in process
>     self.instructions[token['opcode']](token)
> TypeError: 'NoneType' object is not subscriptable

This is another issue. Empty cells in the interpreter cause a crash.