Project

General

Profile

Actions

Bug #4232

closed

unexpected behavior of '#{}' in irb

Added by phasis68 (Heesob Park) almost 14 years ago. Updated over 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.3dev (2010-12-31 trunk 30439) [i386-mswin32_90]
Backport:
[ruby-core:34083]

Description

=begin
In Ruby 1.9.x,

C:\work>irb
irb(main):001:0> a = '#{%}'
irb(main):002:0"

C:\work>irb
irb(main):001:0> a = '#{#}'
irb(main):002:0>

In Ruby 1.8.6,

C:\work>irb
irb(main):001:0> a = '#{%}'
=> "#{%}"
irb(main):002:0>

C:\work>irb
irb(main):001:0> a = '#{#}'
=> "#{#}"
irb(main):002:0>

Here is a patch:

--- ruby-lex.rb 2011-01-05 15:05:31.000000000 +0900
+++ ruby-lex.rb.new 2011-01-05 15:05:08.000000000 +0900
@@ -1046,7 +1046,7 @@
while ch = getc
if @quoted == ch and nest == 0
break

  •   elsif ch == "#" and peek(0) == "{"
    
  •   elsif @ltype != "'" && ch == "#" and peek(0) == "{"
        identify_string_dvar
      elsif @ltype != "'" && @ltype != "]" && @ltype != ":" and ch == "#"
        subtype = true
    

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0