Skip to content
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
4 changes: 2 additions & 2 deletions src/model/project/project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ end
function Project:load_file(filename)
local rok, content = self:readfile(filename)
if rok then
return codeload(content)
return codeload(content, nil, filename)
end
end

Expand Down Expand Up @@ -387,7 +387,7 @@ function ProjectService:run(name, env)
if type(code) ~= 'string' then
return nil, FS.messages.unreadable(ProjectService.MAIN), p_path
end
local content, c_err = codeload(code, env)
local content, c_err = codeload(code, env, ProjectService.MAIN)
return content, c_err, p_path
end
return nil, err
Expand Down
6 changes: 4 additions & 2 deletions src/util/lua.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ end

--- @param code string
--- @param env table?
--- @param name string?
--- @return function? chunk
--- @return string? err
local codeload = function(code, env)
local codeload = function(code, env, name)
if type(code) ~= 'string' then
return nil, ('code must be a string (got %s)'):format(type(code))
end
local f, err = loadstring(code)
local chunk = name and ('@' .. name) or nil
local f, err = loadstring(code, chunk)

if not f then return nil, err end
if env then
Expand Down
Loading