Skip to content

Register function environment variables #15

@z16

Description

@z16

This extension is able to detect usage of undefined global variables:
image

However, setfenv is used on this function to define the missing variable, but at another point in the code that the parser can't detect. Is it possible to somehow tell the parser to ignore this diagnostic? Something like:

local block = function(_)
    -- env: {block, assert, error}
    block()
end

Then it would accept those values? I know you can define globals for the project, but this doesn't affect the entire project, only those functions, so it would be cool if you could define it somehow.

Alternatively, could we just disable the diagnostic?

local block = function(_)
    -- disable: undefined-global
    block()
end

I don't know if the parser supports reading comments like that, let me know if that won't work or if you have better ideas for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions