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

Recognize unused variable from type declaration #429

Closed
straight-shoota opened this issue Dec 6, 2023 · 2 comments · Fixed by #430
Closed

Recognize unused variable from type declaration #429

straight-shoota opened this issue Dec 6, 2023 · 2 comments · Fixed by #430
Assignees
Milestone

Comments

@straight-shoota
Copy link
Contributor

Lint/UselessAssign rule reports local variables that are defined per assignment but never used.

a = "" # Lint/UselessAssign: Useless assignment to variable `b`

Type declarations also declare a variable yet do not assign to the variable. This should even more reason to report it.

For the following program, ameba should report a similar issue:

a : String

This came up in crystal-lang/crystal#14058

@straight-shoota
Copy link
Contributor Author

@Sija citing #430 (comment) here for clarity:

As type declarations are often used as part of DSLs and within accessor macros, I see no reliable way to mark them as unused assignments.

I'm not sure I get the issue you're seeing. For all I can tell, the use of type declarations in DSLs and accessor macros should be pretty much the same as with assignments. Ameba is able to handle getter foo = 1, right? Why is getter foo : Int32 problematic?

@Sija
Copy link
Member

Sija commented Dec 15, 2023

For all I can tell, the use of type declarations in DSLs and accessor macros should be pretty much the same as with assignments.

Ameba itself allows/uses them within the properties macro.
Perhaps it would be possible to exclude 'em somehow... just thinking out loud here.

Ameba is able to handle getter foo = 1, right? Why is getter foo : Int32 problematic?

Good question. I believe it's due to some custom logic I've missed in the PR.

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

Successfully merging a pull request may close this issue.

2 participants