block arguments *_ and &_ at the same time fails with DynamicScope1 only supports scopes with 1 variables #4341

olleolleolle opened this Issue Nov 28, 2016 · 1 comment


None yet

3 participants


@jensnockert narrowed in this defect that happens to define_method usages with this strange usage of a block argument named _ combined with another argument called _.


  • JRuby
  • Operating system and platform: OS X, Darwin Olles-MacBook-Pro.local 15.6.0 Darwin Kernel Version 15.6.0: Thu Sep 1 15:01:16 PDT 2016; root:xnu-3248.60.11~2/RELEASE_X86_64 x86_64

Expected Behavior

JRuby to output the same as MRI.

2.3.1 :001 > define_method(:a) { |*_, &_| puts "Trollolol!" }
2.3.1 :002 > a

It also works in

jruby- :003 > define_method(:a) { |*_, &_| puts "Trollolol!" }
jruby- :004 > a

Actual Behavior

jruby- :004 > define_method(:a) { |*_, &_| puts "Trollolol!" }
 => :a
jruby- :005 > a
Java::JavaLang::RuntimeException: org.jruby.runtime.scopes.DynamicScope1 only supports scopes with 1 variables
	from org.jruby.runtime.scopes.DynamicScope1.sizeError(Unknown Source)
	from org.jruby.runtime.scopes.DynamicScope1.setValueVoid(Unknown Source)
	from org.jruby.ir.interpreter.InterpreterEngine.setResult(InterpreterEngine.java:570)
	from org.jruby.ir.interpreter.InterpreterEngine.setResult(InterpreterEngine.java:576)
	from org.jruby.ir.interpreter.StartupInterpreterEngine.processOtherOp(StartupInterpreterEngine.java:187)
	from org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:111)
	from org.jruby.ir.interpreter.Interpreter.INTERPRET_BLOCK(Interpreter.java:132)
	from org.jruby.runtime.MixedModeIRBlockBody.commonYieldPath(MixedModeIRBlockBody.java:148)
	from org.jruby.runtime.IRBlockBody.call(IRBlockBody.java:69)
	from org.jruby.runtime.Block.call(Block.java:126)
	from org.jruby.RubyProc.call(RubyProc.java:324)
	from org.jruby.internal.runtime.methods.ProcMethod.call(ProcMethod.java:63)
	from org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:196)
	from org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:192)
	from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:318)
	from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:131)
... 247 levels...
	from org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:220)
	from org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:216)
	from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:378)
	from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:227)
	from Users.olle.$_dot_rvm.gems.jruby_minus_9_dot_1_dot_6_dot_0.bin.jruby_executable_hooks.invokeOther16:eval(/Users/olle/.rvm/gems/jruby-
	from Users.olle.$_dot_rvm.gems.jruby_minus_9_dot_1_dot_6_dot_0.bin.jruby_executable_hooks.RUBY$script(/Users/olle/.rvm/gems/jruby-
	from java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
	from org.jruby.ir.Compiler$1.load(Compiler.java:111)
	from org.jruby.Ruby.runScript(Ruby.java:846)
	from org.jruby.Ruby.runNormally(Ruby.java:761)
	from org.jruby.Ruby.runNormally(Ruby.java:779)
	from org.jruby.Ruby.runFromMain(Ruby.java:592)
	from org.jruby.Main.doRunFromMain(Main.java:425)
	from org.jruby.Main.internalRun(Main.java:313)
	from org.jruby.Main.run(Main.java:242)
	from org.jruby.Main.main(Main.java:204)
@enebo enebo added this to the JRuby milestone Nov 28, 2016
@enebo enebo assigned headius and enebo and unassigned headius Nov 28, 2016
enebo commented Nov 28, 2016

I fixed this. We wallpapered over our code years ago to ignore $0 but only in staticscope whereas we should have also just removed this extra logic in the parser. The result is that staticscope only registers _ and ignores all 'fake' names ($0, _$1...) but the AST still gives that name to IRBuilder.

There is still an issue with zsuper and _ variables but I opened up #4342 for that since they exhibit different visible behavior (e.g. we don't crash in that one)/.

@enebo enebo added a commit that closed this issue Nov 28, 2016
@enebo enebo Fixes #4341. block arguments *_ and &_ at the same time fail…
…s with DynamicScope1 only supports scopes with 1 variables
@enebo enebo closed this in a6a0479 Nov 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment