From 1d9de34e79585192b4d7c9988d7d754cf45ffe02 Mon Sep 17 00:00:00 2001 From: Vadim1987 Date: Thu, 25 Jun 2026 21:31:23 +0200 Subject: [PATCH 1/4] fix(lua): return error on non-string code instead of crashing --- src/util/lua.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/lua.lua b/src/util/lua.lua index 299ff7a4..b412cef2 100644 --- a/src/util/lua.lua +++ b/src/util/lua.lua @@ -14,6 +14,9 @@ end --- @return function? chunk --- @return string? err local codeload = function(code, env) + if type(code) ~= 'string' then + return nil, 'no code to load' + end local f, err = loadstring(code) if not f then return nil, err end From 97c28b7b4e542b8c7b7ff2c12463576f435e84bc Mon Sep 17 00:00:00 2001 From: Vadim1987 Date: Thu, 25 Jun 2026 21:31:23 +0200 Subject: [PATCH 2/4] fix(project): report missing main.lua instead of compiling it --- src/model/project/project.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/model/project/project.lua b/src/model/project/project.lua index 9d4a0777..3a999e29 100644 --- a/src/model/project/project.lua +++ b/src/model/project/project.lua @@ -382,7 +382,8 @@ function ProjectService:run(name, env) p_path, err = self.is_project(ProjectService.path, name) end if p_path then - local _, code = self.current:readfile(ProjectService.MAIN) + local ok, code = self.current:readfile(ProjectService.MAIN) + if not ok then return nil, code, p_path end local content, c_err = codeload(code, env) return content, c_err, p_path end From 31700b8084dbae7cd0d0a6390f339b374c7c9e17 Mon Sep 17 00:00:00 2001 From: Danila Sentyabov <8774536+dsent@users.noreply.github.com> Date: Tue, 30 Jun 2026 16:04:11 +0200 Subject: [PATCH 3/4] Make error string less generic Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/util/lua.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/lua.lua b/src/util/lua.lua index b412cef2..beca8068 100644 --- a/src/util/lua.lua +++ b/src/util/lua.lua @@ -15,7 +15,7 @@ end --- @return string? err local codeload = function(code, env) if type(code) ~= 'string' then - return nil, 'no code to load' + return nil, ('code must be a string (got %s)'):format(type(code)) end local f, err = loadstring(code) From cde9b0b820a4bf82bc289fafc58ec3a6ac04f0bc Mon Sep 17 00:00:00 2001 From: Danila Sentyabov <8774536+dsent@users.noreply.github.com> Date: Tue, 30 Jun 2026 16:10:01 +0200 Subject: [PATCH 4/4] Better error message (by Copilot) --- src/model/project/project.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/model/project/project.lua b/src/model/project/project.lua index 3a999e29..13114d85 100644 --- a/src/model/project/project.lua +++ b/src/model/project/project.lua @@ -384,6 +384,9 @@ function ProjectService:run(name, env) if p_path then local ok, code = self.current:readfile(ProjectService.MAIN) if not ok then return nil, code, p_path end + if type(code) ~= 'string' then + return nil, FS.messages.unreadable(ProjectService.MAIN), p_path + end local content, c_err = codeload(code, env) return content, c_err, p_path end