Project

General

Profile

Actions

Bug #8851

closed

alias/undef で % リテラルによるシンボルが使えない

Added by okkez (okkez _) over 10 years ago. Updated almost 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
[ruby-dev:47681]

Description

るりまプロジェクトの#7102で報告されていたのですが、調べてみたら2.0.0でも同様の状況だったので報告します。

以下のスクリプトで、コメントアウトしている部分を有効にすると syntax error になります。
一貫性の観点から %s によるシンボルリテラルも使えた方がいいように思うのですが、いかがでしょうか?

$ ruby -v a.rb
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
a.rb:21: syntax error, unexpected '(', expecting keyword_end
  alias %s(method5) method4
           ^
class A
  def method1
  end
  def method2
  end
  def method3
  end
  def method4
  end
end

p A.instance_methods(false)

class A
  undef method1
  undef :method2
  undef :"method#{3}"
  # undef %s(method4)
  # alias %s(method5) method4
end

p A.instance_methods(false)

Updated by okkez (okkez _) about 8 years ago

  • Backport deleted (1.9.3: UNKNOWN, 2.0.0: UNKNOWN)

ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux] でも同じ状況のままですが、いかがでしょうか?

Updated by shyouhei (Shyouhei Urabe) about 8 years ago

  • Description updated (diff)
Actions #3

Updated by nobu (Nobuyoshi Nakada) about 8 years ago

  • Status changed from Open to Closed

Applied in changeset r54131.


parse.y: symbol literals for alias/undef

  • defs/keywords (alias, undef): symbol literals are allowed.
  • parse.y (parse_percent): should parse symbol literals for alias
    and undef. [ruby-dev:47681] [Bug #8851]

Updated by naruse (Yui NARUSE) about 8 years ago

  • Backport set to 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) about 8 years ago

  • Backport changed from 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED to 2.1: REQUIRED, 2.2: REQUIRED, 2.3: DONE

ruby_2_3 r54642 merged revision(s) 53753,54131.

Updated by usa (Usaku NAKAMURA) almost 8 years ago

  • Backport changed from 2.1: REQUIRED, 2.2: REQUIRED, 2.3: DONE to 2.1: REQUIRED, 2.2: DONE, 2.3: DONE

ruby_2_2 r54686 merged revision(s) 54131.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0