From: noreply@... Date: 2007-05-30T10:52:04+09:00 Subject: [ ruby-Bugs-3329 ] String#scan loops forefever if scanned string is modified inside block. Bugs item #3329, was opened at 2006-01-26 00:55 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=1698&aid=3329&group_id=426 Category: Language / Runtime / Core Libraries Group: None >Status: Closed >Resolution: Accepted Priority: 3 Submitted By: Nikolai Lugovoi (meadow) Assigned to: Nobody (None) Summary: String#scan loops forefever if scanned string is modified inside block. Initial Comment: ruby 1.8.4 (2005-12-24) Following code loops infinitely: a = " 12345678 "; a.scan(/\d/) {|s| a[3,2]='test'; s} ---------------------------------------------------------------------- >Comment By: Ryan Davis (zenspider) Date: 2007-05-29 18:52 Message: confirmed. ---------------------------------------------------------------------- Comment By: Daniel Berger (djberg96) Date: 2007-05-29 16:47 Message: This was fixed by freezing the yielded object as per ruby-core: 7222. Trying to run the sample code with 1.8.6 raises a RuntimeError. Dan ---------------------------------------------------------------------- Comment By: Paul Duncan (pabs) Date: 2006-01-26 12:33 Message: I've posted a comment this on ruby-core at the following URL: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/7220 Basically, I'm not convinced the "fix" to this problem is better than just leaving things as-is. My suggestion, and patch, is a clarification in the documentation that discourages people from modifying the receiving string inside a String#scan block. ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=1698&aid=3329&group_id=426