Overriding require causes eval to give wrong __FILE__ in certain circumstances
------------------------------------------------------------------------------
Key: JRUBY-2328
URL: http://jira.codehaus.org/browse/JRUBY-2328
Project: JRuby
Issue Type: Bug
Reporter: Ola Bini
Assignee: Thomas E Enebo
So, say you have two files, foo1.rb and foo2.rb.
In foo1.rb:
{noformat}
eval(<<DEPS, binding, "deps")
class Object
def require(file)
super
end
end
DEPS
def something(&block)
eval("__FILE__", block.binding)
end
p eval("something { }", binding, "blah")
require 'foo2'
{noformat}
and in foo2.rb:
{noformat}
p "./foo2.rb" == (something { })
{noformat}
This should produce the output
{noformat}
"blah"
true
{noformat}
but instead generates
{noformat}
"foo1.rb"
false
{noformat}
Note that using eval to redefine require is just to avoid having three files.
You could place the code in the string DEPS in a separate file and require that
file, and the same effect would happen. It seems that the overriding of require
in some way doesn't pass along the correct name information.
This breaks when using "dust" with ActiveSupport, and also breaks JtestR (which
uses dust and ActiveSupport).
--
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