From e7606de949fdae93ae51feed80a128511d66a9d3 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 22 Aug 2017 13:21:18 +0000 Subject: [PATCH] parse.y: primary should not be 0 * parse.y (primary): should not be 0, since it can be a receiver. [ruby-core:82447] [Bug #13836] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- parse.y | 2 +- test/ruby/test_defined.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/parse.y b/parse.y index 26763e9a00..14b5e9e3e9 100644 --- a/parse.y +++ b/parse.y @@ -2487,7 +2487,7 @@ primary : literal | tLPAREN_ARG {SET_LEX_STATE(EXPR_ENDARG);} rparen { /*%%%*/ - $$ = 0; + $$ = NEW_BEGIN(0); /*% $$ = dispatch1(paren, 0); %*/ diff --git a/test/ruby/test_defined.rb b/test/ruby/test_defined.rb index de7ba9cc14..54f461ff03 100644 --- a/test/ruby/test_defined.rb +++ b/test/ruby/test_defined.rb @@ -99,6 +99,10 @@ class TestDefined < Test::Unit::TestCase end end + def test_defined_empty_paren_arg + assert_nil(defined?(p () + 1)) + end + def test_defined_impl_specific feature7035 = '[ruby-core:47558]' # not spec assert_predicate(defined?(Foo), :frozen?, feature7035)