Skip to content

Format error #1028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fesily opened this issue Apr 9, 2022 · 3 comments
Closed

Format error #1028

fesily opened this issue Apr 9, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@fesily
Copy link
Contributor

fesily commented Apr 9, 2022

Describe the bug
can not format any file

try require code_format failed when require provide.formatting,because main.lua disable require code_format

local stdRequire = require
require = function (name)
    if name == 'code_format' then
        error('cannot found code_format')
    end
    return stdRequire(name)
end

debug language-server, we can see package['provider.formatting'] type is boolean
image

script/provider/provider.lua:1036: attempt to index a boolean value (local 'pformatting')
stack traceback:
	[C]: in function 'xpcall'
	script/proto/proto.lua:184: in function <script/proto/proto.lua:159>
[Error - 10:12:26 AM] Request textDocument/formatting failed.
  Message: [10:12:26.471][error][#0]: script/provider/provider.lua:1036: attempt to index a boolean value (local 'pformatting')
stack traceback:
	[C]: in function 'xpcall'
	script/proto/proto.lua:184: in function <script/proto/proto.lua:159>

  Code: -32603 

Environment (please complete the following information):

  • OS: macOS
  • Is WSL remote? no
  • Client: VSCODE

Provide logs
file_Users_apple_apisix.log

@fesily
Copy link
Contributor Author

fesily commented Apr 9, 2022

I changed script/main.lua

local stdRequire = require
require = function (name)
    local ok,result = pcall(stdRequire,name)
    if not ok and name == 'code_format' then
        error('cannot found code_format')
    end
    return result
end

@sumneko
Copy link
Collaborator

sumneko commented Apr 9, 2022

It's a mis-commit, just remove this function

@sumneko sumneko added the bug Something isn't working label Apr 9, 2022
@sumneko
Copy link
Collaborator

sumneko commented Apr 9, 2022

fixed by 885ae3b and a54d265

@sumneko sumneko closed this as completed Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants