Incorrectly reporting shadowingOuterLocalVar within macro included

closes #161
This commit is contained in:
Vitalii Elenhaupt 2020-07-15 10:18:12 +03:00
parent 7f501a1df5
commit d650ca5477
No known key found for this signature in database
GPG key ID: CD0BF17825928BC0
4 changed files with 41 additions and 7 deletions

View file

@ -114,19 +114,30 @@ module Ameba::AST
end
end
describe "#macro?" do
describe "#in_macro?" do
it "returns true if Crystal::Macro" do
nodes = as_nodes %(
macro included
end
)
scope = Scope.new nodes.macro_nodes.first
scope.macro?.should be_true
scope.in_macro?.should be_true
end
it "returns true if node is nested to Crystal::Macro" do
nodes = as_nodes %(
macro included
{{@type.each do |type| a = type end}}
end
)
outer_scope = Scope.new nodes.macro_nodes.first
scope = Scope.new nodes.block_nodes.first, outer_scope
scope.in_macro?.should be_true
end
it "returns false otherwise" do
scope = Scope.new as_node "a = 1"
scope.macro?.should be_false
scope.in_macro?.should be_false
end
end
end