Open ghost opened 1 year ago
Thank you for submitting an issue! :)
Thanks for submitting this! We will have a look soon!
The following statements, when written and then executed as-is, will result in a crash: "?/switch", "if", "if?", "a:".
Thanks for mentioning this! 🚀
All this probably results from either AST transformations or - less likely - bytecode generation. So, we'll definitely have to deal with this.
Probably related: #1083, #1099
It don't seems to be at parser time...
If I would guess something, I would say it probably can be an issue with Any
as first argument... But, who knows...
@RickBarretto
Well, the pure parser phase (vm/parse) is usually innocuous. I mean it just takes the text/script and converts it into values. That's pretty much the safest part of the whole VM.
Now, the next step is the AST... which converts it into a tree. In that particular case (of if
), there is however something particular: https://github.com/arturo-lang/arturo/blob/master/src/vm/ast.nim#L497
Basically, these are call nodes, but marked as "special" (have a look ^).
What "special" means is that the bytecode generator (vm/eval) handles them... in a special way (= ultra-optimized code generation). And here's where the magic happens:
https://github.com/arturo-lang/arturo/blob/master/src/vm/eval.nim#L418-L464
most of it pointing here: https://github.com/arturo-lang/arturo/blob/master/src/vm/eval.nim#L251
Not the easiest code, by far... but I guess this is the source of the issue. Now. should we deal with that there? Perhaps, the answer would be that we should have dealt with it before: that is, before even reaching the bytecode level; and that location would be the AST, where we actually generate the node. But not sure...
I'll have to investigate! 😉
Exactly that! I tested while
and unless/?
too...
They are having the same problem.
The "problematic" ones are well spotted... and unfortunately all related to the exact same thing... Let's see...
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Closing issue as stale.
Describe the bug The following statements, when written and then executed as-is, will result in a crash: "?/switch", "if", "if?", "a:".
To Reproduce Steps to reproduce the behavior:
Expected behavior For it to return a normal runtime error
Desktop (please complete the following information):
Additional context I've tested all other keywords/statements/functions on the "In a Nutshell" page.