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

Lint against suspicious upvalue overwriting in loop #559

Open
Kampfkarren opened this issue Oct 5, 2023 · 2 comments
Open

Lint against suspicious upvalue overwriting in loop #559

Kampfkarren opened this issue Oct 5, 2023 · 2 comments
Labels
A-lints Area: Relating to a lint directly C-enhancement Category: Feature request or improvement

Comments

@Kampfkarren
Copy link
Owner

for _, thing in things do
    values[key] = thing
end

...where key is an upvalue and unmodified, and there's no differing branches (like a continue that would make this potentially a "last that isn't filtered"). Hit a bug like this recently.

@Kampfkarren Kampfkarren added C-enhancement Category: Feature request or improvement A-lints Area: Relating to a lint directly labels Oct 5, 2023
@Kampfkarren
Copy link
Owner Author

We should probably limit this to otherwise pure bodies

@chriscerie chriscerie changed the title Lint against whatever the heck you'd call this Lint against suspicious upvalue overwriting in loop Oct 26, 2023
@chriscerie
Copy link
Collaborator

This can probably extend to anything where the upvalue being overwritten is the same, like a regular variable

In the help message perhaps suggest using # for arrays and next for dictionaries, if that was the user intention

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Relating to a lint directly C-enhancement Category: Feature request or improvement
Projects
None yet
Development

No branches or pull requests

2 participants