Project

General

Profile

Backport #6403

self という名前のメソッド定義で SyntaxError

Added by wanabe (_ wanabe) about 7 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
[ruby-dev:45626]

Description

http://toro.2ch.net/test/read.cgi/tech/1328648447/925-931
で指摘されていたのですが、self という名前のメソッドの定義で
メソッド内部先頭にシンボルがある場合 SyntaxError になります。
また、セミコロンか改行をはさむと正常にパースされます。

def self; :foo; end #<= NG
def self;; :foo; end #<= OK
def self() :foo; end #<= OK
def self(); :foo; end #<= OK
def hoge; :foo; end #<= OK
def class; :foo; end #<= OK

parse.y の f_arglist に関する規則の部分で、
'(' f_args rparen の時には lex_state を変更しているのに
f_args term の時には $$ = $1; しかしていないあたりが
怪しいように思うのですがどうでしょうか。

Associated revisions

Revision 45f6cdcd
Added by nobu (Nobuyoshi Nakada) about 7 years ago

Bug #6403: reset states after empty args

  • parse.y (f_arglist): should reset lexical states after empty argument list with no parenthesis as well as parenthesized list, so that reserved name method definition work. [ruby-dev:45626] [Bug #6403]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 35644
Added by nobu (Nobuyoshi Nakada) about 7 years ago

Bug #6403: reset states after empty args

  • parse.y (f_arglist): should reset lexical states after empty argument list with no parenthesis as well as parenthesized list, so that reserved name method definition work. [ruby-dev:45626] [Bug #6403]

Revision 35644
Added by nobu (Nobuyoshi Nakada) about 7 years ago

Bug #6403: reset states after empty args

  • parse.y (f_arglist): should reset lexical states after empty argument list with no parenthesis as well as parenthesized list, so that reserved name method definition work. [ruby-dev:45626] [Bug #6403]

Revision 35644
Added by nobu (Nobuyoshi Nakada) about 7 years ago

Bug #6403: reset states after empty args

  • parse.y (f_arglist): should reset lexical states after empty argument list with no parenthesis as well as parenthesized list, so that reserved name method definition work. [ruby-dev:45626] [Bug #6403]

Revision 35644
Added by nobu (Nobuyoshi Nakada) about 7 years ago

Bug #6403: reset states after empty args

  • parse.y (f_arglist): should reset lexical states after empty argument list with no parenthesis as well as parenthesized list, so that reserved name method definition work. [ruby-dev:45626] [Bug #6403]

Revision 35644
Added by nobu (Nobuyoshi Nakada) about 7 years ago

Bug #6403: reset states after empty args

  • parse.y (f_arglist): should reset lexical states after empty argument list with no parenthesis as well as parenthesized list, so that reserved name method definition work. [ruby-dev:45626] [Bug #6403]

Revision 35644
Added by nobu (Nobuyoshi Nakada) about 7 years ago

Bug #6403: reset states after empty args

  • parse.y (f_arglist): should reset lexical states after empty argument list with no parenthesis as well as parenthesized list, so that reserved name method definition work. [ruby-dev:45626] [Bug #6403]

Revision 046883d2
Added by naruse (Yui NARUSE) about 7 years ago

merge revision(s) 35644:

    * parse.y (f_arglist): should reset lexical states after empty
      argument list with no parenthesis as well as parenthesized list,
      so that reserved name method definition work.  [ruby-dev:45626]
      [Bug #6403]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@35781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 35781
Added by naruse (Yui NARUSE) about 7 years ago

merge revision(s) 35644:

* parse.y (f_arglist): should reset lexical states after empty
  argument list with no parenthesis as well as parenthesized list,
  so that reserved name method definition work.  [ruby-dev:45626]
  [Bug #6403]

Revision 1059cf6e
Added by naruse (Yui NARUSE) about 7 years ago

merge revision(s) 35644:

    * parse.y (f_arglist): should reset lexical states after empty
      argument list with no parenthesis as well as parenthesized list,
      so that reserved name method definition work.  [ruby-dev:45626]
      [Bug #6403]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@35791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 35791
Added by naruse (Yui NARUSE) about 7 years ago

merge revision(s) 35644:

* parse.y (f_arglist): should reset lexical states after empty
  argument list with no parenthesis as well as parenthesized list,
  so that reserved name method definition work.  [ruby-dev:45626]
  [Bug #6403]

History

#1

Updated by nobu (Nobuyoshi Nakada) about 7 years ago

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

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


Bug #6403: reset states after empty args

  • parse.y (f_arglist): should reset lexical states after empty argument list with no parenthesis as well as parenthesized list, so that reserved name method definition work. [ruby-dev:45626] [Bug #6403]
#2

Updated by nobu (Nobuyoshi Nakada) about 7 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby trunk to Backport193
  • Status changed from Closed to Open
#3

Updated by naruse (Yui NARUSE) about 7 years ago

  • Status changed from Open to Closed

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


merge revision(s) 35644:

* parse.y (f_arglist): should reset lexical states after empty
  argument list with no parenthesis as well as parenthesized list,
  so that reserved name method definition work.  [ruby-dev:45626]
  [Bug #6403]

Also available in: Atom PDF