Prevent false positiveness cause by macro literals

https://github.com/crystal-lang/crystal/pull/6055#issuecomment-386376227
This commit is contained in:
Vitalii Elenhaupt 2018-05-12 17:37:54 +03:00
parent 6579c8f573
commit 415432713a
No known key found for this signature in database
GPG key ID: 7558EF3A4056C706
5 changed files with 47 additions and 25 deletions

View file

@ -820,6 +820,37 @@ module Ameba::Rule
)
subject.catch(s).should be_valid
end
it "doesn't report if assignment is referenced in macro def" do
s = Source.new %(
macro macro_call
puts x
end
def foo
x = 1
macro_call
end
)
subject.catch(s).should be_valid
end
it "reports if assignment is referenced in macro def in a different scope" do
s = Source.new %(
class Foo
def foo
x = 1
end
end
class Bar
macro macro_call
puts x
end
end
)
subject.catch(s).should_not be_valid
end
end
end
end