Skip to content

_ENV as parameter not recognized #1715

Description

@BribeFromTheHive

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions