-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Labels
Milestone
Description
JRuby seems to let you set instance variables on Fixnum, where in MRI this is an error. Can be demonstrated with both instance_eval and normal methods.
$ ~/.rbenv/versions/2.2.0-preview2/bin/ruby -e '14.instance_eval { p @foo = 14 }'
-e:1:in `block in <main>': can't modify frozen Fixnum (RuntimeError)
from -e:1:in `instance_eval'
from -e:1:in `<main>'
$ ~/.rbenv/versions/jruby-1.7.16/bin/ruby -e '14.instance_eval { p @foo = 14 }'
14
$ bin/jruby -e '14.instance_eval { p @foo = 14 }'
14
$ cat ../test.rb
def Fixnum
def write
@foo = 14
end
end
p 14.write
$ ~/.rbenv/versions/2.2.0-preview2/bin/ruby ../test.rb
../test.rb:3:in `write': can't modify frozen Fixnum (RuntimeError)
from ../test.rb:7:in `<main>'
$ ~/.rbenv/versions/jruby-1.7.16/bin/ruby ../test.rb
14
$ bin/jruby ../test.rb
14
Reactions are currently unavailable