Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.1.2
-
Fix Version/s: JRuby 1.1.3
-
Component/s: Core Classes/Modules
-
Labels:None
-
Environment:Latest JRuby 1.1.2
-
Number of attachments :
Description
Kernel.eval in JRuby have the following issues that actually cause some libraries (like Sinatra) to fail with JRuby:
1. ruby -ve "p eval('yield') { 'vvs' }"
ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]
"vvs"
jruby -ve "p eval('yield') { 'vvs' }"
ruby 1.8.6 (2008-06-02 rev 6586) [i386-jruby1.1.2]
: yield called out of block (LocalJumpError)
2.
def render
eval("yield", binding)
end
p render { "vvs" }
Again, JRuby raises LocalJumpError here.
I'm attaching the specs file (to be integrated into RubySpecs).
Here's the output:
mspec -f s -t /opt/ruby1.8-stable/bin/ruby eval-render.rb Kernel.eval - yields to the provided block when evaling 'yield' - does not yield to the provided block when evaling 'yield' when scope argument is present - yields to the block captured by binding - does not pass the block to the method being eval'ed Finished in 0.002724 seconds >mspec -f s -t j eval-render.rb Kernel.eval - yields to the provided block when evaling 'yield' (ERROR - 1) - does not yield to the provided block when evaling 'yield' when scope argument is present - yields to the block captured by binding (ERROR - 2) - does not pass the block to the method being eval'ed 1) Kernel.eval yields to the provided block when evaling 'yield' ERROR LocalJumpError: yield called out of block 2) Kernel.eval yields to the block captured by binding ERROR LocalJumpError: yield called out of block
See also JRUBY-2599 for the example where this problem is visible.
Attachments
Issue Links
| This issue relates to: | ||||
| JRUBY-2599 | Sinatra Web Framework fails on rendering ERB while MRI works - LocalJumpError - yield called out of block |
|
|
|
I've fixed the issue with eval 'yield', binding in r6886. The other failures, where a block is passed directly to yield, have been confirmed as unintentional behavior in Ruby 1.8, so we're not going to fix them. And they seem really wrong anyway.