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

Do not warn for unused variables on negative lines #3176

Merged
merged 1 commit into from
Oct 10, 2024
Merged

Conversation

kddnewton
Copy link
Collaborator

Fixes [Bug #20788]

@kddnewton kddnewton merged commit e6794e6 into main Oct 10, 2024
54 checks passed
@kddnewton kddnewton deleted the negative-lines branch October 10, 2024 15:13
@@ -962,17 +962,19 @@ pm_locals_order(PRISM_ATTRIBUTE_UNUSED pm_parser_t *parser, pm_locals_t *locals,
pm_constant_id_list_insert(list, (size_t) local->index, local->name);

if (warn_unused && local->reads == 0) {
pm_constant_t *constant = pm_constant_pool_id_to_constant(&parser->constant_pool, local->name);
if (pm_newline_list_line(&parser->newline_list, local->location.start, parser->start_line) >= 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One quick thought is we could skip this maybe-no-so-cheap (?) offset to line conversion if start_line >= 0, because then the line of that offset cannot be negative if the first line is >= 0.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah great idea

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

Successfully merging this pull request may close these issues.

2 participants