Skip to content
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

_ENV as parameter not recognized #1715

Closed
BribeFromTheHive opened this issue Nov 19, 2022 · 3 comments
Closed

_ENV as parameter not recognized #1715

BribeFromTheHive opened this issue Nov 19, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@BribeFromTheHive
Copy link

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Diagnostics/Syntax Checking

Expected Behaviour

If I include _ENV as a parameter, the extension should identify _ENV as properly defined. No errors should occur with the below code:

local function foo(_ENV)
    Joe = "human"
end

Actual Behaviour

I am getting an error message:

Invalid global (_ENV is nil).Lua Diagnostics.(global-in-nil-env)

image

Reproduction steps

  1. Create a function which takes _ENV as a parameter
  2. Assign an undefined variable
  3. The undefined variable is throwing a Lua server error.

Additional Notes

This can be worked around via adding a "diagnostic disable" or by adding "local _ENV = _ENV" (which are both very ugly hacks).

Log File

No response

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

sumneko commented Nov 21, 2022

I have not realized that there is such a way. But honestly, I think this writing is really weird.

@BribeFromTheHive
Copy link
Author

I have not realized that there is such a way. But honestly, I think this writing is really weird.

I agree, _ENV is a weird concept in Lua. But in this case, I'm trying to capture all the new assignments to _ENV so I know which legacy API the user is requesting.

@sumneko sumneko added the Info Needed More information is required label Nov 23, 2022
@sumneko
Copy link
Collaborator

sumneko commented Nov 23, 2022

I cannot reproduce it, please check if you are using the latest version 3.6.3

@sumneko sumneko removed the Info Needed More information is required label Mar 8, 2023
@sumneko sumneko closed this as completed in 48a3aab Mar 8, 2023
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