Actions
Bug #11618
closedSafe call syntax with aref or aset is
Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-10-24 trunk 52128)
Description
This test pass
# ruby -v: ruby 2.3.0dev (2015-10-24 trunk 52128) [x86_64-darwin14]
# test/ruby/test_call.rb
def test_safe_call_aref_aset
s = Struct.new(:x, :y)
o = s.new({a: 10})
assert_equal(10, o.x.?send(:[], :a))
o.x.?send(:[]=, :a, 11)
assert_equal(11, o.x.?send(:[], :a))
assert_nil(o.y.?send(:[], :a))
o.y.?send(:[]=, :a, 11)
assert_nil(o.y.?send(:[], :a))
end
This is invalid syntax
# ruby -v: ruby 2.3.0dev (2015-10-24 trunk 52128) [x86_64-darwin14]
# test/ruby/test_call.rb
def test_safe_call_aref_aset
s = Struct.new(:x, :y)
o = s.new({a: 10})
assert_equal(10, o.x.?[:a])
o.x.?[:a] = 11
assert_equal(11, o.x.?[:a])
assert_nil(o.y.?[:a])
o.y.?[:a] = 11
assert_nil(o.y.?[:a])
end
./test/runner.rb: ruby/ruby/test/ruby/test_call.rb:60: syntax error, unexpected '[', expecting '(' (SyntaxError)
assert_equal(10, o.x.?[:a])
^
ruby/ruby/test/ruby/test_call.rb:61: syntax error, unexpected '[', expecting '('
o.x.?[:a] = 11
^
ruby/ruby/test/ruby/test_call.rb:62: syntax error, unexpected '[', expecting '('
assert_equal(11, o.x.?[:a])
^
ruby/ruby/test/ruby/test_call.rb:64: syntax error, unexpected '[', expecting '('
assert_nil(o.y.?[:a])
^
ruby/ruby/test/ruby/test_call.rb:65: syntax error, unexpected '[', expecting '('
o.y.?[:a] = 11
^
ruby/ruby/test/ruby/test_call.rb:66: syntax error, unexpected '[', expecting '('
assert_nil(o.y.?[:a])
^
make: *** [yes-test-all] Error 1
Actions
Like0
Like0Like0Like0