tokay-lang / tokay

Tokay is a programming language designed for ad-hoc parsing, inspired by awk.
https://tokay.dev
MIT License
236 stars 7 forks source link

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

Open phorward opened 11 months ago

phorward commented 11 months ago

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 commented 11 months ago

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.