Skip to content
New issue

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

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

Already on GitHub? # to your account

[Lua] Function mis-scope #3841

Open
Resike opened this issue Sep 17, 2023 · 3 comments
Open

[Lua] Function mis-scope #3841

Resike opened this issue Sep 17, 2023 · 3 comments

Comments

@Resike
Copy link
Contributor

Resike commented Sep 17, 2023

What happened?

Special case function definition gets scoped to string:

local x = {
    func1 = not false and function(...) end or nil, -- func1 is `string.unquoted.key.lua`
    func2 = function(...) end, -- func2 is `entity.name.function.lua`
}

Both function (func1 and func2) definition should be entity.name.function.lua

@Resike Resike changed the title [Lua] Function misscope [Lua] Function mis-scope Sep 17, 2023
@FichteFoll
Copy link
Collaborator

Trying to determine whether func1 in func1 = not false and function(...) end or nil is a function is too generic of a problem to be solved on a syntax definition level, because you'd need to properly parse the expression and evaluate all possibilities whether one of them could end up with a function object.

@Resike
Copy link
Contributor Author

Resike commented Sep 18, 2023

Yeah honestly I don't have a proper solution for this, that's why i created the ticket, but it just could be not solvable.

@deathaxe
Copy link
Collaborator

Not an lua expert, but as func1 is scoped as dictionary key, I wonder why func2 is not.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants