[ruby-core:116972] [Ruby master Bug#20308] `it` and numbered parameters do not work in `eval`
From:
"matheusrich (Matheus Richard) via ruby-core" <ruby-core@...>
Date:
2024-02-27 16:34:00 UTC
List:
ruby-core #116972
Issue #20308 has been updated by matheusrich (Matheus Richard).
Interesting behavior. I'd expect that to work since other "kinds of arguments" work:
```rb
def foo(*)
eval "puts(*)"
end
def foo(**)
eval "puts(**)"
end
def foo(...)
eval "puts(...)"
end
```
----------------------------------------
Bug #20308: `it` and numbered parameters do not work in `eval`
https://bugs.ruby-lang.org/issues/20308#change-107019
* Author: kddnewton (Kevin Newton)
* Status: Open
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
I am not sure if this is a purposeful restriction or not, so I apologize if this is not a "bug" per se.
Currently if you use `it` or `_1` (numbered parameters) in `eval` they do not work with `compile.c`:
```
irb(main):001> 1.tap { eval("_1") }
(eval):1:in `block in <top (required)>': undefined local variable or method `_1' for main:Object (NameError)
Did you mean? _
```
They work accidentally with prism because I didn't know this wasn't allowed. Is it a bug? Or is this on purpose?
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/