[ruby-core:79080] [Ruby trunk Bug#13126] __dir__ in eval returns nil

From: nobu@...
Date: 2017-01-15 00:15:44 UTC
List: ruby-core #79080
Issue #13126 has been updated by Nobuyoshi Nakada.


Artem Shein wrote:
> I've replaced the "`File.dirname(File.realpath(__FILE__))`" in my source code with "`__dir__`" and got different result. I don't care about the exact value, but I expect it to be the same.

The former also does not work in `eval` as expected unless a real path name is given.
Please elaborate on the concrete code.

----------------------------------------
Bug #13126: __dir__ in eval returns nil
https://bugs.ruby-lang.org/issues/13126#change-62487

* Author: Artem Shein
* Status: Feedback
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
~~~
$ ruby -e 'eval "p File.dirname(__FILE__); p __dir__"'
"."
nil
~~~




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next