Project

General

Profile

Actions

Bug #21778

closed

Binding#eval vs implicit parameters

Bug #21778: Binding#eval vs implicit parameters

Added by zverok (Victor Shepelev) about 14 hours ago. Updated about 5 hours ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:124183]

Description

This works:

proc { |x| binding.eval('x') }.call(1) #=> 1

This doesn't (neither with numbered parameters, nor with it):

proc { _1; binding.eval('_1') }.call(1) # undefined local variable or method '_1' for main (NameError)

...even though binding is "aware" of _1 existence with implicit_parameters.

I don't think it is a "huge" bug or even practical one. I just wanted to highlight that maybe Binding#eval lacks some context that it should have?..

Or maybe it is my misunderstanding of Binding#eval, I expected that any code that will work in the place of a binding literally, should work in eval as well.


Related issues 1 (0 open1 closed)

Related to Ruby - Bug #21049: Reconsider handling of the numbered parameters and "it" parameter in `Binding#local_variables`Closedmatz (Yukihiro Matsumoto)Actions

Updated by mame (Yusuke Endoh) about 5 hours ago Actions #1

  • Related to Bug #21049: Reconsider handling of the numbered parameters and "it" parameter in `Binding#local_variables` added

Updated by mame (Yusuke Endoh) about 5 hours ago Actions #2 [ruby-core:124188]

  • Status changed from Open to Rejected

This was pointed by @ko1 (Koichi Sasada) at the dev meeting in the discussion of #21049, and we agreed not to implement it. Implementing it would require the parser to accept more detailed outer context, and that effort was not worth. Sorry it wasn't clearly written in the dev meeting log.

Actions

Also available in: PDF Atom