Skip to content

Commit 2e1327f

Browse files
headiusenebo
authored andcommitted
Properly replace packed 2-tuple entries with those coming in.
Fixes jruby#4124.
1 parent 3400c43 commit 2e1327f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

core/src/main/java/org/jruby/specialized/RubyArrayTwoObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public IRubyObject replace(IRubyObject orig) {
252252

253253
if (origArr.size() == 2) {
254254
car = origArr.eltInternal(0);
255-
cdr = origArr.eltInternal(0);
255+
cdr = origArr.eltInternal(1);
256256
return this;
257257
}
258258

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
describe '#4124 Packed arrays' do
2+
it 'replaces properly' do
3+
# try a range of sizes, since we may expand packed arrays
4+
arys = 1.upto(10).map {|i| (1..i).to_a }
5+
6+
arys.each do |ary|
7+
plus_one = ary.map {|i| i+1}
8+
ary.replace plus_one
9+
10+
ary.should == plus_one
11+
end
12+
end
13+
end

0 commit comments

Comments
 (0)