Skip to content

mruby-proc-ext: #parameters mistakes keyword "splat" for a block parameter #5066

Description

@ntl

Hello, thanks so much for MRuby!

I'm currently investigating some behavior in Proc#parameters (from mrbgems/mruby-proc-ext), and believe I may have spotted a bug (or else I am unaware of the expected behavior). Here is a file that reproduces my issue (I put it in a test project under e.g. mrblib/bug_example.rb):

class BugExample
  def all_method(reqp, optp=nil, *restp, keyreqp:, keyp: nil, **keyrestp, &blockp)
    Invocation::Binding.get
  end
end

example = BugExample.new

puts example.method(:all_method).parameters.inspect

When I run the above code, with mruby-proc-ext (and mruby-io, for #puts), I see the following output:

[[:req, :reqp], [:opt, :optp], [:rest, :restp], [:block, :keyrestp]]

This indicates that the **keyrestp parameter has been interpreted as a block parameter. I'm not sure how keyword arguments are handled internally by MRuby, but I believe the expected output is this:

[[:req, :reqp], [:opt, :optp], [:rest, :restp], [:keyreq, :keyreqp], [:key, :keyp], [:keyrest, :keyrestp], [:block, :blockp]]

I'm not sure how mruby-proc-ext is supposed to work with keyword arguments. I have discovered that the keyword arguments appear to be placed in the stack after the block argument (and mrb->c->ci->argc does not indicate their presence; only ci_nregs in src/vm.c, line 405).

I am very new to MRuby, though, so I realize I may be in error here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions