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

dup on Range regression #3163

Closed
etehtsea opened this issue Jul 22, 2015 · 1 comment
Closed

dup on Range regression #3163

etehtsea opened this issue Jul 22, 2015 · 1 comment

Comments

@etehtsea
Copy link
Contributor

JRuby 9k final:

>> Range.new(0, 1000).dup
NameError: `initialize' called twice
    from org/jruby/RubyRange.java:247:in `initialize_copy'
    from org/jruby/RubyKernel.java:1860:in `initialize_dup'
    from org/jruby/RubyKernel.java:1898:in `dup'

JRuby 1.7.20.1:

>> Range.new(0,1000).dup
=> 0..1000
@enebo enebo added this to the JRuby 9.0.1.0 milestone Jul 22, 2015
@cheald
Copy link
Contributor

cheald commented Jul 22, 2015

This was broken in the course of fixing an MRI test:

def test_initialize_twice
  r = eval("1..2")
  assert_raise(NameError) { r.instance_eval { initialize 3, 4 } }
  assert_raise(NameError) { r.instance_eval { initialize_copy 3..4 } }
end

And apparently #dup calls initialize_copy. I'll get into the MRI source and figure out what it's doing differently.

cheald added a commit to cheald/jruby that referenced this issue Jul 22, 2015
…Closes jruby#3163

MRI checks if the EXCL flag is Qnil to see if the range has been initalized. This doesn't work
in Java because we use a boolean which can't have a nil value. Instead, introduce a new isInited
flag which is used to track the initialization state of the Range, which corrently permits #dup
while not permitting reinitialization of a Range.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants