Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frozen String error message different from MRI #1907

Closed
alexfalkowski opened this issue Aug 15, 2014 · 1 comment
Closed

Frozen String error message different from MRI #1907

alexfalkowski opened this issue Aug 15, 2014 · 1 comment
Milestone

Comments

@alexfalkowski
Copy link

Hi Team,

There seems to be a bit of inconsistency with the error messages when we try to modify frozen object.

In Ruby MRI:

s = String.new.freeze
s.upcase!

RuntimeError: can't modify frozen String

In JRuby:

s = String.new.freeze
s.upcase!

RuntimeError: can't modify frozen string

The difference here is the casing.

If we have a custom class

class Test
  attr_accessor :name
end

In Ruby MRI:

t = Test.new.freeze
t.name = 'Test'

RuntimeError: can't modify frozen Test

In JRuby:

t = Test.new.freeze
t.name = 'Test'

RuntimeError: can't modify frozen

In this example we are missing the name of the class.

@rtyler
Copy link

rtyler commented Aug 7, 2015

This is incorrect still in JRuby 1.7.21 but has been fixed in 9k:

[5] pry(main)> class Test
[5] pry(main)*   attr_accessor :name
[5] pry(main)* end  
=> nil
[6] pry(main)> t = Test.new.freeze
=> #<Test:0x5652f555>
[7] pry(main)> t.name = 'derp'
RuntimeError: can't modify frozen Test
from (pry):9:in `evaluate_ruby'
[8] pry(main)> RUBY_PLATFORM
=> "java"
[9] pry(main)> RUBY_VERSION
=> "2.2.0"
[10] pry(main)> 

So I'm going to go ahead and close it out.

@rtyler rtyler closed this as completed Aug 7, 2015
@enebo enebo added this to the JRuby 9.0.1.0 milestone Aug 20, 2015
@nirvdrum nirvdrum changed the title Frozen Frozen String error message different from MRI Sep 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants