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

etehtsea opened this Issue Jul 22, 2015 · 1 comment


None yet
3 participants
Copy link

etehtsea commented Jul 22, 2015

JRuby 9k final:

>>, 1000).dup
NameError: `initialize' called twice
    from org/jruby/ `initialize_copy'
    from org/jruby/ `initialize_dup'
    from org/jruby/ `dup'


=> 0..1000

@enebo enebo added this to the JRuby milestone Jul 22, 2015


This comment has been minimized.

Copy link

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 } }

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

Fix RubyRange#initialize_copy mistakenly erroring on #dup'ing a range.
…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.

@enebo enebo closed this in #3165 Jul 23, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.