Skip to content

Commit

Permalink
Fixes #4706. TypeError: debugging with --debug
Browse files Browse the repository at this point in the history
This is really about fixing:
```ruby
@t = [[1, 2], [3, 4]]
for th, in @t
   p th
end
```

which stdlib debug happens to use (notice the extra ,).  Spec commit coming
after this one.
  • Loading branch information
enebo committed Aug 16, 2017
1 parent 53748e3 commit c3a1d6c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions core/src/main/java/org/jruby/runtime/Signature.java
Expand Up @@ -208,13 +208,15 @@ public static Signature from(ForNode iter) {
// ForNode can aggregate either a single node (required = 1) or masgn
if (var instanceof MultipleAsgnNode) {
MultipleAsgnNode masgn = (MultipleAsgnNode)var;

Rest rest = Rest.NONE;
if (masgn.getRest() != null) {
Node restArg = masgn.getRest();
rest = restFromArg(restArg);
}
return Signature.from(masgn.getPreCount(), 0, masgn.getPostCount(), 0, 0, rest, -1);
Rest rest = masgn.getRest() == null ? Rest.NONE : restFromArg(masgn.getRest());

// 'for' can only have rest and pre args (no post or opt). If var is a masgn then it is either
// n > 1 args, it includes rest, or it is a special case (for th, in @bleh). In this last case,
// we need to increase the arg count by one so our iter arg passing code will destructure the
// incoming args array and not just pass it through as a single value.
int argCount = masgn.getPreCount();
if (rest == Rest.NONE && argCount == 1) argCount = 2;
return Signature.from(argCount, 0, 0, 0, 0, rest, -1);
}
return Signature.ONE_ARGUMENT;
}
Expand Down

0 comments on commit c3a1d6c

Please sign in to comment.