From f5f6218a23fdbe45d1a80c202a131f02c3eef0ce Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 25 Dec 2014 03:47:46 +0000 Subject: parse.y: warn past scope variable * parse.y (gettable_gen): warn possible reference to a local variable defined in a past scope. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_parse.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 70b38a2a7e..38dca83053 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -873,4 +873,8 @@ x = __ENCODING__ a = "\u{3042}" assert_warning(/#{a}/) {eval("#{a} = 1; /(?<#{a}>)/ =~ ''")} end + + def test_past_scope_variable + assert_warning(/past scope/) {catch {|tag| eval("BEGIN{throw tag}; tap {a = 1}; a")}} + end end -- cgit v1.2.3