rbs 3.9.5 → 3.10.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/.clang-format +74 -0
- data/.clangd +2 -0
- data/.github/workflows/c-check.yml +54 -0
- data/.github/workflows/comments.yml +3 -3
- data/.github/workflows/ruby.yml +34 -19
- data/.github/workflows/typecheck.yml +1 -1
- data/.github/workflows/windows.yml +1 -1
- data/.gitignore +4 -0
- data/README.md +38 -1
- data/Rakefile +152 -23
- data/config.yml +190 -62
- data/core/array.rbs +44 -43
- data/core/dir.rbs +2 -2
- data/core/encoding.rbs +3 -2
- data/core/enumerable.rbs +89 -2
- data/core/errno.rbs +8 -0
- data/core/errors.rbs +28 -1
- data/core/exception.rbs +2 -2
- data/core/fiber.rbs +3 -3
- data/core/file.rbs +26 -11
- data/core/float.rbs +1 -1
- data/core/gc.rbs +422 -281
- data/core/hash.rbs +1024 -727
- data/core/io/wait.rbs +11 -33
- data/core/io.rbs +6 -4
- data/core/kernel.rbs +49 -43
- data/core/marshal.rbs +1 -1
- data/core/match_data.rbs +1 -1
- data/core/math.rbs +42 -3
- data/core/method.rbs +14 -6
- data/core/module.rbs +71 -11
- data/core/nil_class.rbs +3 -3
- data/core/numeric.rbs +8 -8
- data/core/object.rbs +3 -3
- data/core/object_space.rbs +13 -0
- data/{stdlib/pathname/0 → core}/pathname.rbs +253 -352
- data/core/proc.rbs +15 -8
- data/core/process.rbs +2 -2
- data/core/ractor.rbs +278 -437
- data/core/range.rbs +6 -7
- data/core/rbs/unnamed/argf.rbs +1 -1
- data/core/rbs/unnamed/env_class.rbs +1 -1
- data/core/rbs/unnamed/random.rbs +4 -2
- data/core/regexp.rbs +22 -17
- data/core/ruby_vm.rbs +6 -4
- data/core/rubygems/errors.rbs +3 -70
- data/core/rubygems/rubygems.rbs +11 -79
- data/core/set.rbs +439 -332
- data/core/string.rbs +2897 -1117
- data/core/struct.rbs +1 -1
- data/core/symbol.rbs +4 -4
- data/core/thread.rbs +83 -20
- data/core/time.rbs +35 -9
- data/core/unbound_method.rbs +14 -6
- data/docs/aliases.md +79 -0
- data/docs/collection.md +2 -2
- data/docs/gem.md +0 -1
- data/docs/sigs.md +3 -3
- data/ext/rbs_extension/ast_translation.c +1016 -0
- data/ext/rbs_extension/ast_translation.h +37 -0
- data/ext/rbs_extension/class_constants.c +157 -0
- data/{include/rbs/constants.h → ext/rbs_extension/class_constants.h} +7 -1
- data/ext/rbs_extension/compat.h +10 -0
- data/ext/rbs_extension/extconf.rb +25 -1
- data/ext/rbs_extension/legacy_location.c +317 -0
- data/ext/rbs_extension/legacy_location.h +45 -0
- data/ext/rbs_extension/main.c +365 -14
- data/ext/rbs_extension/rbs_extension.h +6 -21
- data/ext/rbs_extension/rbs_string_bridging.c +9 -0
- data/ext/rbs_extension/rbs_string_bridging.h +24 -0
- data/include/rbs/ast.h +687 -0
- data/include/rbs/defines.h +86 -0
- data/include/rbs/lexer.h +199 -0
- data/include/rbs/location.h +59 -0
- data/include/rbs/parser.h +135 -0
- data/include/rbs/string.h +49 -0
- data/include/rbs/util/rbs_allocator.h +59 -0
- data/include/rbs/util/rbs_assert.h +20 -0
- data/include/rbs/util/rbs_buffer.h +83 -0
- data/include/rbs/util/rbs_constant_pool.h +6 -67
- data/include/rbs/util/rbs_encoding.h +282 -0
- data/include/rbs/util/rbs_unescape.h +23 -0
- data/include/rbs.h +1 -2
- data/lib/rbs/annotate/formatter.rb +3 -13
- data/lib/rbs/annotate/rdoc_annotator.rb +3 -1
- data/lib/rbs/annotate/rdoc_source.rb +1 -1
- data/lib/rbs/cli/validate.rb +2 -2
- data/lib/rbs/cli.rb +1 -1
- data/lib/rbs/collection/config/lockfile_generator.rb +1 -0
- data/lib/rbs/definition_builder/ancestor_builder.rb +5 -5
- data/lib/rbs/environment.rb +64 -59
- data/lib/rbs/environment_loader.rb +1 -1
- data/lib/rbs/errors.rb +1 -1
- data/lib/rbs/parser_aux.rb +5 -0
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +124 -38
- data/lib/rbs/test/type_check.rb +13 -0
- data/lib/rbs/types.rb +3 -1
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +1 -1
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +3 -3
- data/sig/annotate/formatter.rbs +2 -2
- data/sig/annotate/rdoc_annotater.rbs +1 -1
- data/sig/environment.rbs +57 -6
- data/sig/manifest.yaml +0 -1
- data/sig/parser.rbs +20 -0
- data/sig/resolver/type_name_resolver.rbs +38 -7
- data/sig/types.rbs +4 -1
- data/src/ast.c +1256 -0
- data/src/lexer.c +2956 -0
- data/src/lexer.re +147 -0
- data/src/lexstate.c +205 -0
- data/src/location.c +71 -0
- data/src/parser.c +3495 -0
- data/src/string.c +90 -0
- data/src/util/rbs_allocator.c +152 -0
- data/src/util/rbs_assert.c +21 -0
- data/src/util/rbs_buffer.c +54 -0
- data/src/util/rbs_constant_pool.c +16 -86
- data/src/util/rbs_encoding.c +21308 -0
- data/src/util/rbs_unescape.c +131 -0
- data/stdlib/cgi/0/core.rbs +2 -396
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/cgi-escape/0/escape.rbs +153 -0
- data/stdlib/coverage/0/coverage.rbs +3 -1
- data/stdlib/delegate/0/delegator.rbs +10 -7
- data/stdlib/erb/0/erb.rbs +737 -347
- data/stdlib/fileutils/0/fileutils.rbs +18 -13
- data/stdlib/forwardable/0/forwardable.rbs +3 -0
- data/stdlib/json/0/json.rbs +67 -48
- data/stdlib/net-http/0/net-http.rbs +3 -0
- data/stdlib/objspace/0/objspace.rbs +8 -3
- data/stdlib/open-uri/0/open-uri.rbs +40 -0
- data/stdlib/openssl/0/openssl.rbs +182 -149
- data/stdlib/optparse/0/optparse.rbs +3 -3
- data/stdlib/rdoc/0/code_object.rbs +2 -2
- data/stdlib/rdoc/0/comment.rbs +2 -0
- data/stdlib/rdoc/0/options.rbs +76 -0
- data/stdlib/rdoc/0/rdoc.rbs +7 -5
- data/stdlib/rdoc/0/store.rbs +1 -1
- data/stdlib/resolv/0/resolv.rbs +25 -68
- data/stdlib/ripper/0/ripper.rbs +5 -2
- data/stdlib/singleton/0/singleton.rbs +3 -0
- data/stdlib/socket/0/socket.rbs +13 -1
- data/stdlib/socket/0/tcp_socket.rbs +10 -2
- data/stdlib/stringio/0/stringio.rbs +412 -80
- data/stdlib/strscan/0/string_scanner.rbs +31 -31
- data/stdlib/tempfile/0/tempfile.rbs +1 -1
- data/stdlib/tsort/0/cyclic.rbs +3 -0
- data/stdlib/uri/0/common.rbs +11 -2
- data/stdlib/uri/0/file.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +16 -15
- data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
- data/stdlib/zlib/0/zstream.rbs +1 -0
- metadata +41 -18
- data/ext/rbs_extension/lexer.c +0 -2728
- data/ext/rbs_extension/lexer.h +0 -179
- data/ext/rbs_extension/lexer.re +0 -147
- data/ext/rbs_extension/lexstate.c +0 -175
- data/ext/rbs_extension/location.c +0 -325
- data/ext/rbs_extension/location.h +0 -85
- data/ext/rbs_extension/parser.c +0 -2982
- data/ext/rbs_extension/parser.h +0 -18
- data/ext/rbs_extension/parserstate.c +0 -411
- data/ext/rbs_extension/parserstate.h +0 -163
- data/ext/rbs_extension/unescape.c +0 -32
- data/include/rbs/ruby_objs.h +0 -72
- data/src/constants.c +0 -153
- data/src/ruby_objs.c +0 -799
data/core/struct.rbs
CHANGED
|
@@ -130,7 +130,7 @@ class Struct[Elem]
|
|
|
130
130
|
# Foo = Struct.new('Foo', :foo, :bar) # => Struct::Foo
|
|
131
131
|
# f = Foo.new(0, 1) # => #<struct Struct::Foo foo=0, bar=1>
|
|
132
132
|
#
|
|
133
|
-
#
|
|
133
|
+
# **Class Name**
|
|
134
134
|
#
|
|
135
135
|
# With string argument `class_name`, returns a new subclass of `Struct` named
|
|
136
136
|
# `Struct::*class_name`*:
|
data/core/symbol.rbs
CHANGED
|
@@ -188,7 +188,7 @@ class Symbol
|
|
|
188
188
|
|
|
189
189
|
# <!--
|
|
190
190
|
# rdoc-file=string.c
|
|
191
|
-
# - capitalize(
|
|
191
|
+
# - capitalize(mapping) -> symbol
|
|
192
192
|
# -->
|
|
193
193
|
# Equivalent to `sym.to_s.capitalize.to_sym`.
|
|
194
194
|
#
|
|
@@ -268,7 +268,7 @@ class Symbol
|
|
|
268
268
|
|
|
269
269
|
# <!--
|
|
270
270
|
# rdoc-file=string.c
|
|
271
|
-
# - downcase(
|
|
271
|
+
# - downcase(mapping) -> symbol
|
|
272
272
|
# -->
|
|
273
273
|
# Equivalent to `sym.to_s.downcase.to_sym`.
|
|
274
274
|
#
|
|
@@ -413,7 +413,7 @@ class Symbol
|
|
|
413
413
|
|
|
414
414
|
# <!--
|
|
415
415
|
# rdoc-file=string.c
|
|
416
|
-
# - swapcase(
|
|
416
|
+
# - swapcase(mapping) -> symbol
|
|
417
417
|
# -->
|
|
418
418
|
# Equivalent to `sym.to_s.swapcase.to_sym`.
|
|
419
419
|
#
|
|
@@ -462,7 +462,7 @@ class Symbol
|
|
|
462
462
|
|
|
463
463
|
# <!--
|
|
464
464
|
# rdoc-file=string.c
|
|
465
|
-
# - upcase(
|
|
465
|
+
# - upcase(mapping) -> symbol
|
|
466
466
|
# -->
|
|
467
467
|
# Equivalent to `sym.to_s.upcase.to_sym`.
|
|
468
468
|
#
|
data/core/thread.rbs
CHANGED
|
@@ -265,7 +265,10 @@ class Thread < Object
|
|
|
265
265
|
# -->
|
|
266
266
|
# Terminates `thr` and schedules another thread to be run, returning the
|
|
267
267
|
# terminated Thread. If this is the main thread, or the last thread, exits the
|
|
268
|
-
# process.
|
|
268
|
+
# process. Note that the caller does not wait for the thread to terminate if the
|
|
269
|
+
# receiver is different from the currently running thread. The termination is
|
|
270
|
+
# asynchronous, and the thread can still run a small amount of ruby code before
|
|
271
|
+
# exiting.
|
|
269
272
|
#
|
|
270
273
|
def kill: () -> Thread?
|
|
271
274
|
|
|
@@ -334,7 +337,10 @@ class Thread < Object
|
|
|
334
337
|
# <!-- rdoc-file=thread.c -->
|
|
335
338
|
# Terminates `thr` and schedules another thread to be run, returning the
|
|
336
339
|
# terminated Thread. If this is the main thread, or the last thread, exits the
|
|
337
|
-
# process.
|
|
340
|
+
# process. Note that the caller does not wait for the thread to terminate if the
|
|
341
|
+
# receiver is different from the currently running thread. The termination is
|
|
342
|
+
# asynchronous, and the thread can still run a small amount of ruby code before
|
|
343
|
+
# exiting.
|
|
338
344
|
#
|
|
339
345
|
def exit: () -> Thread?
|
|
340
346
|
|
|
@@ -364,9 +370,9 @@ class Thread < Object
|
|
|
364
370
|
|
|
365
371
|
# <!--
|
|
366
372
|
# rdoc-file=thread.c
|
|
367
|
-
# - Thread.new { ... }
|
|
368
|
-
# - Thread.new(*args, &proc)
|
|
369
|
-
# - Thread.new(*args) { |args| ... }
|
|
373
|
+
# - Thread.new { ... } -> thread
|
|
374
|
+
# - Thread.new(*args, &proc) -> thread
|
|
375
|
+
# - Thread.new(*args) { |args| ... } -> thread
|
|
370
376
|
# -->
|
|
371
377
|
# Creates a new thread executing the given block.
|
|
372
378
|
#
|
|
@@ -660,7 +666,10 @@ class Thread < Object
|
|
|
660
666
|
# <!-- rdoc-file=thread.c -->
|
|
661
667
|
# Terminates `thr` and schedules another thread to be run, returning the
|
|
662
668
|
# terminated Thread. If this is the main thread, or the last thread, exits the
|
|
663
|
-
# process.
|
|
669
|
+
# process. Note that the caller does not wait for the thread to terminate if the
|
|
670
|
+
# receiver is different from the currently running thread. The termination is
|
|
671
|
+
# asynchronous, and the thread can still run a small amount of ruby code before
|
|
672
|
+
# exiting.
|
|
664
673
|
#
|
|
665
674
|
def terminate: () -> Thread?
|
|
666
675
|
|
|
@@ -972,8 +981,8 @@ class Thread < Object
|
|
|
972
981
|
# from prog.rb:2:in `new'
|
|
973
982
|
# from prog.rb:2
|
|
974
983
|
#
|
|
975
|
-
def raise: (?String message) -> nil
|
|
976
|
-
| (_Exception, ?_ToS message, ?Array[Thread::Backtrace::Location] | Array[String] | nil backtrace) -> nil
|
|
984
|
+
def raise: (?String message, ?cause: Exception?) -> nil
|
|
985
|
+
| (_Exception, ?_ToS message, ?Array[Thread::Backtrace::Location] | Array[String] | nil backtrace, ?cause: Exception?) -> nil
|
|
977
986
|
|
|
978
987
|
# <!--
|
|
979
988
|
# rdoc-file=thread.c
|
|
@@ -1385,28 +1394,80 @@ end
|
|
|
1385
1394
|
# <!-- rdoc-file=thread_sync.c -->
|
|
1386
1395
|
# ConditionVariable objects augment class Mutex. Using condition variables, it
|
|
1387
1396
|
# is possible to suspend while in the middle of a critical section until a
|
|
1388
|
-
# resource becomes available.
|
|
1397
|
+
# condition is met, such as a resource becomes available.
|
|
1398
|
+
#
|
|
1399
|
+
# Due to non-deterministic scheduling and spurious wake-ups, users of condition
|
|
1400
|
+
# variables should always use a separate boolean predicate (such as reading from
|
|
1401
|
+
# a boolean variable) to check if the condition is actually met before starting
|
|
1402
|
+
# to wait, and should wait in a loop, re-checking the condition every time the
|
|
1403
|
+
# ConditionVariable is waken up. The idiomatic way of using condition variables
|
|
1404
|
+
# is calling the `wait` method in an `until` loop with the predicate as the loop
|
|
1405
|
+
# condition.
|
|
1406
|
+
#
|
|
1407
|
+
# condvar.wait(mutex) until condition_is_met
|
|
1408
|
+
#
|
|
1409
|
+
# In the example below, we use the boolean variable `resource_available` (which
|
|
1410
|
+
# is protected by `mutex`) to indicate the availability of the resource, and use
|
|
1411
|
+
# `condvar` to wait for that variable to become true. Note that:
|
|
1412
|
+
#
|
|
1413
|
+
# 1. Thread `b` may be scheduled before thread `a1` and `a2`, and may run so
|
|
1414
|
+
# fast that it have already made the resource available before either `a1`
|
|
1415
|
+
# or `a2` starts. Therefore, `a1` and `a2` should check if
|
|
1416
|
+
# `resource_available` is already true before starting to wait.
|
|
1417
|
+
# 2. The `wait` method may spuriously wake up without signalling. Therefore,
|
|
1418
|
+
# thread `a1` and `a2` should recheck `resource_available` after the `wait`
|
|
1419
|
+
# method returns, and go back to wait if the condition is not actually met.
|
|
1420
|
+
# 3. It is possible that thread `a2` starts right after thread `a1` is waken up
|
|
1421
|
+
# by `b`. Thread `a2` may have acquired the `mutex` and consumed the
|
|
1422
|
+
# resource before thread `a1` acquires the `mutex`. This necessitates
|
|
1423
|
+
# rechecking after `wait`, too.
|
|
1389
1424
|
#
|
|
1390
1425
|
# Example:
|
|
1391
1426
|
#
|
|
1392
1427
|
# mutex = Thread::Mutex.new
|
|
1393
|
-
# resource = Thread::ConditionVariable.new
|
|
1394
1428
|
#
|
|
1395
|
-
#
|
|
1396
|
-
#
|
|
1397
|
-
#
|
|
1398
|
-
#
|
|
1399
|
-
#
|
|
1400
|
-
#
|
|
1429
|
+
# resource_available = false
|
|
1430
|
+
# condvar = Thread::ConditionVariable.new
|
|
1431
|
+
#
|
|
1432
|
+
# a1 = Thread.new {
|
|
1433
|
+
# # Thread 'a1' waits for the resource to become available and consumes
|
|
1434
|
+
# # the resource.
|
|
1435
|
+
# mutex.synchronize {
|
|
1436
|
+
# condvar.wait(mutex) until resource_available
|
|
1437
|
+
# # After the loop, 'resource_available' is guaranteed to be true.
|
|
1438
|
+
#
|
|
1439
|
+
# resource_available = false
|
|
1440
|
+
# puts "a1 consumed the resource"
|
|
1441
|
+
# }
|
|
1442
|
+
# }
|
|
1443
|
+
#
|
|
1444
|
+
# a2 = Thread.new {
|
|
1445
|
+
# # Thread 'a2' behaves like 'a1'.
|
|
1446
|
+
# mutex.synchronize {
|
|
1447
|
+
# condvar.wait(mutex) until resource_available
|
|
1448
|
+
# resource_available = false
|
|
1449
|
+
# puts "a2 consumed the resource"
|
|
1450
|
+
# }
|
|
1401
1451
|
# }
|
|
1402
1452
|
#
|
|
1403
1453
|
# b = Thread.new {
|
|
1404
|
-
#
|
|
1405
|
-
#
|
|
1406
|
-
#
|
|
1407
|
-
#
|
|
1454
|
+
# # Thread 'b' periodically makes the resource available.
|
|
1455
|
+
# loop {
|
|
1456
|
+
# mutex.synchronize {
|
|
1457
|
+
# resource_available = true
|
|
1458
|
+
#
|
|
1459
|
+
# # Notify one waiting thread if any. It is possible that neither
|
|
1460
|
+
# # 'a1' nor 'a2 is waiting on 'condvar' at this moment. That's OK.
|
|
1461
|
+
# condvar.signal
|
|
1462
|
+
# }
|
|
1463
|
+
# sleep 1
|
|
1464
|
+
# }
|
|
1408
1465
|
# }
|
|
1409
1466
|
#
|
|
1467
|
+
# # Eventually both 'a1' and 'a2' will have their resources, albeit in an
|
|
1468
|
+
# # unspecified order.
|
|
1469
|
+
# [a1, a2].each {|th| th.join}
|
|
1470
|
+
#
|
|
1410
1471
|
class Thread::ConditionVariable < Object
|
|
1411
1472
|
# <!--
|
|
1412
1473
|
# rdoc-file=thread_sync.c
|
|
@@ -1433,6 +1494,8 @@ class Thread::ConditionVariable < Object
|
|
|
1433
1494
|
# If `timeout` is given, this method returns after `timeout` seconds passed,
|
|
1434
1495
|
# even if no other thread doesn't signal.
|
|
1435
1496
|
#
|
|
1497
|
+
# This method may wake up spuriously due to underlying implementation details.
|
|
1498
|
+
#
|
|
1436
1499
|
# Returns the slept result on `mutex`.
|
|
1437
1500
|
#
|
|
1438
1501
|
def wait: (Thread::Mutex mutex, ?Time::_Timeout? timeout) -> Integer?
|
data/core/time.rbs
CHANGED
|
@@ -47,24 +47,30 @@
|
|
|
47
47
|
#
|
|
48
48
|
# ## Time Internal Representation
|
|
49
49
|
#
|
|
50
|
-
# Time
|
|
51
|
-
#
|
|
52
|
-
#
|
|
50
|
+
# Conceptually, Time class uses a rational value to represent the number of
|
|
51
|
+
# seconds from *Epoch*, 1970-01-01 00:00:00 UTC. There are no boundary or
|
|
52
|
+
# resolution limitations. The value can be obtained using Time#to_r.
|
|
53
|
+
#
|
|
54
|
+
# The Time class always uses the Gregorian calendar. I.e. the proleptic
|
|
55
|
+
# Gregorian calendar is used. Other calendars, such as Julian calendar, are not
|
|
56
|
+
# supported.
|
|
57
|
+
#
|
|
58
|
+
# The implementation uses a signed 63 bit integer, Integer (Bignum) object or
|
|
59
|
+
# Ratoinal object to represent a rational value. (The signed 63 bit integer is
|
|
60
|
+
# used regardless of 32 and 64 bit environments.) The value represents the
|
|
61
|
+
# number of nanoseconds from *Epoch*. The signed 63 bit integer can represent
|
|
62
|
+
# 1823-11-12 to 2116-02-20. When Integer or Rational object is used (before
|
|
53
63
|
# 1823, after 2116, under nanosecond), Time works slower than when the signed 63
|
|
54
64
|
# bit integer is used.
|
|
55
65
|
#
|
|
56
66
|
# Ruby uses the C function `localtime` and `gmtime` to map between the number
|
|
57
67
|
# and 6-tuple (year,month,day,hour,minute,second). `localtime` is used for local
|
|
58
|
-
# time and
|
|
68
|
+
# time and `gmtime` is used for UTC.
|
|
59
69
|
#
|
|
60
70
|
# Integer and Rational has no range limit, but the localtime and gmtime has
|
|
61
71
|
# range limits due to the C types `time_t` and `struct tm`. If that limit is
|
|
62
72
|
# exceeded, Ruby extrapolates the localtime function.
|
|
63
73
|
#
|
|
64
|
-
# The Time class always uses the Gregorian calendar. I.e. the proleptic
|
|
65
|
-
# Gregorian calendar is used. Other calendars, such as Julian calendar, are not
|
|
66
|
-
# supported.
|
|
67
|
-
#
|
|
68
74
|
# `time_t` can represent 1901-12-14 to 2038-01-19 if it is 32 bit signed
|
|
69
75
|
# integer, -292277022657-01-27 to 292277026596-12-05 if it is 64 bit signed
|
|
70
76
|
# integer. However `localtime` on some platforms doesn't supports negative
|
|
@@ -72,7 +78,7 @@
|
|
|
72
78
|
#
|
|
73
79
|
# `struct tm` has *tm_year* member to represent years. (`tm_year = 0` means the
|
|
74
80
|
# year 1900.) It is defined as `int` in the C standard. *tm_year* can represent
|
|
75
|
-
# between -2147481748 to 2147485547 if `int` is 32 bit.
|
|
81
|
+
# years between -2147481748 to 2147485547 if `int` is 32 bit.
|
|
76
82
|
#
|
|
77
83
|
# Ruby supports leap seconds as far as if the C function `localtime` and
|
|
78
84
|
# `gmtime` supports it. They use the tz database in most Unix systems. The tz
|
|
@@ -984,10 +990,20 @@ class Time < Object
|
|
|
984
990
|
# now = Time.now
|
|
985
991
|
# # => 2022-08-18 10:24:13.5398485 -0500
|
|
986
992
|
# now.utc? # => false
|
|
993
|
+
# now.getutc.utc? # => true
|
|
987
994
|
# utc = Time.utc(2000, 1, 1, 20, 15, 1)
|
|
988
995
|
# # => 2000-01-01 20:15:01 UTC
|
|
989
996
|
# utc.utc? # => true
|
|
990
997
|
#
|
|
998
|
+
# `Time` objects created with these methods are considered to be in UTC:
|
|
999
|
+
#
|
|
1000
|
+
# * Time.utc
|
|
1001
|
+
# * Time#utc
|
|
1002
|
+
# * Time#getutc
|
|
1003
|
+
#
|
|
1004
|
+
# Objects created in other ways will not be treated as UTC even if the
|
|
1005
|
+
# environment variable "TZ" is "UTC".
|
|
1006
|
+
#
|
|
991
1007
|
# Related: Time.utc.
|
|
992
1008
|
#
|
|
993
1009
|
def gmt?: () -> bool
|
|
@@ -1560,10 +1576,20 @@ class Time < Object
|
|
|
1560
1576
|
# now = Time.now
|
|
1561
1577
|
# # => 2022-08-18 10:24:13.5398485 -0500
|
|
1562
1578
|
# now.utc? # => false
|
|
1579
|
+
# now.getutc.utc? # => true
|
|
1563
1580
|
# utc = Time.utc(2000, 1, 1, 20, 15, 1)
|
|
1564
1581
|
# # => 2000-01-01 20:15:01 UTC
|
|
1565
1582
|
# utc.utc? # => true
|
|
1566
1583
|
#
|
|
1584
|
+
# `Time` objects created with these methods are considered to be in UTC:
|
|
1585
|
+
#
|
|
1586
|
+
# * Time.utc
|
|
1587
|
+
# * Time#utc
|
|
1588
|
+
# * Time#getutc
|
|
1589
|
+
#
|
|
1590
|
+
# Objects created in other ways will not be treated as UTC even if the
|
|
1591
|
+
# environment variable "TZ" is "UTC".
|
|
1592
|
+
#
|
|
1567
1593
|
# Related: Time.utc.
|
|
1568
1594
|
#
|
|
1569
1595
|
def utc?: () -> bool
|
data/core/unbound_method.rbs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# <!-- rdoc-file=proc.c -->
|
|
2
|
-
# Ruby supports two forms of objectified methods. Class Method is used to
|
|
2
|
+
# Ruby supports two forms of objectified methods. Class `Method` is used to
|
|
3
3
|
# represent methods that are associated with a particular object: these method
|
|
4
4
|
# objects are bound to that object. Bound method objects for an object can be
|
|
5
5
|
# created using Object#method.
|
|
@@ -287,10 +287,18 @@ class UnboundMethod
|
|
|
287
287
|
|
|
288
288
|
# <!--
|
|
289
289
|
# rdoc-file=proc.c
|
|
290
|
-
# - meth.source_location -> [String, Integer]
|
|
290
|
+
# - meth.source_location -> [String, Integer, Integer, Integer, Integer]
|
|
291
291
|
# -->
|
|
292
|
-
# Returns the
|
|
293
|
-
#
|
|
292
|
+
# Returns the location where the method was defined. The returned Array
|
|
293
|
+
# contains:
|
|
294
|
+
# (1) the Ruby source filename
|
|
295
|
+
# (2) the line number where the definition starts
|
|
296
|
+
# (3) the column number where the definition starts
|
|
297
|
+
# (4) the line number where the definition ends
|
|
298
|
+
# (5) the column number where the definitions ends
|
|
299
|
+
#
|
|
300
|
+
# This method will return `nil` if the method was not defined in Ruby (i.e.
|
|
301
|
+
# native).
|
|
294
302
|
#
|
|
295
303
|
def source_location: () -> [String, Integer]?
|
|
296
304
|
|
|
@@ -298,8 +306,8 @@ class UnboundMethod
|
|
|
298
306
|
# rdoc-file=proc.c
|
|
299
307
|
# - meth.super_method -> method
|
|
300
308
|
# -->
|
|
301
|
-
# Returns a Method of superclass which would be called when super is used or
|
|
302
|
-
# if there is no method on superclass.
|
|
309
|
+
# Returns a `Method` of superclass which would be called when super is used or
|
|
310
|
+
# nil if there is no method on superclass.
|
|
303
311
|
#
|
|
304
312
|
def super_method: () -> UnboundMethod?
|
|
305
313
|
|
data/docs/aliases.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Aliases
|
|
2
|
+
|
|
3
|
+
This document explains module/class aliases and type aliases.
|
|
4
|
+
|
|
5
|
+
## Module/class alias
|
|
6
|
+
|
|
7
|
+
Module/class aliases give another name to a module/class.
|
|
8
|
+
This is useful for some syntaxes that has lexical constraints.
|
|
9
|
+
|
|
10
|
+
```rbs
|
|
11
|
+
class C
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class D = C # ::D is an alias for ::C
|
|
15
|
+
|
|
16
|
+
class E < D # ::E inherits from ::D, which is actually ::C
|
|
17
|
+
end
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Note that module/class aliases cannot be recursive.
|
|
21
|
+
|
|
22
|
+
So, we can define a *normalization* of aliased module/class names.
|
|
23
|
+
Normalization follows the chain of alias definitions and resolves them to the original module/class defined with `module`/`class` syntax.
|
|
24
|
+
|
|
25
|
+
```rbs
|
|
26
|
+
class C
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class D = C
|
|
30
|
+
class E = D
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`::E` is defined as an alias, and it can be normalized to `::C`.
|
|
34
|
+
|
|
35
|
+
## Type alias
|
|
36
|
+
|
|
37
|
+
The biggest difference from module/class alias is that type alias can be recursive.
|
|
38
|
+
|
|
39
|
+
```rbs
|
|
40
|
+
# cons_cell type is defined recursively
|
|
41
|
+
type cons_cell = nil
|
|
42
|
+
| [Integer, cons_cell]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
This means type aliases *cannot be* normalized generally.
|
|
46
|
+
So, we provide another operation for type alias, `DefinitionBuilder#expand_alias` and its family.
|
|
47
|
+
It substitutes with the immediate right hand side of a type alias.
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
cons_cell ===> nil | [Integer, cons_cell] (expand 1 step)
|
|
51
|
+
===> nil | [Integer, nil | [Integer, cons_cell]] (expand 2 steps)
|
|
52
|
+
===> ... (expand will go infinitely)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Note that the namespace of a type alias *can be* normalized, because they are module names.
|
|
56
|
+
|
|
57
|
+
```rbs
|
|
58
|
+
module M
|
|
59
|
+
type t = String
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
module N = M
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
With the type definition above, a type `::N::t` can be normalized to `::M::t`.
|
|
66
|
+
And then it can be expanded to `::String`.
|
|
67
|
+
|
|
68
|
+
> [!NOTE]
|
|
69
|
+
> This is something like an *unfold* operation in type theory.
|
|
70
|
+
|
|
71
|
+
## Type name resolution
|
|
72
|
+
|
|
73
|
+
Type name resolution in RBS usually rewrites *relative* type names to *absolute* type names.
|
|
74
|
+
`Environment#resolve_type_names` converts all type names in the RBS type definitions, and returns a new `Environment` object.
|
|
75
|
+
|
|
76
|
+
It also *normalizes* modules names in type names.
|
|
77
|
+
|
|
78
|
+
- If the type name can be resolved and normalized successfully, the AST has *absolute* type names.
|
|
79
|
+
- If the type name resolution/normalization fails, the AST has *relative* type names.
|
data/docs/collection.md
CHANGED
|
@@ -159,9 +159,9 @@ For example:
|
|
|
159
159
|
# manifest.yaml
|
|
160
160
|
|
|
161
161
|
dependencies:
|
|
162
|
-
# If your gem depends on
|
|
162
|
+
# If your gem depends on logger but the gemspec doesn't include logger,
|
|
163
163
|
# you need to write the following.
|
|
164
|
-
- name:
|
|
164
|
+
- name: logger
|
|
165
165
|
```
|
|
166
166
|
|
|
167
167
|
If the gem's RBS is managed with [ruby/gem_rbs_collection](https://github.com/ruby/gem_rbs_collection), put it as `gems/GEM_NAME/VERSION/manifest.yaml`. For example, `gems/activesupport/6.0/manifest.yaml`.
|
data/docs/gem.md
CHANGED
data/docs/sigs.md
CHANGED
|
@@ -131,10 +131,10 @@ You may need to specify `-r` or `-I` to load signatures.
|
|
|
131
131
|
The default is `-I sig`.
|
|
132
132
|
|
|
133
133
|
```shell
|
|
134
|
-
RBS_TEST_OPT='-r
|
|
134
|
+
RBS_TEST_OPT='-r logger -I sig'
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
-
Replacing `
|
|
137
|
+
Replacing `logger` with the `stdlib` you want to include. For example, if you need to load `Set` and `BigDecimal` in `stdlib`, you would need to have `RBS_TEST_OPT='-r set -r bigdecimal -I sig'`
|
|
138
138
|
|
|
139
139
|
`RBS_TEST_LOGLEVEL` can be used to configure log level. Defaults to `info`.
|
|
140
140
|
|
|
@@ -148,7 +148,7 @@ So, a typical command line to start the test would look like the following:
|
|
|
148
148
|
$ RBS_TEST_LOGLEVEL=error \
|
|
149
149
|
RBS_TEST_TARGET='Kaigi::*' \
|
|
150
150
|
RBS_TEST_SKIP='Kaigi::MonkeyPatch' \
|
|
151
|
-
RBS_TEST_OPT='-
|
|
151
|
+
RBS_TEST_OPT='-rlogger -Isig -Iprivate' \
|
|
152
152
|
RBS_TEST_RAISE=true \
|
|
153
153
|
RUBYOPT='-rbundler/setup -rrbs/test/setup' \
|
|
154
154
|
bundle exec rake test
|