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

Parse difference with MRI for un-parenthesized method calls with an un-bracketed hash argument #2562

Open
lopopolo opened this issue May 19, 2023 · 1 comment
Labels
A-parser Area: Parser implementations. A-spec Area: ruby/spec infrastructure and completeness. B-mruby Backend: Implementation of artichoke-core using mruby.

Comments

@lopopolo
Copy link
Member

This is broken in mruby @ 3.2.0, but fixed on master as of mruby/mruby@eea72ec (latest HEAD when I tested). We'll want to resync our fork.

This results in some breakage in the enforced specs. The specs themselves tend to invoke Kernel#send like this.

describe :env_update, shared: true do
  it "adds the parameter hash to ENV" do
    ENV["foo"].should == nil
    ENV.send @method, "foo" => "bar"
    ENV["foo"].should == "bar"
    ENV.delete "foo"
  end

  it "yields key, the old value and the new value when replacing entries" do
    ENV.send @method, "foo" => "bar"
    ENV["foo"].should == "bar"
    ENV.send(@method, "foo" => "boo") do |key, old, new|
      key.should == "foo"
      old.should == "bar"
      new.should == "boo"
      "rab"
    end
    ENV["foo"].should == "rab"
    ENV.delete "foo"
  end
end

which results in this spec failure:

ENV.merge! adds the parameter hash to ENV
ArgumentError: wrong number of arguments (given 1, expected 1)

MRI

$ irb
[3.2.2] > def doit(sym, hash); end
=> :doit
[3.2.2] > doit :sym, "abc" => "xyz"
=> nil

muby

Artichoke's REPL using mruby 3.2.0

$ cargo run --bin airb -q
artichoke 0.1.0-pre.0 (2023-05-18 revision 6761) [x86_64-apple-darwin]
[rustc 1.69.0 (84c898d65 2023-04-16) on x86_64-apple-darwin]
>>> def doit(sym, hash); end
=> :doit
>>> doit :sym, "abc" => "xyz"
Traceback (most recent call last):
        2: from (airb):1
        1: from (airb):1:in doit
ArgumentError (wrong number of arguments (given 1, expected 2))

mruby master @ eea72ec84a61d5f3c2180c32ecc0c34f317ff648

$ ./bin/mirb
mirb - Embeddable Interactive Ruby Shell

> def doit(sym, hash); end
 => :doit
> doit :sym, "abc" => "xyz"
 => nil
@lopopolo lopopolo added A-parser Area: Parser implementations. A-spec Area: ruby/spec infrastructure and completeness. B-mruby Backend: Implementation of artichoke-core using mruby. labels May 19, 2023
@lopopolo
Copy link
Member Author

This upstream PR looks relevant:

It looks like a small, self-contained to the parser. It should be easy to cherry-pick and see if it works.

Make sure to add a regression test in the artichoke-backend integration tests!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: Parser implementations. A-spec Area: ruby/spec infrastructure and completeness. B-mruby Backend: Implementation of artichoke-core using mruby.
Development

No branches or pull requests

1 participant