Skip to content
Merged
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
11 changes: 7 additions & 4 deletions website/lib/website/lua_sandbox.ex
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,16 @@ defmodule Website.LuaSandbox do
end)

try do
bytecode =
# Parse once and reuse the chunk for both the bytecode pane and the
# evaluation itself. A parse failure falls through to eval!/2 on the
# source so the error path still raises the usual CompilerException.
{bytecode, runnable} =
case Lua.parse_chunk(source) do
{:ok, %Lua.Chunk{prototype: proto}} -> disassemble(proto)
_ -> []
{:ok, %Lua.Chunk{prototype: proto} = chunk} -> {disassemble(proto), chunk}
_ -> {[], source}
end

{results, _lua} = Lua.eval!(lua, source)
{results, _lua} = Lua.eval!(lua, runnable)

%{
status: :ok,
Expand Down
Loading