[#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:66049] [ruby-trunk - Bug #10466] [Open] rb_eval_string_wrap does not actually wrap in a module binding
From:
silverhammermba+ruby@...
Date:
2014-11-02 15:39:30 UTC
List:
ruby-core #66049
Issue #10466 has been reported by Max Anselm.
----------------------------------------
Bug #10466: rb_eval_string_wrap does not actually wrap in a module binding
https://bugs.ruby-lang.org/issues/10466
* Author: Max Anselm
* Status: Open
* Priority: Normal
* Assignee:
* Category:
* Target version:
* ruby -v: ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
`rb_eval_string_wrap` says that it "evaluates the given string under a module binding in an isolated binding", but this isn't true.
Run the following:
~~~
#include <ruby.h>
int main(int argc, char* argv[])
{
ruby_init();
int state;
rb_eval_string_protect("X = 2", &state);
rb_eval_string_wrap("X = 3", &state);
rb_eval_string_protect("puts X", &state);
return ruby_cleanup(0);
}
~~~
### Expected:
outputs 2
### Actual:
outputs
~~~
eval:1: warning: already initialized constant X
eval:1: warning: previous definition of X was here
3
~~~
It looks like `rb_eval_string_wrap` _tries_ to wrap it
~~~
th->top_wrapper = rb_module_new();
th->top_self = rb_obj_clone(rb_vm_top_self());
rb_extend_object(th->top_self, th->top_wrapper);
~~~
But it ends up calling `ruby_eval_string_from_file` which uses `rb_vm_top_self()` as `self`, thus undoing the wrapping.
`rb_load` can perform similar wrapping, but there it works properly.
--
https://bugs.ruby-lang.org/