Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eval does nothing when directly called via mrb_funcall #3522

Closed
i110 opened this issue Mar 16, 2017 · 0 comments
Closed

eval does nothing when directly called via mrb_funcall #3522

i110 opened this issue Mar 16, 2017 · 0 comments

Comments

@i110
Copy link
Contributor

i110 commented Mar 16, 2017

After 48e0bbb, the following code says nothing:

int main(int argc, char **argv)
{
    mrb_state *mrb = mrb_open();

    mrb_value code = mrb_str_new_cstr(mrb, "puts :hoge");
    mrb_funcall(mrb, mrb_top_self(mrb), "eval", 1, code);

    mrb_close(mrb);
}

while before that commit (as far as I know at 4325707), it output hoge, which is expected behavior.

I looked eval.c and vm.c, then I found it's not designed to call eval directly via mrb_funcall and others. Is this change what you intended?

FYI: I found the following workaround works well (but looks bad)

mrb_value proc = mrb_load_string(mrb, "Proc.new do |code| eval code end");
mrb_funcall(mrb, proc, "call", 1, code);
@i110 i110 changed the title eval do nothing when directly called via mrb_funcall eval does nothing when directly called via mrb_funcall Mar 16, 2017
@matz matz closed this as completed in fca17b4 Mar 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant