The Wayback Machine - https://web.archive.org/web/20200528055858/https://github.com/opal/opal/issues/1660
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

Regression with block argument destructuring. #1660

Open
meh opened this issue May 3, 2017 · 4 comments
Open

Regression with block argument destructuring. #1660

meh opened this issue May 3, 2017 · 4 comments

Comments

@meh
Copy link
Member

@meh meh commented May 3, 2017

foo = []
"/event/:id".scan(/:(\w+)/) { |name,| foo << name }
puts foo.inspect

MRI:

["id"]

Opal:

[["id"]]
@meh meh added the bug label May 3, 2017
@meh
Copy link
Member Author

@meh meh commented May 3, 2017

It's a regression because it breaks Lissio, which used to work.

@iliabylich
Copy link
Member

@iliabylich iliabylich commented May 3, 2017

The issue seems to be caused by explicit calling block() in String#scan. Changing it to Opal.yield1/Opal.yieldX and wrapping arguments of Opal.yieldX into array makes it working correctly.

But I don't understand why there are some many block.call() invocations in corelib/stdlib. All of them don't care about args auto-expanding and trailing comma after arguments.

@elia @meh Do you have any ideas why is it written this way? Performance? atm corelib has 52 invocations of block(arg) or block.call(arg), all of them are affected by this issue.

@meh
Copy link
Member Author

@meh meh commented May 3, 2017

@iliabylich I'm 99% sure it's just historical.

@ozpos
Copy link

@ozpos ozpos commented May 18, 2018

Could this be caused by commit b0f239b (sorry my attempt at a link did no work) where in corelib/array.rb

  def <<(object)
    _back-tick_
      self.push(object);
      return self;
    _back-tick_
  end

ended up as

  def <<(object)
    _back-tick_
      self.push(object);
    _back-tick_
      self
  end

and possibly should be


  def <<(object)
    _back-tick_
      self.push(object);
      return self;
    _back-tick_
  end

Sorry I cannot verify this hypothesis but it looks suspicious to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants
You can’t perform that action at this time.