summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-04-30 23:21:59 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-04-30 23:21:59 +0900
commitb82c06a711cbd1f812251a15c1e864027abe8c37 (patch)
tree719e9bc77238b0ec224b9a187317c9fbf16a6d9d /test
parent160f83ba553aa3ff9345cf9cd320bab5996e211f (diff)
downloadruby-b82c06a711cbd1f812251a15c1e864027abe8c37.tar.gz
Handle private AREF call in compile.c
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_method.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index a04666890e..80b8fe277b 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -771,6 +771,14 @@ class TestMethod < Test::Unit::TestCase
assert_raise(NoMethodError) { (self).mv2 }
assert_nothing_raised { self.mv3 }
+ class << (obj = Object.new)
+ private def [](x) x end
+ def mv1(x) self[x] end
+ def mv2(x) (self)[x] end
+ end
+ assert_nothing_raised { obj.mv1(0) }
+ assert_raise(NoMethodError) { obj.mv2(0) }
+
v = Visibility.new
assert_equal('method', defined?(v.mv1))