I've noticed this issue in Rack specs. Exactly in this https://github.com/rack/rack/blob/master/test/spec_mock.rb#L107. There is no issue under MRI (Ruby 2.5.3)
In fact, this issue causes a lot failed Rack specs under Truffleruby 1.0.0-rc9.
To reproduce:
# frozen_string_literal: true
require 'stringio'
StringIO.new('').set_encoding(Encoding::ISO_8859_1)
Error:
~/.rubies/truffleruby-1.0.0-rc9/lib/truffle/stringio.rb:123:in `force_encoding': can't modify frozen String (RuntimeError)
from ~/.rubies/truffleruby-1.0.0-rc9/lib/truffle/stringio.rb:123:in `set_encoding'
from stringio.rb:5:in `<main>'
Thanks for the report. I'll take a look and see what's going on.
This was an issue in the upstream rubysl-stringio. The fix was simple enough and I added a new spec to both better document the expected behavior and to ensure there are no regressions. See ec92ef29863b8ae57661b521146e10793c483818 for details.
@deepj The fix for this should have shipped with the new 1.0.0 RC 11 release. Please comment here if you're still seeing a problem.