Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
olleolleolle opened this issue Nov 28, 2016 · 1 comment
Assignees
Milestone

Comments

@olleolleolle
Copy link
Member

@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 _.

Environment

  • JRuby 9.1.6.0
  • 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!" }
:a
2.3.1 :002 > a
Trollolol!
nil

It also works in 9.1.5.0:

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

Actual Behavior

jruby-9.1.6.0 :004 > define_method(:a) { |*_, &_| puts "Trollolol!" }
 => :a
jruby-9.1.6.0 :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-9.1.6.0/bin/jruby_executable_hooks:15)
	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-9.1.6.0/bin/jruby_executable_hooks:15)
	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
Copy link
Member

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 closed this as completed in a6a0479 Nov 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants