Project

General

Profile

Actions

Bug #18837

open

Not possible to evaluate expression with numbered parameters in it

Added by hurricup (Alexandr Evstigneev) 10 days ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:108983]

Description

I presume it's not really a bug, but design flaw, but this is really frustrating. Use case is - debugger.

Here is script with expected behavior:

def dumper(bnd)
  puts bnd.local_variable_get 'i'
  puts bnd.eval 'i * 10'
end

[1,2].each { |i| dumper(binding) }

And this one attempts to do the same with numbered params:

def dumper(bnd)
  puts bnd.local_variable_get('_1')
  puts bnd.eval '_1 * 10'
end

[1,2].each do
  some = _1  # without this line even local_variable_get won't work, still it may be in any place of block
  dumper(binding)
end

But eval wont ever work and this necessity for using _1 so binding could see it may be confusing as well.


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #15915: `@1` cannot be achieved in meta-programmingClosedActions
Actions #1

Updated by mame (Yusuke Endoh) 10 days ago

  • Related to Feature #15915: `@1` cannot be achieved in meta-programming added
Actions

Also available in: Atom PDF