parse.y: warning for locations

* parse.y (gettable_gen): warn for __FILE__/__LINE__ when eval
  with binding only.  promote use of Binding#source_location
  instead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-12-26 10:10:41 +00:00
parent 62a3e7a33b
commit 3802fb92ff
3 changed files with 52 additions and 4 deletions

View file

@ -503,6 +503,12 @@ class TestEval < Test::Unit::TestCase
assert_same a, b
end
def test_eval_location_binding
assert_warning(/__FILE__ in eval/) do
assert_equal(__FILE__, eval("__FILE__", binding))
end
end
def test_fstring_instance_eval
bug = "[ruby-core:78116] [Bug #12930]".freeze
assert_same bug, (bug.instance_eval {self})