aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-16 01:49:42 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-16 01:49:42 +0000
commitae90744b070d239e125794e87a97d9a2aeb853b0 (patch)
treed9f8e9100417a3e586b6b5dc5b9531a90f523b06
parent8aea5c18f8a595f3cf6bdffdd0d1cffb31d9c768 (diff)
downloadruby-ae90744b070d239e125794e87a97d9a2aeb853b0.tar.gz
parse.y: fix block_call&.call
* parse.y (block_command, block_call): fix `&.` calls after block_call. [Feature #11537] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--parse.y8
-rw-r--r--test/ruby/test_call.rb17
3 files changed, 26 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index ab7d04e8cd..87e50453eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Dec 16 10:49:51 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * parse.y (block_command, block_call): fix `&.` calls after
+ block_call. [Feature #11537]
+
Wed Dec 16 00:53:45 2015 Naohisa Goto <ngotogenome@gmail.com>
* lib/webrick/utils.rb (WEBrick::Utils::TimeoutHandler): Acquire
diff --git a/parse.y b/parse.y
index c67e0fcca2..23c0b1b328 100644
--- a/parse.y
+++ b/parse.y
@@ -1413,7 +1413,7 @@ block_command : block_call
| block_call call_op2 operation2 command_args
{
/*%%%*/
- $$ = NEW_CALL($1, $3, $4);
+ $$ = NEW_QCALL($2, $1, $3, $4);
/*%
$$ = dispatch3(call, $1, $2, $3);
$$ = method_arg($$, $4);
@@ -3626,7 +3626,7 @@ block_call : command do_block
| block_call call_op2 operation2 opt_paren_args
{
/*%%%*/
- $$ = NEW_CALL($1, $3, $4);
+ $$ = NEW_QCALL($2, $1, $3, $4);
/*%
$$ = dispatch3(call, $1, $2, $3);
$$ = method_optarg($$, $4);
@@ -3636,7 +3636,7 @@ block_call : command do_block
{
/*%%%*/
block_dup_check($4, $5);
- $5->nd_iter = NEW_CALL($1, $3, $4);
+ $5->nd_iter = NEW_QCALL($2, $1, $3, $4);
$$ = $5;
fixpos($$, $1);
/*%
@@ -3648,7 +3648,7 @@ block_call : command do_block
{
/*%%%*/
block_dup_check($4, $5);
- $5->nd_iter = NEW_CALL($1, $3, $4);
+ $5->nd_iter = NEW_QCALL($2, $1, $3, $4);
$$ = $5;
fixpos($$, $1);
/*%
diff --git a/test/ruby/test_call.rb b/test/ruby/test_call.rb
index 2cef0e5c66..04966f40f7 100644
--- a/test/ruby/test_call.rb
+++ b/test/ruby/test_call.rb
@@ -65,4 +65,21 @@ class TestCall < Test::Unit::TestCase
o.x&.at(proc.call)
assert_equal(1, count)
end
+
+ def test_safe_call_block_command
+ assert_nil(("a".sub! "b" do end&.foo 1))
+ end
+
+ def test_safe_call_block_call
+ assert_nil(("a".sub! "b" do end&.foo))
+ end
+
+ def test_safe_call_block_call_brace
+ assert_nil(("a".sub! "b" do end&.foo {}))
+ assert_nil(("a".sub! "b" do end&.foo do end))
+ end
+
+ def test_safe_call_block_call_command
+ assert_nil(("a".sub! "b" do end&.foo 1 do end))
+ end
end