ruby-changes:24383
From: shugo <ko1@a...>
Date: Wed, 18 Jul 2012 16:05:27 +0900 (JST)
Subject: [ruby-changes:24383] shugo:r36434 (trunk): * parse.y (primary): allow an empty grouped expression as the
shugo 2012-07-18 16:05:12 +0900 (Wed, 18 Jul 2012) New Revision: 36434 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36434 Log: * parse.y (primary): allow an empty grouped expression as the operand of the not operator (e.g., not ()). [ruby-core:45976] [Bug #6674] * parse.y (parser_yylex): show no warning for a grouped expression as the operand of the not operator (e.g., not (a)) or as an argument of a method call without parentheses (e.g., foo (a)). [ruby-core:39050] [Bug #5214] Added files: trunk/test/ruby/test_not.rb Modified files: trunk/ChangeLog trunk/parse.y Index: ChangeLog =================================================================== --- ChangeLog (revision 36433) +++ ChangeLog (revision 36434) @@ -1,3 +1,14 @@ +Wed Jul 18 15:50:25 2012 Shugo Maeda <shugo@r...> + + * parse.y (primary): allow an empty grouped expression as the + operand of the not operator (e.g., not ()). + [ruby-core:45976] [Bug #6674] + + * parse.y (parser_yylex): show no warning for a grouped expression + as the operand of the not operator (e.g., not (a)) or as an + argument of a method call without parentheses (e.g., foo (a)). + [ruby-core:39050] [Bug #5214] + Wed Jul 18 15:33:21 2012 Koichi Sasada <ko1@a...> * thread.c (rb_thread_call_without_gvl2): added. Index: parse.y =================================================================== --- parse.y (revision 36433) +++ parse.y (revision 36434) @@ -2710,6 +2710,14 @@ $$ = dispatch1(begin, $3); %*/ } + | tLPAREN_ARG {lex_state = EXPR_ENDARG;} rparen + { + /*%%%*/ + $$ = 0; + /*% + $$ = dispatch1(paren, 0); + %*/ + } | tLPAREN_ARG expr {lex_state = EXPR_ENDARG;} rparen { /*%%%*/ @@ -7671,7 +7679,6 @@ } else if (IS_SPCARG(-1)) { c = tLPAREN_ARG; - rb_warning0("(...) interpreted as grouped expression"); } paren_nest++; COND_PUSH(0); Index: test/ruby/test_not.rb =================================================================== --- test/ruby/test_not.rb (revision 0) +++ test/ruby/test_not.rb (revision 36434) @@ -0,0 +1,12 @@ +require 'test/unit' + +class TestIfunless < Test::Unit::TestCase + def test_not_with_grouped_expression + assert_equal(false, (not (true))) + assert_equal(true, (not (false))) + end + + def test_not_with_empty_grouped_expression + assert_equal(true, (not ())) + end +end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/