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

Passing a default parameter to a block causes an exception. #4013

Closed
samphippen opened this Issue Jul 13, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@samphippen

samphippen commented Jul 13, 2016

Environment

Provide at least:

  • JRuby version jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) 64-Bit Server VM 25.5-b02 on 1.8.0_05-b13 +jit [darwin-x86_64] no jruby opts.
  • Operating system and platform Darwin Computer-2.local 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64

Originally reported as: rspec/rspec-dev#163

Expected Behavior

Actual Behavior

(master)$ ruby hi_spec.rb
Unhandled Java exception: java.lang.ClassCastException: org.jruby.RubyNil cannot be cast to org.jruby.parser.StaticScope
java.lang.ClassCastException: org.jruby.RubyNil cannot be cast to org.jruby.parser.StaticScope
             cache at org/jruby/ir/instructions/SearchConstInstr.java:82
    processOtherOp at org/jruby/ir/interpreter/StartupInterpreterEngine.java:173
         interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:115
   INTERPRET_BLOCK at org/jruby/ir/interpreter/Interpreter.java:132
   commonYieldPath at org/jruby/runtime/MixedModeIRBlockBody.java:148
              call at org/jruby/runtime/IRBlockBody.java:66
              call at org/jruby/runtime/Block.java:126
              call at org/jruby/RubyProc.java:342
            call19 at org/jruby/RubyProc.java:326
              call at org/jruby/internal/runtime/methods/DynamicMethod.java:193
              call at org/jruby/internal/runtime/methods/DynamicMethod.java:189
      cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:293
              call at org/jruby/runtime/callsite/CachingCallSite.java:131
       processCall at org/jruby/ir/interpreter/InterpreterEngine.java:332
         interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:77
  INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:109
              call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:95
      cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:273
         callBlock at org/jruby/runtime/callsite/CachingCallSite.java:79
              call at org/jruby/runtime/callsite/CachingCallSite.java:83
         interpret at org/jruby/ir/instructions/CallBase.java:423
       processCall at org/jruby/ir/interpreter/InterpreterEngine.java:348
         interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:77
    INTERPRET_ROOT at org/jruby/ir/interpreter/Interpreter.java:112
           execute at org/jruby/ir/interpreter/Interpreter.java:99
           execute at org/jruby/ir/interpreter/Interpreter.java:35
           execute at org/jruby/ir/IRTranslator.java:42
    runInterpreter at org/jruby/Ruby.java:868
    runInterpreter at org/jruby/Ruby.java:873
       runNormally at org/jruby/Ruby.java:765
       runFromMain at org/jruby/Ruby.java:579
     doRunFromMain at org/jruby/Main.java:425
       internalRun at org/jruby/Main.java:313
               run at org/jruby/Main.java:242
              main at org/jruby/Main.java:204

@samphippen samphippen changed the title from Passing a default parameter that is a to Passing a default parameter to a block causes an exception. Jul 13, 2016

@enebo enebo added this to the JRuby 9.1.3.0 milestone Jul 13, 2016

@enebo enebo added the ir label Jul 13, 2016

@enebo

This comment has been minimized.

Show comment
Hide comment
@enebo

enebo Jul 13, 2016

Member

Testing fix now. Problem is for iters (e.g. not syntactical lambdas). We add our scope loading instrs after we processed default argument instrs so no scope was setup. Largely, constants are the most common reason to need a scope so we would not have seen this with proc {|a=1} }.

Member

enebo commented Jul 13, 2016

Testing fix now. Problem is for iters (e.g. not syntactical lambdas). We add our scope loading instrs after we processed default argument instrs so no scope was setup. Largely, constants are the most common reason to need a scope so we would not have seen this with proc {|a=1} }.

@enebo

This comment has been minimized.

Show comment
Hide comment
@enebo

enebo Jul 13, 2016

Member

Fixed in commit 8e6192f

Member

enebo commented Jul 13, 2016

Fixed in commit 8e6192f

@enebo enebo closed this Jul 13, 2016

@samphippen

This comment has been minimized.

Show comment
Hide comment
@samphippen

samphippen Jul 13, 2016

Thanks so much @enebo :)

samphippen commented Jul 13, 2016

Thanks so much @enebo :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment