Closed
Description
I have the following source:
# path: /var/tmp/lp/qux.py
from lpython import Const, i32
foo: Const[i32] = 4
bar: Const[i32] = foo // 2
running it through lpython breaks with the following error:
$ ~/Workspace/lpython/src/bin/lpython /var/tmp/lp/qux.py
semantic error: Arguments do not match for any generic procedure, _lpython_floordiv
--> /var/tmp/lp/qux.py:4:19
|
4 | bar: Const[i32] = foo // 2
| ^^^^^^^^
Note: Please report unclear or confusing messages as bugs at
https://github.com/lcompilers/lpython/issues.
This should be supported, especially since lpython does not complain about multiplication:
# path: /var/tmp/lp/qux.py
from lpython import Const, i32
foo: Const[i32] = 4
bar: Const[i32] = foo * 2
def main() -> None:
print(foo)
print(bar)
main()
$ ~/Workspace/lpython/src/bin/lpython /var/tmp/lp/qux.py
4
8
The following does work, but is ugly:
# path: /var/tmp/lp/qux.py
from lpython import Const, i32
foo: Const[i32] = 4
bar: Const[i32] = i32(foo / 2)
def main() -> None:
print(foo)
print(bar)
main()
$ ~/Workspace/lpython/src/bin/lpython /var/tmp/lp/qux.py
4
2
Note that mod (%
) also does not work:
$ cat /var/tmp/lp/qux.py
# path: /var/tmp/lp/qux.py
from lpython import Const, i32
foo: Const[i32] = 4
bar: Const[i32] = foo % 2
$ ~/Workspace/lpython/src/bin/lpython /var/tmp/lp/qux.py
semantic error: Arguments do not match for any generic procedure, _mod
--> /var/tmp/lp/qux.py:4:19
|
4 | bar: Const[i32] = foo % 2
| ^^^^^^^
Note: Please report unclear or confusing messages as bugs at
https://github.com/lcompilers/lpython/issues.