rbs 3.4.4 → 3.5.0.pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +7 -0
- data/CHANGELOG.md +0 -26
- data/Gemfile +12 -1
- data/Gemfile.lock +51 -34
- data/README.md +2 -1
- data/Rakefile +2 -2
- data/core/enumerator.rbs +1 -1
- data/core/gc.rbs +272 -150
- data/core/integer.rbs +4 -3
- data/core/io/wait.rbs +4 -4
- data/core/io.rbs +10 -3
- data/core/kernel.rbs +8 -7
- data/core/module.rbs +17 -4
- data/core/range.rbs +2 -2
- data/core/regexp.rbs +101 -90
- data/core/ruby_vm.rbs +103 -103
- data/core/string.rbs +3 -3
- data/core/symbol.rbs +2 -1
- data/core/thread.rbs +1 -1
- data/core/time.rbs +24 -4
- data/docs/architecture.md +110 -0
- data/docs/syntax.md +5 -1
- data/ext/rbs_extension/constants.c +2 -0
- data/ext/rbs_extension/constants.h +1 -0
- data/ext/rbs_extension/location.c +79 -70
- data/ext/rbs_extension/location.h +23 -5
- data/ext/rbs_extension/parser.c +82 -24
- data/ext/rbs_extension/parserstate.c +4 -0
- data/ext/rbs_extension/ruby_objs.c +13 -3
- data/ext/rbs_extension/ruby_objs.h +1 -0
- data/lib/rbs/collection/config.rb +1 -1
- data/lib/rbs/collection/sources/git.rb +1 -6
- data/lib/rbs/definition_builder/method_builder.rb +1 -1
- data/lib/rbs/definition_builder.rb +8 -8
- data/lib/rbs/diff.rb +1 -1
- data/lib/rbs/environment_loader.rb +2 -1
- data/lib/rbs/errors.rb +0 -14
- data/lib/rbs/parser_aux.rb +0 -5
- data/lib/rbs/prototype/helpers.rb +22 -12
- data/lib/rbs/prototype/rb.rb +38 -4
- data/lib/rbs/prototype/rbi.rb +30 -20
- data/lib/rbs/test/errors.rb +19 -14
- data/lib/rbs/test/tester.rb +1 -1
- data/lib/rbs/test/type_check.rb +95 -16
- data/lib/rbs/types.rb +112 -13
- data/lib/rbs/unit_test/spy.rb +1 -1
- data/lib/rbs/version.rb +1 -1
- data/rbs.gemspec +1 -1
- data/sig/environment_loader.rbs +1 -1
- data/sig/errors.rbs +1 -1
- data/sig/method_types.rbs +3 -3
- data/sig/prototype/helpers.rbs +4 -0
- data/sig/prototype/rbi.rbs +2 -0
- data/sig/types.rbs +54 -4
- data/sig/variance_calculator.rbs +2 -2
- data/stdlib/csv/0/csv.rbs +4 -1
- data/stdlib/fileutils/0/fileutils.rbs +1 -1
- data/stdlib/net-http/0/net-http.rbs +29 -27
- data/stdlib/socket/0/socket.rbs +2 -2
- data/stdlib/timeout/0/timeout.rbs +6 -0
- data/stdlib/uri/0/generic.rbs +2 -2
- data/stdlib/uri/0/http.rbs +2 -2
- metadata +3 -6
- data/lib/rbs/parser_compat/lexer_error.rb +0 -6
- data/lib/rbs/parser_compat/located_value.rb +0 -7
- data/lib/rbs/parser_compat/semantics_error.rb +0 -6
- data/lib/rbs/parser_compat/syntax_error.rb +0 -6
data/core/regexp.rbs
CHANGED
@@ -1332,56 +1332,41 @@
|
|
1332
1332
|
# * [Rubular](https://rubular.com/).
|
1333
1333
|
#
|
1334
1334
|
class Regexp
|
1335
|
-
#
|
1336
|
-
# rdoc-file=re.c
|
1337
|
-
# - Regexp.new(string, options = 0, timeout: nil) -> regexp
|
1338
|
-
# - Regexp.new(regexp, timeout: nil) -> regexp
|
1339
|
-
# -->
|
1340
|
-
# With argument `string` given, returns a new regexp with the given string and
|
1341
|
-
# options:
|
1342
|
-
#
|
1343
|
-
# r = Regexp.new('foo') # => /foo/
|
1344
|
-
# r.source # => "foo"
|
1345
|
-
# r.options # => 0
|
1346
|
-
#
|
1347
|
-
# Optional argument `options` is one of the following:
|
1348
|
-
#
|
1349
|
-
# * A String of options:
|
1335
|
+
# Represents an object's ability to be converted to a `Regexp`.
|
1350
1336
|
#
|
1351
|
-
#
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
#
|
1361
|
-
#
|
1362
|
-
# Regexp.new('foo', flags) # => /foo/mix
|
1363
|
-
#
|
1364
|
-
# * `nil` or `false`, which is ignored.
|
1365
|
-
# * Any other truthy value, in which case the regexp will be case-insensitive.
|
1337
|
+
# This is only used in `Regexp.try_convert` and `Regexp.union` within the standard library.
|
1338
|
+
interface _ToRegexp
|
1339
|
+
# Converts `self` to a `Regexp`.
|
1340
|
+
def to_regexp: () -> Regexp
|
1341
|
+
end
|
1342
|
+
|
1343
|
+
class TimeoutError < RegexpError
|
1344
|
+
end
|
1345
|
+
|
1346
|
+
# <!-- rdoc-file=re.c -->
|
1347
|
+
# see Regexp.options and Regexp.new
|
1366
1348
|
#
|
1349
|
+
EXTENDED: Integer
|
1350
|
+
|
1351
|
+
# <!-- rdoc-file=re.c -->
|
1352
|
+
# see Regexp.options and Regexp.new
|
1367
1353
|
#
|
1368
|
-
|
1369
|
-
|
1370
|
-
#
|
1354
|
+
FIXEDENCODING: Integer
|
1355
|
+
|
1356
|
+
# <!-- rdoc-file=re.c -->
|
1357
|
+
# see Regexp.options and Regexp.new
|
1371
1358
|
#
|
1372
|
-
|
1373
|
-
|
1374
|
-
#
|
1359
|
+
IGNORECASE: Integer
|
1360
|
+
|
1361
|
+
# <!-- rdoc-file=re.c -->
|
1362
|
+
# see Regexp.options and Regexp.new
|
1375
1363
|
#
|
1376
|
-
|
1377
|
-
|
1378
|
-
#
|
1379
|
-
#
|
1380
|
-
# r3 = Regexp.new(r, timeout: 3.14) # => /foo/m
|
1381
|
-
# r3.timeout # => 3.14
|
1364
|
+
MULTILINE: Integer
|
1365
|
+
|
1366
|
+
# <!-- rdoc-file=re.c -->
|
1367
|
+
# see Regexp.options and Regexp.new
|
1382
1368
|
#
|
1383
|
-
|
1384
|
-
| (Regexp regexp, ?timeout: Float?) -> void
|
1369
|
+
NOENCODING: Integer
|
1385
1370
|
|
1386
1371
|
# <!--
|
1387
1372
|
# rdoc-file=re.c
|
@@ -1444,8 +1429,7 @@ class Regexp
|
|
1444
1429
|
# Regexp.last_match('foo') # Raises IndexError.
|
1445
1430
|
#
|
1446
1431
|
def self.last_match: () -> MatchData?
|
1447
|
-
| (
|
1448
|
-
| (interned n) -> String?
|
1432
|
+
| (MatchData::capture capture) -> String?
|
1449
1433
|
|
1450
1434
|
# <!--
|
1451
1435
|
# rdoc-file=re.c
|
@@ -1466,7 +1450,8 @@ class Regexp
|
|
1466
1450
|
#
|
1467
1451
|
# (*1): https://doi.org/10.1109/SP40001.2021.00032
|
1468
1452
|
#
|
1469
|
-
def self.linear_time?: () -> bool
|
1453
|
+
def self.linear_time?: (Regexp regex, ?nil, ?timeout: untyped) -> bool
|
1454
|
+
| (string regex, ?int | string | bool | nil options, ?timeout: untyped) -> bool
|
1470
1455
|
|
1471
1456
|
# <!--
|
1472
1457
|
# rdoc-file=re.c
|
@@ -1482,7 +1467,7 @@ class Regexp
|
|
1482
1467
|
# r = Regexp.new(Regexp.escape(s)) # => /\\\\\\\*\\\?\\\{\\\}\\\./
|
1483
1468
|
# r.match(s) # => #<MatchData "\\\\\\*\\?\\{\\}\\.">
|
1484
1469
|
#
|
1485
|
-
|
1470
|
+
alias self.quote self.escape
|
1486
1471
|
|
1487
1472
|
# <!--
|
1488
1473
|
# rdoc-file=re.c
|
@@ -1501,7 +1486,8 @@ class Regexp
|
|
1501
1486
|
#
|
1502
1487
|
# Raises an exception unless `object.to_regexp` returns a regexp.
|
1503
1488
|
#
|
1504
|
-
def self.try_convert: (
|
1489
|
+
def self.try_convert: (Regexp | _ToRegexp regexp_like) -> Regexp
|
1490
|
+
| (untyped other) -> Regexp?
|
1505
1491
|
|
1506
1492
|
# <!--
|
1507
1493
|
# rdoc-file=re.c
|
@@ -1524,7 +1510,7 @@ class Regexp
|
|
1524
1510
|
# Regexp.timeout = 1
|
1525
1511
|
# /^a*b?a*$/ =~ "a" * 100000 + "x" #=> regexp match timeout (RuntimeError)
|
1526
1512
|
#
|
1527
|
-
def self.timeout=: (
|
1513
|
+
def self.timeout=: [T < _ToF] (T timeout) -> T
|
1528
1514
|
|
1529
1515
|
# <!--
|
1530
1516
|
# rdoc-file=re.c
|
@@ -1558,11 +1544,62 @@ class Regexp
|
|
1558
1544
|
#
|
1559
1545
|
# If any regexp pattern contains captures, the behavior is unspecified.
|
1560
1546
|
#
|
1561
|
-
def self.union: () -> Regexp
|
1562
|
-
| (
|
1563
|
-
| (
|
1547
|
+
def self.union: (*_ToRegexp | string patterns) -> Regexp
|
1548
|
+
| (array[_ToRegexp | string] patterns) -> Regexp
|
1549
|
+
| (Symbol | [Symbol] symbol_pattern) -> Regexp
|
1564
1550
|
|
1565
|
-
|
1551
|
+
# <!--
|
1552
|
+
# rdoc-file=re.c
|
1553
|
+
# - Regexp.new(string, options = 0, timeout: nil) -> regexp
|
1554
|
+
# - Regexp.new(regexp, timeout: nil) -> regexp
|
1555
|
+
# -->
|
1556
|
+
# With argument `string` given, returns a new regexp with the given string and
|
1557
|
+
# options:
|
1558
|
+
#
|
1559
|
+
# r = Regexp.new('foo') # => /foo/
|
1560
|
+
# r.source # => "foo"
|
1561
|
+
# r.options # => 0
|
1562
|
+
#
|
1563
|
+
# Optional argument `options` is one of the following:
|
1564
|
+
#
|
1565
|
+
# * A String of options:
|
1566
|
+
#
|
1567
|
+
# Regexp.new('foo', 'i') # => /foo/i
|
1568
|
+
# Regexp.new('foo', 'im') # => /foo/im
|
1569
|
+
#
|
1570
|
+
# * The bit-wise OR of one or more of the constants Regexp::EXTENDED,
|
1571
|
+
# Regexp::IGNORECASE, Regexp::MULTILINE, and Regexp::NOENCODING:
|
1572
|
+
#
|
1573
|
+
# Regexp.new('foo', Regexp::IGNORECASE) # => /foo/i
|
1574
|
+
# Regexp.new('foo', Regexp::EXTENDED) # => /foo/x
|
1575
|
+
# Regexp.new('foo', Regexp::MULTILINE) # => /foo/m
|
1576
|
+
# Regexp.new('foo', Regexp::NOENCODING) # => /foo/n
|
1577
|
+
# flags = Regexp::IGNORECASE | Regexp::EXTENDED | Regexp::MULTILINE
|
1578
|
+
# Regexp.new('foo', flags) # => /foo/mix
|
1579
|
+
#
|
1580
|
+
# * `nil` or `false`, which is ignored.
|
1581
|
+
# * Any other truthy value, in which case the regexp will be case-insensitive.
|
1582
|
+
#
|
1583
|
+
#
|
1584
|
+
# If optional keyword argument `timeout` is given, its float value overrides the
|
1585
|
+
# timeout interval for the class, Regexp.timeout. If `nil` is passed as
|
1586
|
+
# +timeout, it uses the timeout interval for the class, Regexp.timeout.
|
1587
|
+
#
|
1588
|
+
# With argument `regexp` given, returns a new regexp. The source, options,
|
1589
|
+
# timeout are the same as `regexp`. `options` and `n_flag` arguments are
|
1590
|
+
# ineffective. The timeout can be overridden by `timeout` keyword.
|
1591
|
+
#
|
1592
|
+
# options = Regexp::MULTILINE
|
1593
|
+
# r = Regexp.new('foo', options, timeout: 1.1) # => /foo/m
|
1594
|
+
# r2 = Regexp.new(r) # => /foo/m
|
1595
|
+
# r2.timeout # => 1.1
|
1596
|
+
# r3 = Regexp.new(r, timeout: 3.14) # => /foo/m
|
1597
|
+
# r3.timeout # => 3.14
|
1598
|
+
#
|
1599
|
+
def initialize: (Regexp regexp, ?timeout: _ToF?) -> self
|
1600
|
+
| (string pattern, ?int | string | bool | nil options, ?timeout: _ToF?) -> self
|
1601
|
+
|
1602
|
+
def initialize_copy: (self object) -> self
|
1566
1603
|
|
1567
1604
|
# <!-- rdoc-file=re.c -->
|
1568
1605
|
# Returns `true` if `object` is another Regexp whose pattern, flags, and
|
@@ -1648,7 +1685,8 @@ class Regexp
|
|
1648
1685
|
# /(?<foo>\w+)\s*=\s*#{r}/ =~ 'x = y'
|
1649
1686
|
# p foo # Undefined local variable
|
1650
1687
|
#
|
1651
|
-
def =~: (
|
1688
|
+
def =~: (interned? string) -> Integer?
|
1689
|
+
| (nil) -> nil
|
1652
1690
|
|
1653
1691
|
# <!--
|
1654
1692
|
# rdoc-file=re.c
|
@@ -1683,7 +1721,7 @@ class Regexp
|
|
1683
1721
|
# /foo/ == Regexp.new('food') # => false
|
1684
1722
|
# /foo/ == Regexp.new("abc".force_encoding("euc-jp")) # => false
|
1685
1723
|
#
|
1686
|
-
|
1724
|
+
alias eql? ==
|
1687
1725
|
|
1688
1726
|
# <!--
|
1689
1727
|
# rdoc-file=re.c
|
@@ -1774,8 +1812,9 @@ class Regexp
|
|
1774
1812
|
# /(.)(.)(.)/.match("abc")[2] # => "b"
|
1775
1813
|
# /(.)(.)/.match("abc", 1)[2] # => "c"
|
1776
1814
|
#
|
1777
|
-
def match: (
|
1778
|
-
| [T] (
|
1815
|
+
def match: (interned? str, ?int offset) -> MatchData?
|
1816
|
+
| [T] (interned? str, ?int offset) { (MatchData matchdata) -> T } -> T?
|
1817
|
+
| (nil, ?int offset) ?{ (MatchData matchdata) -> void } -> nil
|
1779
1818
|
|
1780
1819
|
# <!--
|
1781
1820
|
# rdoc-file=re.c
|
@@ -1791,7 +1830,8 @@ class Regexp
|
|
1791
1830
|
# /P.../.match?("Ruby") # => false
|
1792
1831
|
# $& # => nil
|
1793
1832
|
#
|
1794
|
-
def match?: (
|
1833
|
+
def match?: (interned str, ?int offset) -> bool
|
1834
|
+
| (nil, ?int offset) -> false
|
1795
1835
|
|
1796
1836
|
# <!--
|
1797
1837
|
# rdoc-file=re.c
|
@@ -1810,7 +1850,7 @@ class Regexp
|
|
1810
1850
|
# /(?<foo>.)(?<foo>.)/.named_captures # => {"foo"=>[1, 2]}
|
1811
1851
|
# /(.)(.)/.named_captures # => {}
|
1812
1852
|
#
|
1813
|
-
def named_captures: () ->
|
1853
|
+
def named_captures: () -> Hash[String, Array[Integer]]
|
1814
1854
|
|
1815
1855
|
# <!--
|
1816
1856
|
# rdoc-file=re.c
|
@@ -1823,7 +1863,7 @@ class Regexp
|
|
1823
1863
|
# /(?<foo>.)(?<foo>.)/.names # => ["foo"]
|
1824
1864
|
# /(.)(.)/.names # => []
|
1825
1865
|
#
|
1826
|
-
def names: () ->
|
1866
|
+
def names: () -> Array[String]
|
1827
1867
|
|
1828
1868
|
# <!--
|
1829
1869
|
# rdoc-file=re.c
|
@@ -1933,33 +1973,4 @@ class Regexp
|
|
1933
1973
|
# ~ /at/ # => 7
|
1934
1974
|
#
|
1935
1975
|
def ~: () -> Integer?
|
1936
|
-
|
1937
|
-
private
|
1938
|
-
|
1939
|
-
def initialize_copy: (self object) -> self
|
1940
1976
|
end
|
1941
|
-
|
1942
|
-
# <!-- rdoc-file=re.c -->
|
1943
|
-
# see Regexp.options and Regexp.new
|
1944
|
-
#
|
1945
|
-
Regexp::EXTENDED: Integer
|
1946
|
-
|
1947
|
-
# <!-- rdoc-file=re.c -->
|
1948
|
-
# see Regexp.options and Regexp.new
|
1949
|
-
#
|
1950
|
-
Regexp::FIXEDENCODING: Integer
|
1951
|
-
|
1952
|
-
# <!-- rdoc-file=re.c -->
|
1953
|
-
# see Regexp.options and Regexp.new
|
1954
|
-
#
|
1955
|
-
Regexp::IGNORECASE: Integer
|
1956
|
-
|
1957
|
-
# <!-- rdoc-file=re.c -->
|
1958
|
-
# see Regexp.options and Regexp.new
|
1959
|
-
#
|
1960
|
-
Regexp::MULTILINE: Integer
|
1961
|
-
|
1962
|
-
# <!-- rdoc-file=re.c -->
|
1963
|
-
# see Regexp.options and Regexp.new
|
1964
|
-
#
|
1965
|
-
Regexp::NOENCODING: Integer
|
data/core/ruby_vm.rbs
CHANGED
@@ -260,118 +260,118 @@ module RubyVM::AbstractSyntaxTree
|
|
260
260
|
#
|
261
261
|
def children: () -> Array[untyped]
|
262
262
|
end
|
263
|
+
end
|
263
264
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
265
|
+
# <!-- rdoc-file=yjit.rb -->
|
266
|
+
# This module allows for introspection of YJIT, CRuby's just-in-time compiler.
|
267
|
+
# Everything in the module is highly implementation specific and the API might
|
268
|
+
# be less stable compared to the standard library.
|
269
|
+
# This module may not exist if YJIT does not support the particular platform
|
270
|
+
# for which CRuby is built.
|
271
|
+
#
|
272
|
+
module RubyVM::YJIT
|
273
|
+
# <!--
|
274
|
+
# rdoc-file=yjit.rb
|
275
|
+
# - code_gc()
|
276
|
+
# -->
|
277
|
+
# Discard existing compiled code to reclaim memory
|
278
|
+
# and allow for recompilations in the future.
|
279
|
+
#
|
280
|
+
def self.code_gc: () -> void
|
280
281
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
282
|
+
# <!--
|
283
|
+
# rdoc-file=yjit.rb
|
284
|
+
# - dump_exit_locations(filename)
|
285
|
+
# -->
|
286
|
+
# Marshal dumps exit locations to the given filename.
|
287
|
+
# Usage:
|
288
|
+
# If `--yjit-exit-locations` is passed, a file named
|
289
|
+
# "yjit_exit_locations.dump" will automatically be generated.
|
290
|
+
# If you want to collect traces manually, call `dump_exit_locations`
|
291
|
+
# directly.
|
292
|
+
# Note that calling this in a script will generate stats after the
|
293
|
+
# dump is created, so the stats data may include exits from the
|
294
|
+
# dump itself.
|
295
|
+
# In a script call:
|
296
|
+
# at_exit do
|
297
|
+
# RubyVM::YJIT.dump_exit_locations("my_file.dump")
|
298
|
+
# end
|
299
|
+
#
|
300
|
+
# Then run the file with the following options:
|
301
|
+
# ruby --yjit --yjit-trace-exits test.rb
|
302
|
+
#
|
303
|
+
# Once the code is done running, use Stackprof to read the dump file.
|
304
|
+
# See Stackprof documentation for options.
|
305
|
+
#
|
306
|
+
def self.dump_exit_locations: (untyped filename) -> void
|
306
307
|
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
308
|
+
# <!--
|
309
|
+
# rdoc-file=yjit.rb
|
310
|
+
# - enable(stats: false)
|
311
|
+
# -->
|
312
|
+
# Enable YJIT compilation.
|
313
|
+
#
|
314
|
+
def self.enable: () -> void
|
314
315
|
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
316
|
+
# <!--
|
317
|
+
# rdoc-file=yjit.rb
|
318
|
+
# - enabled?()
|
319
|
+
# -->
|
320
|
+
# Check if YJIT is enabled.
|
321
|
+
#
|
322
|
+
def self.enabled?: () -> bool
|
322
323
|
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
324
|
+
# <!--
|
325
|
+
# rdoc-file=yjit.rb
|
326
|
+
# - format_number(pad, number)
|
327
|
+
# -->
|
328
|
+
# Format large numbers with comma separators for readability
|
329
|
+
#
|
330
|
+
def self.format_number: (untyped pad, untyped number) -> untyped
|
330
331
|
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
332
|
+
# <!--
|
333
|
+
# rdoc-file=yjit.rb
|
334
|
+
# - format_number_pct(pad, number, total)
|
335
|
+
# -->
|
336
|
+
# Format a number along with a percentage over a total value
|
337
|
+
#
|
338
|
+
def self.format_number_pct: (untyped pad, untyped number, untyped total) -> untyped
|
338
339
|
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
340
|
+
# <!--
|
341
|
+
# rdoc-file=yjit.rb
|
342
|
+
# - reset_stats!()
|
343
|
+
# -->
|
344
|
+
# Discard statistics collected for `--yjit-stats`.
|
345
|
+
#
|
346
|
+
def self.reset_stats!: () -> void
|
346
347
|
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
348
|
+
# <!--
|
349
|
+
# rdoc-file=yjit.rb
|
350
|
+
# - runtime_stats(context: false)
|
351
|
+
# -->
|
352
|
+
# Return a hash for statistics generated for the `--yjit-stats` command line
|
353
|
+
# option.
|
354
|
+
# Return `nil` when option is not passed or unavailable.
|
355
|
+
#
|
356
|
+
def self.runtime_stats: (?context: bool) -> Hash[untyped, untyped]?
|
356
357
|
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
358
|
+
# <!--
|
359
|
+
# rdoc-file=yjit.rb
|
360
|
+
# - stats_enabled?()
|
361
|
+
# -->
|
362
|
+
# Check if `--yjit-stats` is used.
|
363
|
+
#
|
364
|
+
def self.stats_enabled?: () -> bool
|
364
365
|
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
366
|
+
# <!--
|
367
|
+
# rdoc-file=yjit.rb
|
368
|
+
# - stats_string()
|
369
|
+
# -->
|
370
|
+
# Format and print out counters as a String. This returns a non-empty
|
371
|
+
# content only when `--yjit-stats` is enabled.
|
372
|
+
#
|
373
|
+
def self.stats_string: () -> String
|
374
|
+
end
|
374
375
|
|
375
|
-
|
376
|
-
end
|
376
|
+
module RubyVM::RJIT
|
377
377
|
end
|
data/core/string.rbs
CHANGED
@@ -703,7 +703,7 @@ class String
|
|
703
703
|
#
|
704
704
|
# String.new('hello', encoding: 'UTF-8', capacity: 25)
|
705
705
|
#
|
706
|
-
def initialize: (?string source, ?encoding: encoding
|
706
|
+
def initialize: (?string source, ?encoding: encoding, ?capacity: int) -> void
|
707
707
|
|
708
708
|
# <!--
|
709
709
|
# rdoc-file=string.c
|
@@ -1185,7 +1185,7 @@ class String
|
|
1185
1185
|
# offset does not land on character (codepoint) boundary, an IndexError will be
|
1186
1186
|
# raised.
|
1187
1187
|
#
|
1188
|
-
def bytesplice: (
|
1188
|
+
def bytesplice: (Integer start, int length, string str) -> String
|
1189
1189
|
| (int start, int length, string str, int str_start, int str_length) -> String
|
1190
1190
|
| (range[int?] range, string str, ?range[int?] str_range) -> String
|
1191
1191
|
|
@@ -2098,7 +2098,7 @@ class String
|
|
2098
2098
|
# Related: String#sub, String#gsub, String#sub!.
|
2099
2099
|
#
|
2100
2100
|
def gsub!: (Regexp | string pattern, string | hash[String, _ToS] replacement) -> self?
|
2101
|
-
| (Regexp | string pattern) -> Enumerator[String, self]
|
2101
|
+
| (Regexp | string pattern) -> Enumerator[String, self?]
|
2102
2102
|
| (Regexp | string pattern) { (String match) -> _ToS } -> self?
|
2103
2103
|
|
2104
2104
|
# <!--
|
data/core/symbol.rbs
CHANGED
@@ -175,7 +175,8 @@ class Symbol
|
|
175
175
|
# Equivalent to `symbol.to_s =~ object`, including possible updates to global
|
176
176
|
# variables; see String#=~.
|
177
177
|
#
|
178
|
-
def =~: (
|
178
|
+
def =~: (Regexp regex) -> Integer?
|
179
|
+
| [T] (String::_MatchAgainst[self, T] object) -> T
|
179
180
|
|
180
181
|
# <!--
|
181
182
|
# rdoc-file=string.c
|
data/core/thread.rbs
CHANGED
@@ -1437,7 +1437,7 @@ class Thread::ConditionVariable < Object
|
|
1437
1437
|
#
|
1438
1438
|
# Returns the slept result on `mutex`.
|
1439
1439
|
#
|
1440
|
-
def wait: (Thread::Mutex mutex, ?
|
1440
|
+
def wait: (Thread::Mutex mutex, ?Time::_Timeout? timeout) -> Integer?
|
1441
1441
|
end
|
1442
1442
|
|
1443
1443
|
# <!-- rdoc-file=thread_sync.c -->
|
data/core/time.rbs
CHANGED
@@ -389,6 +389,26 @@
|
|
389
389
|
# You can define this method per subclasses, or on the toplevel Time class.
|
390
390
|
#
|
391
391
|
class Time < Object
|
392
|
+
# A type that's used for timeouts.
|
393
|
+
#
|
394
|
+
# All numeric types implement this, but custom classes can also implement it if desired.
|
395
|
+
#
|
396
|
+
# Usage of `Time::_Timeout` is fairly common throughout the stdlib, such as in `Kernel#sleep`,
|
397
|
+
# `IO#timeout=`, and `TCPSocket#new`'s `connet_timeout` field.
|
398
|
+
interface _Timeout
|
399
|
+
# Returns `[seconds, nanoseconds]`.
|
400
|
+
#
|
401
|
+
# The `seconds` should be a whole number of seconds, whereas the `nanoseconds` should be smaller
|
402
|
+
# than one. For example, `3.125.divmod(1)` would yield `[3, 0.125]`
|
403
|
+
def divmod: (1) -> [int, _TimeoutNSecs]
|
404
|
+
end
|
405
|
+
|
406
|
+
# The nanoseconds part of `Time::_Timeout`'s return value. See it for details
|
407
|
+
interface _TimeoutNSecs
|
408
|
+
# Convert `self` into a whole number of seconds.
|
409
|
+
def *: (1_000_000_000) -> int
|
410
|
+
end
|
411
|
+
|
392
412
|
include Comparable
|
393
413
|
|
394
414
|
# <!--
|
@@ -1083,8 +1103,8 @@ class Time < Object
|
|
1083
1103
|
# More digits will be truncated, as other operations of `Time`. Ignored
|
1084
1104
|
# unless the first argument is a string.
|
1085
1105
|
#
|
1086
|
-
def initialize: (?Integer
|
1087
|
-
| (?Integer
|
1106
|
+
def initialize: (?Integer year, ?Integer? month, ?Integer? day, ?Integer? hour, ?Integer? min, ?Numeric? sec, ?String | Integer | nil) -> void
|
1107
|
+
| (?Integer year, ?Integer? month, ?Integer? day, ?Integer? hour, ?Integer? min, ?Numeric? sec, in: String | Integer | nil) -> void
|
1088
1108
|
| (String, ?in: string | int | nil, ?precision: int) -> void
|
1089
1109
|
|
1090
1110
|
# <!--
|
@@ -1333,7 +1353,7 @@ class Time < Object
|
|
1333
1353
|
# The returned array is suitable for use as an argument to Time.utc or
|
1334
1354
|
# Time.local to create a new `Time` object.
|
1335
1355
|
#
|
1336
|
-
def to_a: () -> [ Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, bool, String ]
|
1356
|
+
def to_a: () -> [ Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, bool, String? ]
|
1337
1357
|
|
1338
1358
|
# <!--
|
1339
1359
|
# rdoc-file=time.c
|
@@ -1564,7 +1584,7 @@ class Time < Object
|
|
1564
1584
|
# Time.utc(2000, 1, 1).zone # => "UTC"
|
1565
1585
|
# Time.new(2000, 1, 1).zone # => "Central Standard Time"
|
1566
1586
|
#
|
1567
|
-
def zone: () -> String
|
1587
|
+
def zone: () -> String?
|
1568
1588
|
|
1569
1589
|
# <!-- rdoc-file=time.c -->
|
1570
1590
|
# Like Time.utc, except that the returned `Time` object has the local timezone,
|