Project

General

Profile

Bug #8851

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

Added by okkez _ almost 3 years ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
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)

Associated revisions

Revision 54131
Added by Nobuyoshi Nakada 5 months ago

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. [Bug #8851]

Revision 54642
Added by Tomoyuki Chikanaga 3 months ago

merge revision(s) 53753,54131: [Backport #8851]

lex.c.blt: update

* lex.c.blt: follows r52429, not removing casts to int.
* defs/keywords (alias, undef): symbol literals are allowed.

* parse.y (parse_percent): should parse symbol literals for alias
  and undef.   [Bug #8851]

Revision 54686
Added by Usaku NAKAMURA 3 months ago

merge revision(s) 54131: [Backport #8851]

* defs/keywords (alias, undef): symbol literals are allowed.

* parse.y (parse_percent): should parse symbol literals for alias
  and undef.   [Bug #8851]

History

#1 [ruby-dev:49513] Updated by okkez _ 5 months ago

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

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

#2 [ruby-dev:49516] Updated by Shyouhei Urabe 5 months ago

  • Description updated (diff)

#3 Updated by Nobuyoshi Nakada 5 months 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. [Bug #8851]

#4 [ruby-dev:49540] Updated by Yui NARUSE 4 months ago

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

#5 [ruby-dev:49581] Updated by Tomoyuki Chikanaga 3 months 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.

#6 [ruby-dev:49586] Updated by Usaku NAKAMURA 3 months 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.

Also available in: Atom PDF