Kernel.eval with yield behaves differently than MRI 1.8.6/1.8.7, causes some libraries failures with JRuby ----------------------------------------------------------------------------------------------------------
Key: JRUBY-2605 URL: http://jira.codehaus.org/browse/JRUBY-2605 Project: JRuby Issue Type: Bug Components: Core Classes/Modules Affects Versions: JRuby 1.1.2 Environment: Latest JRuby 1.1.2 Reporter: Vladimir Sizikov Priority: Critical Attachments: eval-specs.rb 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. {noformat} def render eval("yield", binding) end p render { "vvs" } {noformat} Again, JRuby raises LocalJumpError here. I'm attaching the specs file (to be integrated into RubySpecs). Here's the output: {noformat} 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 {noformat} See also JRUBY-2599 for the example where this problem is visible. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email