diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-07-18 07:05:12 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-07-18 07:05:12 +0000 |
commit | bbaf9b28000d7e11d74c85a8312de856bef7ab21 (patch) | |
tree | 801c1327d580316caa086f17b719370dbead1b29 | |
parent | e9a91d2c95dfe22ad0487952f7a1053ef9a5fd16 (diff) |
* 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]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | parse.y | 9 | ||||
-rw-r--r-- | test/ruby/test_not.rb | 12 |
3 files changed, 31 insertions, 1 deletions
@@ -1,3 +1,14 @@ +Wed Jul 18 15:50:25 2012 Shugo Maeda <shugo@ruby-lang.org> + + * 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@atdot.net> * thread.c (rb_thread_call_without_gvl2): added. @@ -2710,6 +2710,14 @@ primary : literal $$ = 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 @@ parser_yylex(struct parser_params *parser) } else if (IS_SPCARG(-1)) { c = tLPAREN_ARG; - rb_warning0("(...) interpreted as grouped expression"); } paren_nest++; COND_PUSH(0); diff --git a/test/ruby/test_not.rb b/test/ruby/test_not.rb new file mode 100644 index 0000000000..486075bf83 --- /dev/null +++ b/test/ruby/test_not.rb @@ -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 |