Skip to content

Commit

Permalink
Fix some oddity with scopes for kwargs getting mixed up.
Browse files Browse the repository at this point in the history
After removing the dynscope requirement from kwargs in
afd1906
and further fixing a mistake in that change in
6bea316
I started to see an unusual error when starting up `rake test:mri`
that this commit appears to fix. It seems like
context.getCurrentStaticScope may not be the one the interpreter
uses? Are the interpreters actually omitting dynscopes sometimes?

Here's the error. The methods involved are rather simple...perhaps
so simple they have no dynscope in the interpreter?

In any case, this bothered me when I made the original change,
and it feels better to push the upstream StaticScope through
anyway.

Here's the error:

```

/Users/headius/projects/jruby/test/mri/lib/test/unit.rb:614:in `add_status': unknown keyword: flush (ArgumentError)
	from /Users/headius/projects/jruby/test/mri/lib/test/unit.rb:614:in `update_status'
	from /Users/headius/projects/jruby/test/mri/lib/test/unit.rb:607:in `new_test'
	from /Users/headius/projects/jruby/test/mri/lib/test/unit.rb:689:in `print'
	from /Users/headius/projects/jruby/test/mri/lib/minitest/unit.rb:861:in `print'
	from /Users/headius/projects/jruby/test/mri/lib/minitest/unit.rb:938:in `block in _run_suite'
	from org/jruby/RubyArray.java:2350:in `map'
	from /Users/headius/projects/jruby/test/mri/lib/minitest/unit.rb:934:in `_run_suite'
	from /Users/headius/projects/jruby/test/mri/lib/test/unit.rb:881:in `_run_suite'
	from /Users/headius/projects/jruby/test/mri/lib/test/unit.rb:469:in `block in _run_suites'
	from org/jruby/RubyArray.java:1592:in `each'
	from /Users/headius/projects/jruby/test/mri/lib/test/unit.rb:467:in `_run_suites'
	from /Users/headius/projects/jruby/test/mri/lib/test/unit.rb:500:in `_run_suites'
	from /Users/headius/projects/jruby/test/mri/lib/minitest/unit.rb:885:in `_run_anything'
	from /Users/headius/projects/jruby/test/mri/lib/minitest/unit.rb:1096:in `run_tests'
	from /Users/headius/projects/jruby/test/mri/lib/minitest/unit.rb:1083:in `block in _run'
	from org/jruby/RubyArray.java:1592:in `each'
	from /Users/headius/projects/jruby/test/mri/lib/minitest/unit.rb:1082:in `_run'
	from /Users/headius/projects/jruby/test/mri/lib/minitest/unit.rb:1070:in `run'
	from /Users/headius/projects/jruby/test/mri/lib/test/unit.rb:650:in `run'
	from /Users/headius/projects/jruby/test/mri/lib/test/unit.rb:33:in `run'
	from /Users/headius/projects/jruby/test/mri/lib/test/unit.rb:958:in `run'
	from /Users/headius/projects/jruby/test/mri/lib/test/unit.rb:962:in `run'
	from test/mri/runner.rb:43:in `<top>'
rake aborted!
Command failed with status (1): [/Users/headius/projects/jruby/bin/jruby -r...]
/Users/headius/projects/jruby/rakelib/test.rake:82:in `block in (root)'
Tasks: TOP => test:mri => test:mri:int
(See full trace by running task with --trace)
```
headius committed May 20, 2016
1 parent a363f64 commit 8e8c3d7
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.InlineCloneInfo;
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Block;
import org.jruby.runtime.ThreadContext;

@@ -65,8 +66,8 @@ public static CheckArityInstr decode(IRReaderDecoder d) {
return new CheckArityInstr(d.decodeInt(), d.decodeInt(), d.decodeBoolean(), d.decodeBoolean(), d.decodeInt());
}

public void checkArity(ThreadContext context, Object[] args, Block.Type blockType) {
IRRuntimeHelpers.checkArity(context.runtime, context.getCurrentStaticScope(), args, required, opt, rest, receivesKeywords, restKey, blockType);
public void checkArity(ThreadContext context, StaticScope scope, Object[] args, Block.Type blockType) {
IRRuntimeHelpers.checkArity(context.runtime, scope, args, required, opt, rest, receivesKeywords, restKey, blockType);
}

@Override
Original file line number Diff line number Diff line change
@@ -384,7 +384,7 @@ protected static void processBookKeepingOp(ThreadContext context, Block block, I
context.callThreadPoll();
break;
case CHECK_ARITY:
((CheckArityInstr) instr).checkArity(context, args, block == null ? null : block.type);
((CheckArityInstr) instr).checkArity(context, currScope, args, block == null ? null : block.type);
break;
case LINE_NUM:
context.setLine(((LineNumberInstr)instr).lineNumber);

0 comments on commit 8e8c3d7

Please sign in to comment.