Backport #6403
closedself という名前のメソッド定義で SyntaxError
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; しかしていないあたりが
怪しいように思うのですがどうでしょうか。
Updated by nobu (Nobuyoshi Nakada) over 12 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]
Updated by nobu (Nobuyoshi Nakada) over 12 years ago
- Tracker changed from Bug to Backport
- Project changed from Ruby master to Backport193
- Status changed from Closed to Open
Updated by naruse (Yui NARUSE) over 12 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]