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

Fix Array#concat signature on subclasses #648

Merged
merged 1 commit into from Mar 16, 2021
Merged

Fix Array#concat signature on subclasses #648

merged 1 commit into from Mar 16, 2021

Conversation

kachick
Copy link
Member

@kachick kachick commented Mar 15, 2021

$ ruby -v -e 'p Class.new(Array).new.concat.class'
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20]
#<Class:0x00007ff93307abf0>
$ ruby -v -e 'p Class.new(Array).new.concat.class'
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin20]
#<Class:0x00007faa0010d2e8>

Comment on lines +220 to +221
assert_send_type "(Array[Integer], Array[Integer]) -> self",
Class.new(Array).new, :concat, [4,5,6], [7,8,9]
Copy link
Member Author

Choose a reason for hiding this comment

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

I don’t know why even in without changing signature, this added test passed. But adding it makes better, I think.
Please tell me a way if rbs have something to ensure it. 🙏

Copy link
Member

Choose a reason for hiding this comment

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

Good point. The test passes because Class.new(Array).new.is_a?(Array) holds. The runtime type checker can be improved...

Copy link
Member Author

Choose a reason for hiding this comment

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

😮 Thank you for letting me know the why!

Copy link
Member

@soutaro soutaro left a comment

Choose a reason for hiding this comment

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

👍

@soutaro soutaro merged commit 0fda54d into ruby:master Mar 16, 2021
@kachick
Copy link
Member Author

kachick commented Mar 16, 2021

Thank you!

@kachick kachick deleted the fix-array-subclass-concat branch March 16, 2021 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants