Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: compiler error when using MENU with no arguments #469

Merged
merged 1 commit into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1690,15 +1690,15 @@ function handleFn_MEAN(exp, procState)
end

function handleFn_MENU(exp, procState)
for i, arg in ipairs(exp.args) do
procState:emitExpression(arg, Callables.MENU.args[i])
end
if #exp.args == 0 then
procState:emit("BB", opcodes.CallFunction, fncodes.Menu)
else
if exp.args and #exp.args > 0 then
for i, arg in ipairs(exp.args) do
procState:emitExpression(arg, Callables.MENU.args[i])
end
procState:emit("BB", opcodes.CallFunction, fncodes.MenuWithMemory)
procState:popStack(#exp.args)
else
procState:emit("BB", opcodes.CallFunction, fncodes.Menu)
end
procState:popStack(#exp.args)
procState:pushStack(Int)
end

Expand Down
5 changes: 5 additions & 0 deletions src/tcompiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,11 @@ checkCode('mPOPUP(1, 2, 0, "a", 0)', {
op"DropInt",
})

checkCode('MENU', {
fn"Menu",
op"DropInt",
})

checkSyntaxError("ALERT()", "1: Zero-argument calls should not have ()")

checkSyntaxError("alert(a$, b$, c$, d$, e$, f$)", "1: Wrong number of arguments to ALERT")
Expand Down
Loading