-
Notifications
You must be signed in to change notification settings - Fork 215
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
Updated most of Kernel module methods #1963
base: master
Are you sure you want to change the base?
Updated most of Kernel module methods #1963
Conversation
52248e2
to
c695200
Compare
@@ -796,7 +796,7 @@ module Kernel : BasicObject | |||
# If *const* is defined as autoload, the file name to be loaded is replaced with | |||
# *filename*. If *const* is defined but not as autoload, does nothing. | |||
# | |||
def self?.autoload: (interned _module, String filename) -> NilClass | |||
def self?.autoload: (interned const, path filename) -> nil |
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.
if we ever decide to use const
as a keyword we might want to change this to constant
?
@@ -970,7 +969,9 @@ module Kernel : BasicObject | |||
# For details on `format_string`, see [Format | |||
# Specifications](rdoc-ref:format_specifications.rdoc). | |||
# | |||
def self?.format: (String format, *untyped args) -> String | |||
def self?.sprintf: (string format, hash[Symbol, untyped] keywords) -> String |
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.
Oddly enough, sprintf
only allows positional or keyword arguments, but not both.
def self?.loop: () { () -> void } -> bot | ||
| () -> ::Enumerator[nil, bot] | ||
def self?.loop: () -> Enumerator[nil, bot] | ||
| () { () -> void } -> 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.
untyped
instead of bot
because you can break
out
core/kernel.rbs
Outdated
def self?.select: ([]?, ?[]?, ?[]?, ?nil) -> bot | ||
| [R < _ToIO] (Array[R] read, ?[]?, ?[]?, ?nil ) -> [Array[R], [], []] | ||
| [R < _ToIO] (Array[R] read, []?, []?, Time::_Timeout timeout) -> [Array[R], [], []]? | ||
| [R < _ToIO, W < _ToIO] (Array[R] read, ?Array[W] write, ?[]?, ?nil ) -> [Array[R], Array[W], []] | ||
| [R < _ToIO, W < _ToIO] (Array[R] read, Array[W] write, []?, Time::_Timeout timeout) -> [Array[R], Array[W], []]? | ||
| [R < _ToIO, W < _ToIO, E < _ToIO] (Array[R] read, ?Array[W] write, ?Array[E] error, ?nil ) -> [Array[R], Array[W], Array[E]] | ||
| [R < _ToIO, W < _ToIO, E < _ToIO] (Array[R] read, Array[W] write, Array[E] error, Time::_Timeout timeout) -> [Array[R], Array[W], Array[E]]? | ||
| (Array[_ToIO]? read, ?Array[_ToIO]? write, ?Array[_ToIO]? error, ?Time_Timeout? timeout) -> [Array[_ToIO], Array[_ToIO], Array[_ToIO]]? |
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.
The ?[]?
is because you can have empty arrays or nil
as options for those arguments; the timeout can only benil
, or unspecified though.
| ('s' | 115, IO | path filename) -> Integer? | ||
| ('M' | 'A' | 'C' | 77 | 65 | 67, IO | path file) -> Time | ||
| ('-' | '=' | '<' | '>' | 45 | 60 | 61 | 62, IO | path file1, IO | path file2) -> bool | ||
| (String | int cmd, IO | path file1, ?IO | path file2) -> (bool | Integer? | Time) |
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.
this is the "catch all" case, which covers all the other variants.
@@ -1728,7 +1748,7 @@ module Kernel : BasicObject | |||
# :experimental | |||
# : Used for experimental features that may change in future releases. | |||
# | |||
def self?.warn: (*_ToS msg, ?uplevel: int?, ?category: Warning::category?) -> nil | |||
def self?.warn: (*_ToS msgs, ?uplevel: int?, ?category: Warning::category | _ToSym | nil) -> nil |
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.
One of the few places in the stdlib that uses _ToSym
and not interend
; the return value should be a Warning::category
@@ -331,7 +331,7 @@ def value(val, type) | |||
when Types::Variable | |||
true | |||
when Types::Literal | |||
type.literal == val | |||
defined?(val.==) and type.literal == val |
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.
This is needed for the Kernel#test
, as the int
variants of the "catch all" variants don't define ==
.
@@ -336,6 +336,27 @@ def break_from_block(value = nil) | |||
def pass(message = nil) | |||
assert true, message | |||
end | |||
|
|||
def assert_send_raises(sig, errclass, object, method, ...) | |||
# TODO: ensure args match with signature |
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.
TODO: The sig
is actually entirely unused currently, and needs to be updated.
51a4c8c
to
8bff31f
Compare
8bff31f
to
e4a11f4
Compare
This PR updates most of
Kernel
's module methods. Here's some things to note:Complex
,Rational
,open
,rand
,select
,exec
,spawn
, andsystem
remain. These methods will be addressed in later PRs, but are somewhat complicated, and I wanted to get this PR merged.Kernel
methods: The newassert_send_raises
doesn't actually validate the signature it's passed (instead, it only validates the raised error).def self?.XXX
syntax is used to indicatemodule_function
s. However, it doesn't mark the instance methods as private (it should be equal todef self.XXX
andprivate def XXX
).loop
with no arguments returns anEnumerator
, except theeach
method doesn't actually pass in any arguments (ieloop.each{|*x,**y,&z| break [x, y, z] }
gives you[[], {}, nil
). This means theEnumerator[nil, untyped]
interface is technically incorrect, as that implies it is given an argument. I've omitted the test, but I'm not sure what to do about it.