Skip to content

Commit

Permalink
fix: compiler error when using MENU with no arguments (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsci authored Dec 7, 2024
1 parent 8ab5005 commit e4e08f8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
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

0 comments on commit e4e08f8

Please sign in to comment.