[ruby/prism] Do not warn for unused variables on negative lines
Fixes [Bug #20788] https://github.com/ruby/prism/commit/27e91f21af
This commit is contained in:
parent
d12c8cbf14
commit
b5ecb03ae4
@ -962,6 +962,7 @@ 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) {
|
||||
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 != '_') {
|
||||
@ -978,6 +979,7 @@ pm_locals_order(PRISM_ATTRIBUTE_UNUSED pm_parser_t *parser, pm_locals_t *locals,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Node-related functions */
|
||||
|
@ -259,6 +259,8 @@ module Prism
|
||||
|
||||
refute_warning("def foo; bar = 1; tap { bar }; end")
|
||||
refute_warning("def foo; bar = 1; tap { baz = bar; baz }; end")
|
||||
|
||||
refute_warning("def foo; bar = 1; end", line: -2, compare: false)
|
||||
end
|
||||
|
||||
def test_void_statements
|
||||
|
Loading…
x
Reference in New Issue
Block a user