Project

General

Profile

Actions

Bug #18905

closed

:"@=".inspect is non-evaluatable

Added by qnighy (Masaki Hara) over 2 years ago. Updated over 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
[ruby-core:109170]

Description

There is an edge case where Symbol#inspect returns a non-evaluatable expression:

:"@=".inspect # => :@=
:"[][]=".inspect # => :[][]=
:"$$$$=" # => :$$$$=

More specifically, the quotations are stripped if the following conditions are met (but the converse does not hold):

  • It starts with @, @@, $ or [,
  • the prefix is not followed by an identifier, and
  • it ends with =.

But the rule should only apply to :$= and :[]=, because (in my understanding) we should generally have eval(sym.inspect) == sym for the programmers' convenience.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0