core/kernel.rbs in rbs-3.2.0.pre.1 vs core/kernel.rbs in rbs-3.2.0

- old
+ new

@@ -298,11 +298,11 @@ # end # str = "hello" # eval "str + ' Fred'" #=> "hello Fred" # eval "str + ' Fred'", get_binding("bye") #=> "bye Fred" # - def self?.eval: (String arg0, ?Binding arg1, ?String filename, ?Integer lineno) -> untyped + def self?.eval: (string src, ?Binding? scope, ?string filename, ?int lineno) -> untyped # <!-- # rdoc-file=vm_eval.c # - block_given? -> true or false # --> @@ -356,11 +356,11 @@ # [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319] # [ rand(10), rand(1000) ] # => [4, 664] # srand 1234 # => 1234 # [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319] # - def self?.srand: (?Numeric number) -> Numeric + def self?.srand: (?int number) -> Integer # <!-- # rdoc-file=process.c # - Kernel.fork [{ block }] -> integer or nil # - Process.fork [{ block }] -> integer or nil @@ -381,11 +381,11 @@ # # Note that fork(2) is not available on some platforms like Windows and NetBSD # 4. Therefore you should use spawn() instead of fork(). # def self?.fork: () -> Integer? - | () { () -> untyped } -> Integer? + | () { () -> void } -> Integer def initialize_copy: (self object) -> self # <!-- # rdoc-file=object.c @@ -401,16 +401,14 @@ # # Returns `object` in an array, `[object]`, if `object` cannot be converted: # # Array(:foo) # => [:foo] # - def self?.Array: (NilClass x) -> [ ] - | [T] (::Array[T] x) -> ::Array[T] - | [T] (::Range[T] x) -> ::Array[T] - | [T] (_Each[T] x) -> ::Array[T] - | [K, V] (::Hash[K, V] x) -> ::Array[[ K, V ]] - | [T] (T x) -> ::Array[T] + def self?.Array: (nil) -> [] + | [T] (Array[T] ary) -> Array[T] + | [T] (_ToAry[T] | _ToA[T] array_like) -> Array[T] + | [T] (T ele) -> [T] # <!-- # rdoc-file=complex.c # - Complex(x[, y], exception: true) -> numeric or nil # --> @@ -444,11 +442,15 @@ # digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; # extra spaces = ? \s* ? ; # # See String#to_c. # - def self?.Complex: (Numeric | String x, ?Numeric | String y, ?exception: bool exception) -> Complex + def self?.Complex: (_ToC complex_like, ?exception: true) -> Complex + | (_ToC complex_like, exception: bool) -> Complex? + | (Numeric | String real, ?Numeric | String imag, ?exception: true) -> Complex + | (Numeric | String real, ?Numeric | String imag, exception: bool) -> Complex? + | (untyped, ?untyped, exception: false) -> nil # <!-- # rdoc-file=kernel.rb # - Float(arg, exception: true) -> float or nil # --> @@ -462,11 +464,13 @@ # Float("123.456") #=> 123.456 # Float("123.0_badstring") #=> ArgumentError: invalid value for Float(): "123.0_badstring" # Float(nil) #=> TypeError: can't convert nil into Float # Float("123.0_badstring", exception: false) #=> nil # - def self?.Float: (Numeric | String x, ?exception: bool exception) -> Float + def self?.Float: (_ToF float_like, ?exception: true) -> Float + | (_ToF float_like, exception: bool) -> Float? + | (untyped, exception: false) -> nil # <!-- # rdoc-file=object.c # - Hash(object) -> object or new_hash # --> @@ -486,11 +490,12 @@ # # Hash({foo: 0, bar: 1}) # => {:foo=>0, :bar=>1} # Hash(nil) # => {} # Hash([]) # => {} # - def self?.Hash: [K, V] (Object x) -> ::Hash[K, V] + def self?.Hash: [K, V] (nil | [] _empty) -> Hash[K, V] + | [K, V] (_ToHash[K, V] hash_like) -> Hash[K, V] # <!-- # rdoc-file=object.c # - Integer(object, base = 0, exception: true) -> integer or nil # --> @@ -572,12 +577,15 @@ # # # With `exception` given as `false`, an exception of any kind is suppressed and # `nil` is returned. # - def self?.Integer: (Numeric | String arg, ?exception: bool exception) -> Integer - | (String arg, ?Integer base, ?exception: bool exception) -> Integer + def self?.Integer: (_ToInt | _ToI int_like, ?exception: true) -> Integer + | (_ToInt | _ToI int_like, exception: bool) -> Integer? + | (string str, ?int base, ?exception: true) -> Integer + | (string str, ?int base, exception: bool) -> Integer? + | (untyped, ?untyped, exception: false) -> nil # <!-- # rdoc-file=rational.c # - Rational(x, y, exception: true) -> rational or nil # - Rational(arg, exception: true) -> rational or nil @@ -612,12 +620,22 @@ # digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; # extra spaces = ? \s* ? ; # # See also String#to_r. # - def self?.Rational: (Numeric | String | Object x, ?Numeric | String y, ?exception: bool exception) -> Rational + def self?.Rational: (_ToInt | _ToR rational_like, ?exception: true) -> Rational + | (_ToInt | _ToR rational_like, exception: bool) -> Rational? + | (_ToInt | _ToR numer, ?_ToInt | _ToR denom, ?exception: true) -> Rational + | (_ToInt | _ToR numer, ?_ToInt | _ToR denom, exception: bool) -> Rational? + | [T] (Numeric&_RationalDiv[T] numer, Numeric denom, ?exception: bool) -> T + | [T < Numeric] (T value, 1, ?exception: bool) -> T + | (untyped, ?untyped, exception: false) -> nil + interface _RationalDiv[T] + def /: (Numeric) -> T + end + # <!-- # rdoc-file=object.c # - String(object) -> object or new_string # --> # Returns a string converted from `object`. @@ -628,11 +646,11 @@ # String(0..5) # => "0..5" # String({foo: 0, bar: 1}) # => "{:foo=>0, :bar=>1}" # # Raises `TypeError` if `object` cannot be converted to a string. # - def self?.String: (_ToStr | _ToS x) -> String + def self?.String: (string | _ToS string_like) -> String # <!-- # rdoc-file=eval.c # - __callee__ -> symbol # --> @@ -689,11 +707,11 @@ # - Process.abort([msg]) # --> # Terminate execution immediately, effectively by calling `Kernel.exit(false)`. # If *msg* is given, it is written to STDERR prior to terminating. # - def self?.abort: (?String msg) -> bot + def self?.abort: (?string msg) -> bot # <!-- # rdoc-file=eval_jump.c # - at_exit { block } -> proc # --> @@ -710,11 +728,11 @@ # # *produces:* # # goodbye cruel world # - def self?.at_exit: () { () -> untyped } -> Proc + def self?.at_exit: () { () -> void } -> Proc # <!-- # rdoc-file=load.c # - autoload(const, filename) -> nil # --> @@ -793,23 +811,22 @@ # *produces:* # # at_exit function # in finalizer # - def self?.exit: () -> bot - | (?Integer | TrueClass | FalseClass status) -> bot + def self?.exit: (?int | bool status) -> bot # <!-- # rdoc-file=process.c # - Process.exit!(status=false) # --> # Exits the process immediately. No exit handlers are run. *status* is returned # to the underlying system as the exit status. # # Process.exit!(true) # - def self?.exit!: (?Integer | TrueClass | FalseClass status) -> bot + def self?.exit!: (?int | bool status) -> bot # <!-- rdoc-file=eval.c --> # With no arguments, raises the exception in `$!` or raises a RuntimeError if # `$!` is `nil`. With a single `String` argument, raises a `RuntimeError` with # the string as a message. Otherwise, the first parameter should be an @@ -826,12 +843,12 @@ # # raise "Failed to create socket" # raise ArgumentError, "No parameters", caller # def self?.fail: () -> bot - | (String message, ?cause: Exception?) -> bot - | (_Exception exception, ?untyped message, ?::Array[String] backtrace, ?cause: Exception?) -> bot + | (string message, ?cause: Exception?) -> bot + | (_Exception exception, ?_ToS? message, ?nil | String | Array[String] backtrace, ?cause: Exception?) -> bot # <!-- # rdoc-file=eval.c # - raise # - raise(string, cause: $!) @@ -986,11 +1003,11 @@ # # result = loop { # puts enum.next # } #=> :ok # - def self?.loop: () { (nil) -> untyped } -> bot + def self?.loop: () { () -> void } -> bot | () -> ::Enumerator[nil, bot] # <!-- # rdoc-file=io.c # - open(path, mode = 'r', perm = 0666, **opts) -> io or nil @@ -1135,11 +1152,11 @@ # recent user input): # # gets # Sets $_ to the most recent user input. # print # Prints $_. # - def self?.print: (*Kernel args) -> nil + def self?.print: (*_ToS args) -> nil # <!-- # rdoc-file=io.c # - printf(format_string, *objects) -> nil # - printf(io, format_string, *objects) -> nil @@ -1169,13 +1186,13 @@ # # 0024 24 24.00# => nil # # With no arguments, does nothing. # - def self?.printf: (IO arg0, String arg1, *untyped args) -> nil - | (String arg1, *untyped args) -> nil - | () -> nil + def self?.printf: () -> nil + | (String fmt, *untyped args) -> nil + | (_Writer io, string fmt, *untyped args) -> nil # <!-- # rdoc-file=proc.c # - proc { |...| block } -> a_proc # --> @@ -1200,22 +1217,22 @@ # # $stdout.putc(int) # # See IO#putc for important information regarding multi-byte characters. # - def self?.putc: (Integer arg0) -> Integer - | (String arg0) -> String + def self?.putc: [T < _ToInt] (T chr) -> T + | (String chr) -> String # <!-- # rdoc-file=io.c # - puts(*objects) -> nil # --> # Equivalent to # # $stdout.puts(objects) # - def self?.puts: (*untyped arg0) -> NilClass + def self?.puts: (*_ToS objects) -> nil # <!-- # rdoc-file=io.c # - p(object) -> obj # - p(*objects) -> array of objects @@ -1238,12 +1255,12 @@ # Output: # # 0..4 # [0..4, 0..4, 0..4] # - def self?.p: [T] (T arg0) -> T - | (untyped, untyped, *untyped) -> Array[untyped] + def self?.p: [T < _Inspect] (T arg0) -> T + | (_Inspect arg0, _Inspect arg1, *_Inspect rest) -> Array[_Inspect] | () -> nil # <!-- # rdoc-file=lib/pp.rb # - pp(*objs) @@ -1548,11 +1565,11 @@ # sleep 1.2 #=> 1 # Time.new #=> 2008-03-08 19:56:20 +0900 # sleep 1.9 #=> 2 # Time.new #=> 2008-03-08 19:56:22 +0900 # - def self?.sleep: () -> bot + def self?.sleep: (?nil) -> bot | ((Integer | Float | _Divmod) duration) -> Integer interface _Divmod def divmod: (Numeric) -> [ Numeric, Numeric ] end @@ -1648,11 +1665,11 @@ # Transfers control to the end of the active `catch` block waiting for *tag*. # Raises `UncaughtThrowError` if there is no `catch` block for the *tag*. The # optional second parameter supplies a return value for the `catch` block, which # otherwise defaults to `nil`. For examples, see Kernel::catch. # - def self?.throw: (Object tag, ?untyped obj) -> bot + def self?.throw: (untyped tag, ?untyped obj) -> bot # <!-- # rdoc-file=warning.rb # - warn(*msgs, uplevel: nil, category: nil) -> nil # --> @@ -1695,10 +1712,10 @@ # : Used for warning for deprecated functionality that may be removed in the # future. # :experimental # : Used for experimental features that may change in future releases. # - def self?.warn: (*untyped msg, ?uplevel: Integer | nil, ?category: :deprecated | :experimental | nil) -> NilClass + def self?.warn: (*_ToS msg, ?uplevel: int?, ?category: Warning::category?) -> nil # <!-- # rdoc-file=process.c # - exec([env,] command... [,options]) # -->