Skip to content

Commit

Permalink
[Bug #20417] Block local variables do not need to warn about unused
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Apr 11, 2024
1 parent 5d9fd67 commit 2077884
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions parse.y
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test/ruby/test_ast.rb
Expand Up @@ -1232,6 +1232,12 @@ def test_with_bom
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
Expand Down

0 comments on commit 2077884

Please sign in to comment.