Project

General

Profile

Bug #6674

1.9 parser regression: not ()

Added by zenspider (Ryan Davis) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
1.9 & 2.0
Backport:
[ruby-core:45976]

Description

4482 % ruby18 -v
ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0]
4483 % ruby19 -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]
4484 % ruby18 -cwe '! (a); not (a); ! (); not ()'
Syntax OK
4485 % ruby19 -cwe '! (a)'
Syntax OK
4486 % ruby19 -cwe 'not (a)'
-e:1: warning: (...) interpreted as grouped expression
Syntax OK
4487 % ruby19 -cwe '! ()'
Syntax OK
4488 % ruby19 -cwe 'not ()'
-e:1: syntax error, unexpected ')'
4489 % ruby20 -v
ruby 2.0.0dev (2012-05-05 trunk 35541) [x86_64-darwin11.3.0]
4490 % ruby20 -cwe '! (a)'
Syntax OK
4491 % ruby20 -cwe 'not (a)'
-e:1: warning: (...) interpreted as grouped expression
Syntax OK
4492 % ruby20 -cwe '! ()'
Syntax OK
4493 % ruby20 -cwe 'not ()'
-e:1: warning: (...) interpreted as grouped expression
-e:1: syntax error, unexpected ')'
4494 %


Files

not.diff (628 Bytes) not.diff shugo (Shugo Maeda), 07/04/2012 05:29 PM

Related issues

Is duplicate of Ruby master - Bug #5214: "not (true)" should not warn "(...) interpreted as grouped expression" Closed08/23/2011Actions

Associated revisions

Revision bbaf9b28
Added by shugo (Shugo Maeda) over 7 years ago

  • 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

Revision 36434
Added by shugo (Shugo Maeda) over 7 years ago

  • 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]

Revision 36434
Added by shugo (Shugo Maeda) over 7 years ago

  • 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]

Revision 36434
Added by shugo (Shugo Maeda) over 7 years ago

  • 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]

Revision 36434
Added by shugo (Shugo Maeda) over 7 years ago

  • 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]

Revision 36434
Added by shugo (Shugo Maeda) over 7 years ago

  • 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]

Revision 36434
Added by shugo (Shugo Maeda) over 7 years ago

  • 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]

History

Updated by shugo (Shugo Maeda) over 7 years ago

  • File not.diff not.diff added
  • Category set to core
  • Assignee set to matz (Yukihiro Matsumoto)

zenspider (Ryan Davis) wrote:

4486 % ruby19 -cwe 'not (a)'
-e:1: warning: (...) interpreted as grouped expression
Syntax OK
(snip)
4488 % ruby19 -cwe 'not ()'
-e:1: syntax error, unexpected ')'

I've attached a patch to fix the problem.

In Ruby 1.9, space before argument parentheses is not allowed (i.e.,
`foo (1, 2)' is now syntax error) anymore, so there is no need to
warn grouped expressions not only for "not" but also for method calls.

What do you think of it, Matz?

Updated by matz (Yukihiro Matsumoto) over 7 years ago

  • Assignee changed from matz (Yukihiro Matsumoto) to shugo (Shugo Maeda)

I accept the fix. Please check in.

Matz.

Updated by mame (Yusuke Endoh) over 7 years ago

  • Status changed from Open to Assigned
#4

Updated by shugo (Shugo Maeda) over 7 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r36434.
Ryan, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • 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]

Also available in: Atom PDF