JoeStrout / miniscript

source code of both C# and C++ implementations of the MiniScript scripting language
MIT License
275 stars 64 forks source link

[C++] command-line MiniScript aborts on extra "end function" #101

Open JoeStrout opened 10 months ago

JoeStrout commented 10 months ago

In command-line MiniScript, if you type end function at the prompt without first starting a function, it aborts (exit code 134). It should instead just print an error and continue.

Note that end if and end while work correctly; only end function shows this problem.

JoeStrout commented 10 months ago

Note that this might be fixed incidentally if we implement suggestion #100.

Armen138 commented 1 month ago

I came across this issue when testing how accurately Miniscript can tell me which line an error occurred on. I expected an error for "unknown function fution" or similar on line 1 of the code below, but instead it crashes the interpreter (presumably because the end function is now "extra")

bread = fution(x) b = "butter" + x end function

JoeStrout commented 1 month ago

So it does! (In the C++ implementation; not in the C# one.) Good catch.