mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
runtime: propagate lua parsing errors while using "require"
This commit is contained in:
parent
85bce4d13d
commit
3421485253
@ -659,7 +659,7 @@ endif()
|
||||
|
||||
if(LUACHECK_PRG)
|
||||
add_custom_target(lualint
|
||||
COMMAND ${LUACHECK_PRG} -q runtime/ src/ test/
|
||||
COMMAND ${LUACHECK_PRG} -q runtime/ src/ test/ --exclude-files test/functional/fixtures/lua/syntax_error.lua
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
else()
|
||||
add_custom_target(lualint false
|
||||
|
@ -115,7 +115,8 @@ function vim._load_package(name)
|
||||
for _,path in ipairs(paths) do
|
||||
local found = vim.api.nvim_get_runtime_file(path, false)
|
||||
if #found > 0 then
|
||||
return loadfile(found[1])
|
||||
local f, err = loadfile(found[1])
|
||||
return f or error(err)
|
||||
end
|
||||
end
|
||||
|
||||
@ -123,7 +124,8 @@ function vim._load_package(name)
|
||||
local path = "lua/"..trail:gsub('?',basename)
|
||||
local found = vim.api.nvim_get_runtime_file(path, false)
|
||||
if #found > 0 then
|
||||
return package.loadlib(found[1])
|
||||
local f, err = package.loadlib(found[1])
|
||||
return f or error(err)
|
||||
end
|
||||
end
|
||||
return nil
|
||||
|
1
test/functional/fixtures/lua/syntax_error.lua
Normal file
1
test/functional/fixtures/lua/syntax_error.lua
Normal file
@ -0,0 +1 @@
|
||||
- <= the syntax error
|
@ -1453,3 +1453,18 @@ describe('lua stdlib', function()
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('lua: require("mod") from packages', function()
|
||||
before_each(function()
|
||||
command('set rtp+=test/functional/fixtures')
|
||||
end)
|
||||
|
||||
it('propagates syntax error', function()
|
||||
local syntax_error_msg = exec_lua [[
|
||||
local _, err = pcall(require, "syntax_error")
|
||||
return err
|
||||
]]
|
||||
|
||||
matches("unexpected symbol", syntax_error_msg)
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user