ShadowingOuterLocalVar while it is not in macro

closes #224
This commit is contained in:
Vitalii Elenhaupt 2021-04-18 20:55:10 +03:00
parent cd18c6a000
commit a64f48b543
No known key found for this signature in database
GPG key ID: CD0BF17825928BC0
2 changed files with 20 additions and 0 deletions

View file

@ -236,6 +236,21 @@ module Ameba::Rule::Lint
)
subject.catch(source).should be_valid
end
it "does not report scoped vars to MacroFor" do
source = Source.new %(
struct Test
def test
{% for ivar in @type.instance_vars %}
{% var_type = ivar %}
{% end %}
{% ["a", "b"].map { |ivar| puts ivar } %}
end
end
)
subject.catch(source).should be_valid
end
end
end
end

View file

@ -97,6 +97,11 @@ module Ameba::AST
on_scope_enter(node)
end
# :nodoc:
def visit(node : Crystal::MacroFor)
on_scope_enter(node)
end
@current_assign : Crystal::ASTNode?
# :nodoc: