diff options
author | Kevin Newton <[email protected]> | 2024-10-10 10:57:05 -0400 |
---|---|---|
committer | git <[email protected]> | 2024-10-10 15:13:10 +0000 |
commit | b5ecb03ae40e01ffe57b4dc409f8c96b15e32b12 (patch) | |
tree | 2aa7fa4d3ceb2c515521968e1afb0bcc853a7470 /prism/prism.c | |
parent | d12c8cbf14084c35209a9cb07bccc8b4bee7760a (diff) |
[ruby/prism] Do not warn for unused variables on negative lines
Fixes [Bug #20788]
https://github.com/ruby/prism/commit/27e91f21af
Diffstat (limited to 'prism/prism.c')
-rw-r--r-- | prism/prism.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/prism/prism.c b/prism/prism.c index 74c86d1622..99aa7982a3 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -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) { + pm_constant_t *constant = pm_constant_pool_id_to_constant(&parser->constant_pool, local->name); - if (constant->length >= 1 && *constant->start != '_') { - PM_PARSER_WARN_FORMAT( - parser, - local->location.start, - local->location.end, - PM_WARN_UNUSED_LOCAL_VARIABLE, - (int) constant->length, - (const char *) constant->start - ); + if (constant->length >= 1 && *constant->start != '_') { + PM_PARSER_WARN_FORMAT( + parser, + local->location.start, + local->location.end, + PM_WARN_UNUSED_LOCAL_VARIABLE, + (int) constant->length, + (const char *) constant->start + ); + } } } } |