Skip to content

Fixed argument forwarding in instance_exec#6391

Merged
matz merged 2 commits into
mruby:masterfrom
dearblue:instance_exec
Oct 24, 2024
Merged

Fixed argument forwarding in instance_exec#6391
matz merged 2 commits into
mruby:masterfrom
dearblue:instance_exec

Conversation

@dearblue

Copy link
Copy Markdown
Contributor

However, on C, there is no easy way to pass keyword arguments. Therefore, when called Kernel#instance_exec on C, keyword arguments are converted to positional arguments. This is a limitation of current mruby.

fixed #6389


During our work we found two problems.

One had to do with commit messages, and calling mrb_exec_irep() from C did not pass arguments.
The other was that calls like instance_exec(1, 2, 3, &:puts) would result in a __send__: main is not a symbol nor a string (TypeError) exception.

I will put these together a bit more and add each as a separate issue.

@matz

matz commented Oct 23, 2024

Copy link
Copy Markdown
Member

Thank you! The same change is probably needed for Class#class_exec in mruby-class-ext too.

@dearblue

Copy link
Copy Markdown
Contributor Author

Thank you for the review.
I see, indeed. I will update.

However, on C, there is no easy way to pass keyword arguments.
Therefore, when called `Kernel#instance_exec` on C, keyword arguments are converted to positional arguments.
This is a limitation of current mruby.

fixed mruby#6389
@dearblue

Copy link
Copy Markdown
Contributor Author

Main changes.

  • Fixed argument transfer in Module#class_exec as well.
  • Added a common function mrb_object_exec() called from class_exec and instance_exec in src/vm.c.

And the argument transfer problem with mrb_exec_irep() called from C. It was not difficult to fix.
It is sent as a separate PR.
If that one is taken in first, the branch that calls mrb_yield_with_classs() in mrb_object_exec() in this PR becomes unnecessary.

@matz
matz merged commit 49b9db2 into mruby:master Oct 24, 2024
dearblue added a commit to dearblue/mruby that referenced this pull request Oct 25, 2024
The mruby#6392 has been merged, so the call to `mrb_yield_with_class()` is no longer needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

instance_exec named block args don't work properly

2 participants