Project

General

Profile

Actions

Bug #16097

closed

[PATCH] Don't accidentally name anonymous module/class

Added by alanwu (Alan Wu) over 4 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:94277]

Description

My patch in #15765 accidentally introduced a behavior change.
ruby -ve 'Module.new { class self::A; end; p name }' outputs a name
similar to Module#inspect when it should output nil like in Ruby 2.6.x.

I have a pull request to fix this: https://github.com/ruby/ruby/pull/2337

Updated by nobu (Nobuyoshi Nakada) over 4 years ago

Could you rebase the PR with adding this reference [Bug #16097] to the commit log?

Updated by alanwu (Alan Wu) over 4 years ago

Done. The latest commit has a reference to this ticket.

Actions #3

Updated by alanwu (Alan Wu) over 4 years ago

  • Status changed from Open to Closed

Applied in changeset git|c8f97596b7dd6ffbeb98970f9cc664b0a8a2336e.


Don't accidentally name anonymous module/class

b00f280d4b9569e7153365d7e1c522b3d6b3c6cf introduced
an accidental behavior change in that defining a module/class under
m gives m a name when m is anonymous.

ruby -ve 'Module.new { class self::A; end; p name }' outputs a name
similar to Module#inspect when it should output nil like in Ruby
2.6.x.

  • variable.c: Use make_temporary_path instead of save_temporary_path
    when getting the name of the parent module.

  • variable.c (rb_set_class_path): Delegate to rb_set_class_path_string
    instead of duplicating the logic.

[Bug #16097]

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0