Bug #4232

unexpected behavior of '#{}' in irb

Added by Heesob Park over 4 years ago. Updated about 4 years ago.

[ruby-core:34083]
Status:Closed
Priority:Normal
Assignee:Keiju Ishitsuka
ruby -v:ruby 1.9.3dev (2010-12-31 trunk 30439) [i386-mswin32_90] Backport:

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

Associated revisions

Revision 32257
Added by Keiju Ishitsuka about 4 years ago

  • lib/irb/ruby-lex.rb: fix [Bug #4232].

Revision 32257
Added by Keiju Ishitsuka about 4 years ago

  • lib/irb/ruby-lex.rb: fix [Bug #4232].

History

#1 Updated by Yuki Sonoda over 4 years ago

  • Assignee set to Keiju Ishitsuka

=begin

=end

#2 Updated by Shyouhei Urabe over 4 years ago

  • Status changed from Open to Assigned

#3 Updated by Keiju Ishitsuka about 4 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r32257.
Heesob, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/irb/ruby-lex.rb: fix [Bug #4232].

Also available in: Atom PDF