-
Notifications
You must be signed in to change notification settings - Fork 219
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
Add built-in ObjectSpace definition #477
Conversation
|
||
private | ||
|
||
def garbage_collect: (?full_mark: bool, ?immediate_mark: bool, ?immediate_sweep: bool) -> void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[note] I don't know how to test this private method, so the test is not added.
ObjectSpace, :each_object, klass | ||
# NOTE: Commented out because it's too slow. | ||
# assert_send_type "() { (top) -> void } -> Integer", | ||
# ObjectSpace, :each_object do |obj| obj.to_s end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[note] If running this commented-out test, the following failure occur:
ObjectSpaceTest#test_each_object:
ArgumentError: string contains null byte
/Users/masafumi.koba/git/ybiquitous/rbs/test/stdlib/test_helper.rb:243:in `inspect'
/Users/masafumi.koba/git/ybiquitous/rbs/test/stdlib/test_helper.rb:243:in `inspect'
/Users/masafumi.koba/git/ybiquitous/rbs/test/stdlib/test_helper.rb:243:in `inspect'
/Users/masafumi.koba/git/ybiquitous/rbs/test/stdlib/test_helper.rb:243:in `assert_send_type'
/Users/masafumi.koba/git/ybiquitous/rbs/test/stdlib/objectspace_test.rb:38:in `test_each_object'
I think this PR is ready to review, but some tests are disabled still due to they are too slow. |
core/object_space.rbs
Outdated
# Total count: 7 | ||
# | ||
def self.each_object: (?Module `module`) -> Enumerator[top, Integer] | ||
| (?Module `module`) { (top obj) -> void } -> Integer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ybiquitous Do you want to make the type of obj
top
? It looks like untyped
is fine to me...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no opinion here. Should I fix also top
at other points in this file?
(I'll follow your suggestion)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Please make it untyped
. 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed via b3f2590
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll rebase the branch after approval.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ybiquitous 👍 👏
@soutaro Thank you for the review! I've squashed to one commit. |
This change adds the built-in
ObjectSpace
module definition:https://ruby-doc.org/core-2.7.2/ObjectSpace.html
Note that this change does not include the following definitions to keep the changeset small:
objspace
:https://ruby-doc.org/stdlib-2.7.2/libdoc/objspace/rdoc/ObjectSpace.html
ObjectSpace::WeakMap
:https://ruby-doc.org/core-2.7.2/ObjectSpace/WeakMap.html