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

Incorrect Global Function Definition Detection for Localized Functions within do Blocks #1310

Open
filipovskis opened this issue Aug 17, 2024 · 1 comment
Labels
🐞 Bug Something isn't working

Comments

@filipovskis
Copy link

Expected Behavior

It should not declare localized variables as global ones.

Actual Behavior

The code report detects an issue in actually localized variable, which it defines as a global one. The code report ignores if you prior localized the variable name. I actually do not know if it is a global issue related to localizing prior or just related to do blocks.

It returns an issue called: _Global function definitions are prohibited. Namespace them inside your addon's global table_.

Example:

local split do
    local len = string.len
    local sub = string.sub
    local maxBytes = netchunk.maxBytes

    function split(data)
        local length = len(data)
        local index = 1
        local last = 1
        local chunks = {}

        for i = 1, length do
            if (i - last + 1) > maxBytes then
                chunks[index] = sub(data, last, i)
                index = index + 1
                last = i + 1
            end
        end

        chunks[index] = sub(data, last, length)

        return chunks
    end
end

Result:

Image

Reproduction Steps

1. Paste somewhere in the code the example above.
2. Run code report.
3. Check the issues.

Browsers

Vivaldi

Example URL

https://www.gmodstore.com/dashboard/products/onyx-scoreboard-a-modern-scoreboard/code-reports/rkhUPOF8QBqvkzAf40Ew7g

Pivity Marketplace Version

v18.4.0

Event ID

No response

Additional Information

No response

@filipovskis filipovskis added the 🐞 Bug Something isn't working label Aug 17, 2024
@Indecisiv3
Copy link

Yeah, would be amazing if this could be fixed same thing happened with one of my submissions.

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