Skip to content

Commit b82c06a

Browse files
committed
Handle private AREF call in compile.c
1 parent 160f83b commit b82c06a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

parse.y

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4249,10 +4249,7 @@ method_call : fcall paren_args
42494249
| primary_value '[' opt_call_args rbracket
42504250
{
42514251
/*%%%*/
4252-
if ($1 && nd_type_p($1, NODE_SELF))
4253-
$$ = NEW_FCALL(tAREF, $3, &@$);
4254-
else
4255-
$$ = NEW_CALL($1, tAREF, $3, &@$);
4252+
$$ = NEW_CALL($1, tAREF, $3, &@$);
42564253
fixpos($$, $1);
42574254
/*% %*/
42584255
/*% ripper: aref!($1, escape_Qundef($3)) %*/

test/ruby/test_method.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,14 @@ def test_visibility
771771
assert_raise(NoMethodError) { (self).mv2 }
772772
assert_nothing_raised { self.mv3 }
773773

774+
class << (obj = Object.new)
775+
private def [](x) x end
776+
def mv1(x) self[x] end
777+
def mv2(x) (self)[x] end
778+
end
779+
assert_nothing_raised { obj.mv1(0) }
780+
assert_raise(NoMethodError) { obj.mv2(0) }
781+
774782
v = Visibility.new
775783

776784
assert_equal('method', defined?(v.mv1))

0 commit comments

Comments
 (0)