[Bug #20417] Block local variables do not need to warn about unused

This commit is contained in:
Nobuyoshi Nakada 2024-04-10 22:44:33 +09:00
parent 5d9fd674c9
commit 207788466e
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
2 changed files with 10 additions and 0 deletions

View File

@ -13814,6 +13814,10 @@ new_bv(struct parser_params *p, ID name)
}
if (!shadowing_lvar_0(p, name)) return;
dyna_var(p, name);
ID *vidp = 0;
if (dvar_defined_ref(p, name, &vidp)) {
if (vidp) *vidp |= LVAR_USED;
}
}
static void

View File

@ -1232,6 +1232,12 @@ dummy
EXP
end
def test_unused_block_local_variable
assert_warning('') do
RubyVM::AbstractSyntaxTree.parse(%{->(; foo) {}})
end
end
def assert_error_tolerant(src, expected, keep_tokens: false)
begin
verbose_bak, $VERBOSE = $VERBOSE, false