diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-12 17:39:29 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-12 17:39:29 +0000 |
commit | 37d0c873f6c9fabebf2ea44a28f843a99f082b07 (patch) | |
tree | 6369d79547e2579a157548d85e909283e3f45fcb /test/ruby/test_syntax.rb | |
parent | 7fa39b27621122b336db3f17ae77bb10a577d1d7 (diff) | |
download | ruby-37d0c873f6c9fabebf2ea44a28f843a99f082b07.tar.gz |
parse.y: should not eliminate value nodes
* parse.y (remove_duplicate_keys): should not simply eliminate all
value nodes, which may have side effects.
[ruby-core:65625] [Bug #10315]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_syntax.rb')
-rw-r--r-- | test/ruby/test_syntax.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 5a7d2f8a62..797d559b02 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -120,6 +120,21 @@ class TestSyntax < Test::Unit::TestCase assert_raise(ArgumentError) {o.kw(**h)} h = {"k1"=>11, k2: 12} assert_raise(TypeError) {o.kw(**h)} + + bug10315 = '[ruby-core:65625] [Bug #10315]' + a = [] + def a.add(x) push(x); x; end + def a.f(k:) k; end + a.clear + r = nil + assert_warn(/duplicated/) {r = eval("a.f(k: a.add(1), k: a.add(2))")} + assert_equal(2, r) + assert_equal([1, 2], a, bug10315) + a.clear + r = nil + assert_warn(/duplicated/) {r = eval("a.f({k: a.add(1), k: a.add(2)})")} + assert_equal(2, r) + assert_equal([1, 2], a, bug10315) end def test_keyword_self_reference |