提交 7470f270 编写于 作者: J Justin Collins

Fix handling of shadowed block args

上级 f8a5011b
......@@ -182,7 +182,7 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor
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
......
......@@ -437,6 +437,26 @@ class AliasProcessorTests < Test::Unit::TestCase
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册