instance_eval does not share a variable scope with sibling evals
----------------------------------------------------------------
Key: JRUBY-3336
URL: http://jira.codehaus.org/browse/JRUBY-3336
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.1.6
Reporter: Charles Oliver Nutter
Fix For: JRuby 1.x+
In 1.8 mode, evals at the same lexical scoping level should share the same
"eval scope". (in 1.9 all evals get their own scopes) But in JRuby,
instance_eval and module_eval/class_eval do not share scopes. This leads to a
couple rubyspec failures (specs added by me):
{noformat}
1)
Kernel#instance_eval shares a scope across sibling evals FAILED
Expected to not get Exception
core/kernel/instance_eval_spec.rb:36
1)
Module#module_eval shares a scope across sibling evals FAILED
Expected to not get Exception
core/module/shared/class_eval.rb:10
{noformat}
The reason we fail this is somewhat complicated. In order to support
instance_eval having a separate "cref" class (the containing scope for constant
definition, etc), we always create a new scope for it. So with current scoping
structures there's no way to both share variables and have a different cref.
For the moment, the variable-sharing is the lesser problem (since cref *can't*
be allowed to break) so that's how I'm leaving it for now. But we'll need to
fix the scoping at some point.
--
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