uiua-lang / uiua

A stack-based array programming language
https://www.uiua.org
MIT License
1.63k stars 116 forks source link

Array Macros cause unwanted execution #497

Closed Exund closed 6 months ago

Exund commented 6 months ago

While using Array Macros there are situations where the previous code is executed twice or executed when it shouldn't.

I'm using the Rayua bindings for Raylib for a project and when using any sort of array macro the the code above the macro call is executed twice when started normally and also execute when the LSP is called, crashing it in the process.

Taking the example in rayua, adding the following snippet at the end and executing it (via uiua example.ua) will start the program normally but the window will re-open when closed.

Def! ←^ ∘
Def!0

The window will also open when opening the file in VS Code with the Uiua extension installed and crash the LSP when closed.

This only seems to happen when using the FFI (simply executing pure Uiua code doesn't output it twice)

kaikalii commented 6 months ago

I'm investigating this now. A much simpler example that doesn't require rayua is

&fwa $"_.ua" tag ""
F! ←^ ∘
F!

This creates 2 files.