Sitelet https://github.com/opal/opal/pull/2123
Skip to content

Fix class Class < superclass for invalid superclass - #2123

Merged
elia merged 1 commit into
opal:masterfrom
davispuh:class
Jul 16, 2021
Merged

elia merged 1 commit into
opal:masterfrom
davispuh:class

Conversation

@davispuh

@davispuh davispuh commented Oct 5, 2020

Copy link
Copy Markdown
Contributor

While trying to do #2114 I found this bug that

class TestClass < BasicObject.new
end

This fails with Uncaught TypeError: can't convert undefined to object but it should raise error TypeError: superclass must be a Class (BasicObject given) like Ruby does.

Note that Class.new(BasicObject.new) works correctly.
In Ruby specs there is test for Class.new but not for class Class < superclass so they were passing, but I added such test aswell ruby/spec#792

elia
elia previously approved these changes Dec 12, 2020

@elia elia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question about the test case, otherwise looks good! 👍

Comment on lines +135 to +136
-> { class TestClass < `#{Module.new}`; end }.should raise_error(TypeError, error_msg)
-> { class TestClass < `#{BasicObject.new}`; end }.should raise_error(TypeError, error_msg)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm missing something… isn't this the same as

    -> { class TestClass < Module.new;       end }.should raise_error(TypeError, error_msg)
    -> { class TestClass < BasicObject.new;  end }.should raise_error(TypeError, error_msg)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't any reason for it, did based on similarity from others and thought maybe it does make some difference. Anyway removed it. Updated PR with your changes aswell.

@elia
elia force-pushed the class branch 3 times, most recently from 0c56663 to 2f3dfc8 Compare December 12, 2020 16:11
@elia

elia commented Dec 12, 2020

Copy link
Copy Markdown
Member

@davispuh I amended the commit to get rid of the linting issue

@elia
elia dismissed their stale review December 12, 2020 22:03

I hit approve because it's basically 👍 but I'll approve again once I understand why we need the interpolation

@hmdne hmdne added this to the v1.2 milestone Jul 14, 2021
@elia
elia merged commit d2d18e0 into opal:master Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants