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

`print(Int ast("int"))` causes `assertion failed: n <= tos - self.frame0().capture_start` #107

Closed phorward closed 7 months ago

phorward commented 1 year ago

The call

print(Int ast("int"))  # causes assertion failure

causes an assertion failure

>>> print(Int ast("int"))
main [start 1:1, end 1:22]
 call [start 1:1, end 1:22]
  identifier [start 1:1, end 1:6] => "print"
  callarg [start 1:7, end 1:11]
   identifier [start 1:7, end 1:10] => "Int"
  callarg [start 1:11, end 1:21]
   call [start 1:11, end 1:21]
    identifier [start 1:11, end 1:14] => "ast"
    callarg [start 1:15, end 1:20]
     value_string [start 1:15, end 1:20] => "int"
thread 'main' panicked at 'assertion failed: n <= tos - self.frame0().capture_start', src/vm/context.rs:429:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

because the stack is modified by the ast() call during the print() call. This behavior is expected, but the assertion should be avoided. The problem occurs with any function.

When creating another inline sequence as single parameter, it works correctly.

print((Int ast("int")))
phorward commented 1 year ago

This is a syntax issue. General advise for this issue is to allow for lists only as parameters, so that print(Int ast("int")) becomes invalid, and print((Int ast("int"))) is the only valid work-around. It will be resolvable by #10 when the List generic builtin was made available.

phorward commented 9 months ago

This partly belongs to #100.

phorward commented 7 months ago

Seems to be fixes as #100 was merged :+1:

shot-2023-12-22_15-11-25