Backport #8436

__dir__ not working in eval with binding

Added by Dawid Janczak 11 months ago. Updated 10 months ago.

[ruby-core:55123]
Status:Closed
Priority:Normal
Assignee:Tomoyuki Chikanaga

Description

Hello,
I think I might have found a bug concerning the new dir method.

Given binding (e.g. current top level binding) I would expect dir to return the directory I'm in, similarly to how FILE with binding does. Instead it returns nil.

I think I have found the solution, but since this is my first modification of Ruby code it might be inaccurate and not work in some cases. I hope it points to the right location though.
Please see attached patch along with a testcase showing the problem.

I also had to modify another testcase to use realpath when checking dir functionality, please check if it's correct.

dir_eval.diff Magnifier (1.39 KB) Dawid Janczak, 05/23/2013 02:31 AM

Associated revisions

Revision 41317
Added by Tomoyuki Chikanaga 10 months ago

merge revision(s) 40759,40966,41305,41306: [Backport #8436]

vm_eval.c: suppress warning

* vm_eval.c (eval_string_with_cref): narrow a variable scope into the

EXECTAG block to suppress -Wclobberd warning.
* vm
eval.c (evalstringwith_cref): propagate absolute path from the
binding if it is given explicitly. patch by Gat (Dawid Janczak) at
. [Bug #8436]

Revision 41318
Added by Tomoyuki Chikanaga 10 months ago

merge revision(s) 41315: [Backport #8436]

vm_eval.c: suppress warning

* vm_eval.c (eval_string_with_cref): move absolute_path inside

non-exception block, since it is used only there. [Bug #8436]

Revision 42116
Added by Tomoyuki Chikanaga 9 months ago

merge revision(s) 42103: [Backport #8662]

* vm_eval.c (eval_string_with_cref): use the given file name unless
  eval even if scope is given.  additional fix for [Bug #8436].
  based on the patch by srawlins at  [Bug #8662].

History

#1 Updated by Nobuyoshi Nakada 10 months ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r41306.
Dawid, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


vmeval.c: _dir__ in eval

  • vmeval.c (evalstringwithcref): propagate absolute path from the binding if it is given explicitly. patch by Gat (Dawid Janczak) at . [Bug #8436]

#2 Updated by Nobuyoshi Nakada 10 months ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: DONTNEED, 2.0.0: REQUIRED

#3 Updated by Tomoyuki Chikanaga 10 months ago

  • Tracker changed from Bug to Backport
  • Project changed from ruby-trunk to Backport200
  • Status changed from Closed to Assigned
  • Assignee set to Tomoyuki Chikanaga

r41305 and 41306.

#4 Updated by Tomoyuki Chikanaga 10 months ago

r40759 and r40966 are also required.

#5 Updated by Tomoyuki Chikanaga 10 months ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r41317.
Dawid, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 40759,40966,41305,41306: [Backport #8436]

vm_eval.c: suppress warning

* vm_eval.c (eval_string_with_cref): narrow a variable scope into the

EXECTAG block to suppress -Wclobberd warning.
* vm
eval.c (evalstringwith_cref): propagate absolute path from the
binding if it is given explicitly. patch by Gat (Dawid Janczak) at
. [Bug #8436]

#6 Updated by Tomoyuki Chikanaga 10 months ago

  • Status changed from Closed to Assigned

add r41315.

#7 Updated by Tomoyuki Chikanaga 10 months ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r41318.
Dawid, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 41315: [Backport #8436]

vm_eval.c: suppress warning

* vm_eval.c (eval_string_with_cref): move absolute_path inside

non-exception block, since it is used only there. [Bug #8436]

Also available in: Atom PDF