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

Super on Array #467

Closed
ryanstout opened this issue Dec 24, 2013 · 2 comments
Closed

Super on Array #467

ryanstout opened this issue Dec 24, 2013 · 2 comments

Comments

@ryanstout
Copy link
Contributor

Found an issue with super on arrays.

class BetterArray < Array
  def test
    @count += 1
  end
end

class WayBetterArray < BetterArray
  attr_reader :count
  def test
    @count = 1
    super
  end
end

describe Array do
  it "should call super" do
    WayBetterArray.new.test.should == 2
  end
end

Thanks

@meh
Copy link
Member

meh commented Dec 26, 2013

From a hasty look I don't think this is caused by the hack to implement array inheritance, it's probably just a super bug.

@elia elia modified the milestones: 0.7, 0.6 Apr 8, 2014
@elia elia modified the milestone: 0.7 Sep 27, 2014
@elia elia added the super label May 5, 2015
@elia
Copy link
Member

elia commented Feb 29, 2016

Seems to be fixed on master (5f49850):

opal:master ⤑ be bin/opal -e '                                                                                                                                            ~/C/opal
              class BetterArray < Array
                def test
                  @count += 1
                end
              end

              class WayBetterArray < BetterArray
                attr_reader :count
                def test
                  @count = 1
                  super
                end
              end

              p WayBetterArray.new.test
              '
2
opal:master ⤑                                                                                                                                                             ~/C/opal

@elia elia closed this as completed Feb 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants