Skip to content

Global in one file affects diagnostics in another #2340

@andybak

Description

@andybak

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 have 1.lua:

function Main()
    foobar = 1
end

and 2.lua:

function Main()
    print(foobar)
end

in the same workspace/directory.

I would expect 2.lua to show foobar as undefined (unless I explicitly require 1.lua)

Actual Behaviour

No error is shown.

Additional Notes

This might be a pecularity of how I'm using lua (each file defines a separate plugin) but I would be surprised if this is an uncommon usage pattern. At the very least there should be a way to configure the behaviour.

Also - I'd be curious to understand the thinking behind the existing behaviour?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions