Project

General

Profile

Actions

Backport #6403

closed

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

Added by wanabe (_ wanabe) over 12 years ago. Updated over 12 years ago.

Status:
Closed
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; しかしていないあたりが
怪しいように思うのですがどうでしょうか。

Actions #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]
Actions #2

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
Actions #3

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

Also available in: Atom PDF

Like0
Like0Like0Like0