1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

compile.c, parse.y: private op assign

* compile.c (iseq_compile_each), parse.y (new_attr_op_assign_gen):
  allow op assign to a private attribute.
  [ruby-core:62949] [Bug #9907]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-06-06 08:07:13 +00:00
parent 7342e78ea6
commit 199f814f32
4 changed files with 42 additions and 15 deletions

View file

@ -102,8 +102,12 @@ class TestAssignment < Test::Unit::TestCase
end
def test_assign_private_self
bug9907 = '[ruby-core:62949] [Bug #9907]'
o = Object.new
class << o
def foo; 42; end
def [](i); 42; end
private
def foo=(a); 42; end
def []=(i, a); 42; end
@ -122,6 +126,20 @@ class TestAssignment < Test::Unit::TestCase
assert_nothing_raised(NoMethodError) {
assert_equal(1, o.instance_eval {self[0] = 1})
}
assert_nothing_raised(NoMethodError, bug9907) {
assert_equal(43, o.instance_eval {self.foo += 1})
}
assert_nothing_raised(NoMethodError, bug9907) {
assert_equal(1, o.instance_eval {self.foo &&= 1})
}
assert_nothing_raised(NoMethodError, bug9907) {
assert_equal(43, o.instance_eval {self[0] += 1})
}
assert_nothing_raised(NoMethodError, bug9907) {
assert_equal(1, o.instance_eval {self[0] &&= 1})
}
end
def test_yield