[#66126] Creation/Conversion methods/functions table for Ruby types — SASADA Koichi <ko1@...>
Hi,
5 messages
2014/11/07
[#66248] [ruby-trunk - Feature #10423] [PATCH] opt_str_lit*: avoid literal string allocations — normalperson@...
Issue #10423 has been updated by Eric Wong.
3 messages
2014/11/13
[#66595] [ruby-trunk - Bug #10557] [Open] Block not given when the argument is a string — bartosz@...
Issue #10557 has been reported by Bartosz Kopinski.
3 messages
2014/11/30
[ruby-core:66287] [ruby-trunk - misc #10513] [Open] instance_eval yields the receiver, but is documented to yield no arguments
From:
ctm@...
Date:
2014-11-14 22:29:50 UTC
List:
ruby-core #66287
Issue #10513 has been reported by Cliff Matthews.
----------------------------------------
misc #10513: instance_eval yields the receiver, but is documented to yield no arguments
https://bugs.ruby-lang.org/issues/10513
* Author: Cliff Matthews
* Status: Open
* Priority: Low
* Assignee: Zachary Scott
* Category: doc
* Target version:
----------------------------------------
instance_eval yields the receiver, but is documented as yielding no arguments.
I searched the bug reports before writing this up and found bug #2476 which was closed with a message that contained "instance_eval yields the receiver in both 1.8 and 1.9. Unfortunately, a Proc object created by lambda raises ArgumentError when extra arguments are yielded in 1.9.". However such behavior is not expected when the calling sequence is:
~~~
* call-seq:
* obj.instance_eval(string [, filename [, lineno]] ) -> obj
* obj.instance_eval {| | block } -> obj
~~~
This discrepancy surprised me, but once I realized what was going on I simply used instance_exec instead of instance_eval. All else equal, I would prefer for instance_eval to to not yield the receiver since I can pick up the receiver as self if I want to, but such a change could breaking existing code, so probably documenting the current behavior is better.
~~~
bash-3.2$ ruby --version
ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin14.0]
bash-3.2$ ./instance_eval
This is the lambda that *does* work.
arg = 32
self = 32
./instance_eval:6:in `block in <main>': wrong number of arguments (1 for 0) (ArgumentError)
from ./instance_eval:17:in `instance_eval'
from ./instance_eval:17:in `<main>'
~~~
---Files--------------------------------
instance_eval (561 Bytes)
--
https://bugs.ruby-lang.org/