tokay icon indicating copy to clipboard operation
tokay copied to clipboard

`1(2+3)`: The value Int(1) is generally not callable! - hint for user?

Open phorward opened this issue 2 years ago • 1 comments

The input 1(2+3) should not be parsed as a function call.

$ cargo run -- -d
Tokay 0.6.4
>>> 1(2+3)
main [start 1:1, end 1:7]
 call [start 1:1, end 1:7]
  value_integer [start 1:1, end 1:2] => 1
  callarg [start 1:3, end 1:6]
   op_binary_add [start 1:3, end 1:6]
    value_integer [start 1:3, end 1:4] => 2
    value_integer [start 1:5, end 1:6] => 3
thread 'main' panicked at 'not yet implemented: The value Int(1) is generally not callable!', src/compiler/iml/imlop.rs:135:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

phorward avatar Aug 07 '23 21:08 phorward

This is not considered as a bug anymore.

It is equal when calling in Python:

>>> 1(2+3)
<stdin>:1: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' object is not callable
>>> 1,2
(1, 2)

A good solution would be to provide an adequate warning as shown above.

phorward avatar Aug 15 '23 09:08 phorward