Projects

Ticket #784 (closed defect: fixed)

Opened 19 months ago

Last modified 19 months ago

Exception is generated when change Hash's key.

Reported by: watson1978@… Owned by: lsansonetti@…
Priority: blocker Milestone: MacRuby 0.7
Component: MacRuby Keywords:
Cc:

Description

It seems that this issue blocks #753

Test Script:

$ cat test_hash.rb 
# based on send_header() in "lib/webrick/httpresponse.rb"
hash = {}
hash["content-type"] = "text/html"

hash.each{|key,value|
  p "#{key} : #{value}"
  tmp = key.gsub(/\bwww|^te$|\b\w/){ 
    p $&
    p $&.upcase 
  }
  p tmp
}

Result of Ruby 1.9.1:

$ ruby test_hash.rb 
"content-type : text/html"
"c"
"C"
"t"
"T"
"Content-Type"

Result of MacRuby Trunk:

$ macruby test_hash.rb
"content-type : text/html"
"c"
"C"
/Users/watson/test/ruby/macruby/test_hash.rb:6:in `block': string frozen (RuntimeError)
        from /Users/watson/test/ruby/macruby/test_hash.rb:5:in `<main>'

Test Script works when changed "key.gsub" to "key.dup.gsub".

Change History

Changed 19 months ago by lsansonetti@…

Better reduction:

$ ./miniruby -e "p 'foo'.freeze.gsub(/./, '_')"
"___"
$ ./miniruby -e "p 'foo'.freeze.gsub(/./){'_'}"
/Users/lrz/src/macruby-trunk/-e:1:in `<main>': string frozen (RuntimeError)

Changed 19 months ago by watson1978@…

This issue did not reproduce with r4344. Thanks!

Changed 19 months ago by lsansonetti@…

  • status changed from new to closed
  • resolution set to fixed
  • milestone set to MacRuby 0.7

Indeed, forgot to mention the revision & close the ticket :)

Note: See TracTickets for help on using tickets.