Skip to content

Commit

Permalink
Merge pull request #613 from presidentbeef/fix_shadow_block_args
Browse files Browse the repository at this point in the history
Fix handling of shadowed block args
  • Loading branch information
presidentbeef committed Jan 28, 2015
2 parents f8a5011 + 7470f27 commit b7cb568
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/brakeman/processors/alias_processor.rb
Expand Up @@ -182,7 +182,7 @@ def process_call_with_block exp
env.current[Sexp.new(:lvar, e.lhs)] = e.rhs
elsif node_type? e, :kwarg
env.current[Sexp.new(:lvar, e[1])] = e[2]
elsif node_type? e, :masgn
elsif node_type? e, :masgn, :shadow
e[1..-1].each do |var|
local = Sexp.new(:lvar, var)
env.current[local] = local
Expand Down
20 changes: 20 additions & 0 deletions test/tests/alias_processor.rb
Expand Up @@ -437,6 +437,26 @@ def a
OUTPUT
end

def test_shadowed_block_arg
assert_output <<-INPUT, <<-OUTPUT
def a
y = 1
x do |w; y, z|
y = 2
end
puts y
end
INPUT
def a
y = 1
x do |w; y, z|
y = 2
end
puts 1
end
OUTPUT
end

def test_block_in_class_scope
# Make sure blocks in class do not mess up instance variable scope
# for subsequent methods
Expand Down

0 comments on commit b7cb568

Please sign in to comment.