Project

General

Profile

Backport #6403

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

Added by wanabe (_ wanabe) almost 8 years ago. Updated almost 8 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; しかしていないあたりが
怪しいように思うのですがどうでしょうか。

#1

Updated by nobu (Nobuyoshi Nakada) almost 8 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) almost 8 years ago

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

Updated by naruse (Yui NARUSE) almost 8 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