Permalink
Browse files

Probable fix for JRUBY-4831: Multiple block args to ActiveRecord asso…

…ciation proxy are splatted incorrectly
  • Loading branch information...
1 parent ef19b4a commit c3329e40d9559457431c1ccf6de6f2030ec756ff @headius headius committed Jun 4, 2010
Showing with 10 additions and 1 deletion.
  1. +10 −1 src/org/jruby/RubyEnumerable.java
@@ -858,7 +858,16 @@ public EachWithIndex(ThreadContext ctx, Block block) {
}
public IRubyObject call(ThreadContext context, IRubyObject[] iargs, Block block) {
- this.block.call(context, new IRubyObject[] { runtime.newArray(checkArgs(runtime, iargs), runtime.newFixnum(index++)) });
+ switch (iargs.length) {
+ case 0:
+ // FIXME: Does this ever happen?
+ case 1:
+ this.block.call(context, checkArgs(runtime, iargs), runtime.newFixnum(index++));
+ break;
+ case 2:
+ this.block.call(context, runtime.newArrayNoCopy(iargs), runtime.newFixnum(index++));
+ break;
+ }
return runtime.getNil();
}
}

0 comments on commit c3329e4

Please sign in to comment.