rbs 4.0.0.dev.4 → 4.0.0

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.
Files changed (281) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +14 -14
  3. data/.github/workflows/bundle-update.yml +60 -0
  4. data/.github/workflows/c-check.yml +18 -11
  5. data/.github/workflows/comments.yml +5 -3
  6. data/.github/workflows/dependabot.yml +2 -2
  7. data/.github/workflows/ruby.yml +27 -34
  8. data/.github/workflows/rust.yml +95 -0
  9. data/.github/workflows/typecheck.yml +2 -2
  10. data/.github/workflows/windows.yml +2 -2
  11. data/.rubocop.yml +1 -1
  12. data/CHANGELOG.md +323 -0
  13. data/README.md +1 -1
  14. data/Rakefile +43 -33
  15. data/Steepfile +1 -0
  16. data/config.yml +426 -24
  17. data/core/array.rbs +307 -227
  18. data/core/basic_object.rbs +9 -8
  19. data/core/binding.rbs +0 -2
  20. data/core/builtin.rbs +2 -2
  21. data/core/class.rbs +6 -5
  22. data/core/comparable.rbs +55 -34
  23. data/core/complex.rbs +104 -78
  24. data/core/dir.rbs +61 -49
  25. data/core/encoding.rbs +12 -15
  26. data/core/enumerable.rbs +179 -87
  27. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  28. data/core/enumerator.rbs +65 -2
  29. data/core/errno.rbs +11 -2
  30. data/core/errors.rbs +58 -29
  31. data/core/exception.rbs +13 -13
  32. data/core/fiber.rbs +74 -54
  33. data/core/file.rbs +280 -177
  34. data/core/file_test.rbs +3 -3
  35. data/core/float.rbs +257 -92
  36. data/core/gc.rbs +425 -281
  37. data/core/hash.rbs +1045 -739
  38. data/core/integer.rbs +135 -137
  39. data/core/io/buffer.rbs +53 -42
  40. data/core/io/wait.rbs +13 -35
  41. data/core/io.rbs +192 -144
  42. data/core/kernel.rbs +216 -155
  43. data/core/marshal.rbs +4 -4
  44. data/core/match_data.rbs +15 -13
  45. data/core/math.rbs +107 -66
  46. data/core/method.rbs +69 -33
  47. data/core/module.rbs +244 -106
  48. data/core/nil_class.rbs +7 -6
  49. data/core/numeric.rbs +74 -63
  50. data/core/object.rbs +9 -11
  51. data/core/object_space.rbs +30 -23
  52. data/core/pathname.rbs +1322 -0
  53. data/core/proc.rbs +95 -58
  54. data/core/process.rbs +222 -202
  55. data/core/ractor.rbs +371 -515
  56. data/core/random.rbs +21 -3
  57. data/core/range.rbs +159 -57
  58. data/core/rational.rbs +60 -89
  59. data/core/rbs/unnamed/argf.rbs +60 -53
  60. data/core/rbs/unnamed/env_class.rbs +19 -14
  61. data/core/rbs/unnamed/main_class.rbs +123 -0
  62. data/core/rbs/unnamed/random.rbs +11 -118
  63. data/core/regexp.rbs +258 -214
  64. data/core/ruby.rbs +53 -0
  65. data/core/ruby_vm.rbs +38 -34
  66. data/core/rubygems/config_file.rbs +5 -5
  67. data/core/rubygems/errors.rbs +4 -71
  68. data/core/rubygems/requirement.rbs +5 -5
  69. data/core/rubygems/rubygems.rbs +16 -82
  70. data/core/rubygems/version.rbs +2 -3
  71. data/core/set.rbs +490 -360
  72. data/core/signal.rbs +26 -16
  73. data/core/string.rbs +3234 -1285
  74. data/core/struct.rbs +27 -26
  75. data/core/symbol.rbs +41 -34
  76. data/core/thread.rbs +135 -67
  77. data/core/time.rbs +81 -50
  78. data/core/trace_point.rbs +41 -35
  79. data/core/true_class.rbs +2 -2
  80. data/core/unbound_method.rbs +24 -16
  81. data/core/warning.rbs +7 -7
  82. data/docs/aliases.md +79 -0
  83. data/docs/collection.md +3 -3
  84. data/docs/config.md +171 -0
  85. data/docs/encoding.md +56 -0
  86. data/docs/gem.md +0 -1
  87. data/docs/inline.md +576 -0
  88. data/docs/sigs.md +3 -3
  89. data/docs/syntax.md +46 -16
  90. data/docs/type_fingerprint.md +21 -0
  91. data/exe/rbs +1 -1
  92. data/ext/rbs_extension/ast_translation.c +544 -116
  93. data/ext/rbs_extension/ast_translation.h +3 -0
  94. data/ext/rbs_extension/class_constants.c +16 -2
  95. data/ext/rbs_extension/class_constants.h +8 -0
  96. data/ext/rbs_extension/extconf.rb +5 -1
  97. data/ext/rbs_extension/legacy_location.c +33 -56
  98. data/ext/rbs_extension/legacy_location.h +37 -0
  99. data/ext/rbs_extension/main.c +44 -35
  100. data/include/rbs/ast.h +448 -173
  101. data/include/rbs/defines.h +27 -0
  102. data/include/rbs/lexer.h +30 -11
  103. data/include/rbs/location.h +25 -44
  104. data/include/rbs/parser.h +6 -6
  105. data/include/rbs/string.h +0 -2
  106. data/include/rbs/util/rbs_allocator.h +34 -13
  107. data/include/rbs/util/rbs_assert.h +12 -1
  108. data/include/rbs/util/rbs_constant_pool.h +0 -3
  109. data/include/rbs/util/rbs_encoding.h +2 -0
  110. data/include/rbs/util/rbs_unescape.h +2 -1
  111. data/include/rbs.h +8 -0
  112. data/lib/rbs/ast/annotation.rb +1 -1
  113. data/lib/rbs/ast/comment.rb +1 -1
  114. data/lib/rbs/ast/declarations.rb +10 -10
  115. data/lib/rbs/ast/members.rb +14 -14
  116. data/lib/rbs/ast/ruby/annotations.rb +293 -3
  117. data/lib/rbs/ast/ruby/comment_block.rb +24 -0
  118. data/lib/rbs/ast/ruby/declarations.rb +198 -3
  119. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
  120. data/lib/rbs/ast/ruby/members.rb +532 -22
  121. data/lib/rbs/ast/type_param.rb +24 -4
  122. data/lib/rbs/buffer.rb +20 -15
  123. data/lib/rbs/cli/diff.rb +16 -15
  124. data/lib/rbs/cli/validate.rb +38 -106
  125. data/lib/rbs/cli.rb +52 -19
  126. data/lib/rbs/collection/config/lockfile_generator.rb +14 -2
  127. data/lib/rbs/collection/sources/git.rb +1 -0
  128. data/lib/rbs/definition.rb +1 -1
  129. data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
  130. data/lib/rbs/definition_builder/method_builder.rb +20 -0
  131. data/lib/rbs/definition_builder.rb +147 -25
  132. data/lib/rbs/diff.rb +7 -1
  133. data/lib/rbs/environment.rb +227 -74
  134. data/lib/rbs/environment_loader.rb +0 -6
  135. data/lib/rbs/errors.rb +27 -18
  136. data/lib/rbs/inline_parser.rb +342 -6
  137. data/lib/rbs/location_aux.rb +1 -1
  138. data/lib/rbs/locator.rb +5 -1
  139. data/lib/rbs/method_type.rb +5 -3
  140. data/lib/rbs/parser_aux.rb +20 -7
  141. data/lib/rbs/prototype/helpers.rb +57 -0
  142. data/lib/rbs/prototype/rb.rb +3 -28
  143. data/lib/rbs/prototype/rbi.rb +3 -20
  144. data/lib/rbs/prototype/runtime.rb +8 -0
  145. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  146. data/lib/rbs/resolver/type_name_resolver.rb +116 -38
  147. data/lib/rbs/subtractor.rb +3 -1
  148. data/lib/rbs/test/type_check.rb +19 -2
  149. data/lib/rbs/type_name.rb +1 -1
  150. data/lib/rbs/types.rb +88 -78
  151. data/lib/rbs/unit_test/type_assertions.rb +35 -8
  152. data/lib/rbs/validator.rb +2 -2
  153. data/lib/rbs/version.rb +1 -1
  154. data/lib/rbs.rb +1 -2
  155. data/lib/rdoc/discover.rb +1 -1
  156. data/lib/rdoc_plugin/parser.rb +1 -1
  157. data/rbs.gemspec +4 -3
  158. data/rust/.gitignore +1 -0
  159. data/rust/Cargo.lock +378 -0
  160. data/rust/Cargo.toml +7 -0
  161. data/rust/ruby-rbs/Cargo.toml +22 -0
  162. data/rust/ruby-rbs/build.rs +764 -0
  163. data/rust/ruby-rbs/examples/locations.rs +60 -0
  164. data/rust/ruby-rbs/src/lib.rs +1 -0
  165. data/rust/ruby-rbs/src/node/mod.rs +742 -0
  166. data/rust/ruby-rbs/tests/sanity.rs +47 -0
  167. data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
  168. data/rust/ruby-rbs-sys/Cargo.toml +23 -0
  169. data/rust/ruby-rbs-sys/build.rs +204 -0
  170. data/rust/ruby-rbs-sys/src/lib.rs +50 -0
  171. data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
  172. data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
  173. data/rust/ruby-rbs-sys/wrapper.h +1 -0
  174. data/schema/typeParam.json +17 -1
  175. data/sig/ast/ruby/annotations.rbs +315 -4
  176. data/sig/ast/ruby/comment_block.rbs +8 -0
  177. data/sig/ast/ruby/declarations.rbs +102 -4
  178. data/sig/ast/ruby/members.rbs +108 -2
  179. data/sig/cli/diff.rbs +5 -11
  180. data/sig/cli/validate.rbs +12 -8
  181. data/sig/cli.rbs +18 -18
  182. data/sig/definition.rbs +6 -1
  183. data/sig/definition_builder.rbs +2 -0
  184. data/sig/environment.rbs +70 -12
  185. data/sig/errors.rbs +13 -14
  186. data/sig/inline_parser.rbs +39 -2
  187. data/sig/locator.rbs +0 -2
  188. data/sig/manifest.yaml +0 -1
  189. data/sig/method_builder.rbs +3 -1
  190. data/sig/parser.rbs +31 -13
  191. data/sig/prototype/helpers.rbs +2 -0
  192. data/sig/resolver/type_name_resolver.rbs +35 -7
  193. data/sig/source.rbs +3 -3
  194. data/sig/type_param.rbs +13 -8
  195. data/sig/types.rbs +6 -7
  196. data/sig/unit_test/spy.rbs +0 -8
  197. data/sig/unit_test/type_assertions.rbs +11 -0
  198. data/src/ast.c +410 -153
  199. data/src/lexer.c +1392 -1313
  200. data/src/lexer.re +3 -0
  201. data/src/lexstate.c +58 -37
  202. data/src/location.c +8 -48
  203. data/src/parser.c +977 -516
  204. data/src/string.c +0 -48
  205. data/src/util/rbs_allocator.c +89 -71
  206. data/src/util/rbs_assert.c +1 -1
  207. data/src/util/rbs_buffer.c +2 -2
  208. data/src/util/rbs_constant_pool.c +10 -14
  209. data/src/util/rbs_encoding.c +4 -8
  210. data/src/util/rbs_unescape.c +56 -20
  211. data/stdlib/bigdecimal/0/big_decimal.rbs +116 -98
  212. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  213. data/stdlib/cgi/0/core.rbs +9 -393
  214. data/stdlib/cgi/0/manifest.yaml +1 -0
  215. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  216. data/stdlib/coverage/0/coverage.rbs +7 -4
  217. data/stdlib/date/0/date.rbs +92 -79
  218. data/stdlib/date/0/date_time.rbs +25 -24
  219. data/stdlib/delegate/0/delegator.rbs +10 -7
  220. data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
  221. data/stdlib/digest/0/digest.rbs +110 -0
  222. data/stdlib/erb/0/erb.rbs +748 -347
  223. data/stdlib/etc/0/etc.rbs +55 -50
  224. data/stdlib/fileutils/0/fileutils.rbs +158 -139
  225. data/stdlib/forwardable/0/forwardable.rbs +13 -10
  226. data/stdlib/io-console/0/io-console.rbs +2 -2
  227. data/stdlib/json/0/json.rbs +217 -136
  228. data/stdlib/monitor/0/monitor.rbs +3 -3
  229. data/stdlib/net-http/0/net-http.rbs +162 -134
  230. data/stdlib/objspace/0/objspace.rbs +17 -34
  231. data/stdlib/open-uri/0/open-uri.rbs +48 -8
  232. data/stdlib/open3/0/open3.rbs +469 -10
  233. data/stdlib/openssl/0/openssl.rbs +475 -357
  234. data/stdlib/optparse/0/optparse.rbs +26 -17
  235. data/stdlib/pathname/0/pathname.rbs +11 -1381
  236. data/stdlib/pp/0/pp.rbs +9 -8
  237. data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
  238. data/stdlib/pstore/0/pstore.rbs +35 -30
  239. data/stdlib/psych/0/psych.rbs +65 -12
  240. data/stdlib/psych/0/store.rbs +2 -4
  241. data/stdlib/pty/0/pty.rbs +9 -6
  242. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  243. data/stdlib/rdoc/0/code_object.rbs +2 -1
  244. data/stdlib/rdoc/0/parser.rbs +1 -1
  245. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  246. data/stdlib/rdoc/0/store.rbs +1 -1
  247. data/stdlib/resolv/0/resolv.rbs +25 -68
  248. data/stdlib/ripper/0/ripper.rbs +22 -19
  249. data/stdlib/securerandom/0/manifest.yaml +2 -0
  250. data/stdlib/securerandom/0/securerandom.rbs +7 -20
  251. data/stdlib/shellwords/0/shellwords.rbs +2 -2
  252. data/stdlib/singleton/0/singleton.rbs +3 -0
  253. data/stdlib/socket/0/addrinfo.rbs +7 -7
  254. data/stdlib/socket/0/basic_socket.rbs +3 -3
  255. data/stdlib/socket/0/ip_socket.rbs +10 -8
  256. data/stdlib/socket/0/socket.rbs +23 -10
  257. data/stdlib/socket/0/tcp_server.rbs +1 -1
  258. data/stdlib/socket/0/tcp_socket.rbs +11 -3
  259. data/stdlib/socket/0/udp_socket.rbs +1 -1
  260. data/stdlib/socket/0/unix_server.rbs +1 -1
  261. data/stdlib/stringio/0/stringio.rbs +1177 -85
  262. data/stdlib/strscan/0/string_scanner.rbs +27 -25
  263. data/stdlib/tempfile/0/tempfile.rbs +25 -21
  264. data/stdlib/time/0/time.rbs +8 -6
  265. data/stdlib/timeout/0/timeout.rbs +63 -7
  266. data/stdlib/tsort/0/cyclic.rbs +3 -0
  267. data/stdlib/tsort/0/tsort.rbs +7 -6
  268. data/stdlib/uri/0/common.rbs +42 -20
  269. data/stdlib/uri/0/file.rbs +3 -3
  270. data/stdlib/uri/0/generic.rbs +26 -18
  271. data/stdlib/uri/0/http.rbs +2 -2
  272. data/stdlib/uri/0/ldap.rbs +2 -2
  273. data/stdlib/uri/0/mailto.rbs +3 -3
  274. data/stdlib/uri/0/rfc2396_parser.rbs +12 -12
  275. data/stdlib/zlib/0/deflate.rbs +4 -3
  276. data/stdlib/zlib/0/gzip_reader.rbs +6 -6
  277. data/stdlib/zlib/0/gzip_writer.rbs +14 -12
  278. data/stdlib/zlib/0/inflate.rbs +1 -1
  279. data/stdlib/zlib/0/need_dict.rbs +1 -1
  280. data/stdlib/zlib/0/zstream.rbs +1 -0
  281. metadata +50 -6
data/core/time.rbs CHANGED
@@ -47,32 +47,38 @@
47
47
  #
48
48
  # ## Time Internal Representation
49
49
  #
50
- # Time implementation uses a signed 63 bit integer, Integer, or Rational. It is
51
- # a number of nanoseconds since the *Epoch*. The signed 63 bit integer can
52
- # represent 1823-11-12 to 2116-02-20. When Integer or Rational is used (before
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 "gmtime" is used for UTC.
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
71
77
  # `time_t` (before 1970).
72
78
  #
73
- # `struct tm` has *tm_year* member to represent years. (`tm_year = 0` means the
74
- # 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.
79
+ # `struct tm` has *tm_year* member to represent years. (<code>tm_year = 0</code>
80
+ # means the year 1900.) It is defined as `int` in the C standard. *tm_year* can
81
+ # represent 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
@@ -253,9 +259,9 @@
253
259
  #
254
260
  # Certain `Time` methods accept arguments that specify timezones:
255
261
  #
256
- # * Time.at: keyword argument `in:`.
257
- # * Time.new: positional argument `zone` or keyword argument `in:`.
258
- # * Time.now: keyword argument `in:`.
262
+ # * Time.at: keyword argument <code>in:</code>.
263
+ # * Time.new: positional argument `zone` or keyword argument <code>in:</code>.
264
+ # * Time.now: keyword argument <code>in:</code>.
259
265
  # * Time#getlocal: positional argument `zone`.
260
266
  # * Time#localtime: positional argument `zone`.
261
267
  #
@@ -270,11 +276,11 @@
270
276
  #
271
277
  # ### Hours/Minutes Offsets
272
278
  #
273
- # The zone value may be a string offset from UTC in the form `'+HH:MM'` or
274
- # `'-HH:MM'`, where:
279
+ # The zone value may be a string offset from UTC in the form
280
+ # <code>'+HH:MM'</code> or <code>'-HH:MM'</code>, where:
275
281
  #
276
- # * `HH` is the 2-digit hour in the range `0..23`.
277
- # * `MM` is the 2-digit minute in the range `0..59`.
282
+ # * `HH` is the 2-digit hour in the range <code>0..23</code>.
283
+ # * `MM` is the 2-digit minute in the range <code>0..59</code>.
278
284
  #
279
285
  # Examples:
280
286
  #
@@ -284,8 +290,8 @@
284
290
  #
285
291
  # ### Single-Letter Offsets
286
292
  #
287
- # The zone value may be a letter in the range `'A'..'I'` or `'K'..'Z'`; see
288
- # [List of military time
293
+ # The zone value may be a letter in the range <code>'A'..'I'</code> or
294
+ # <code>'K'..'Z'</code>; see [List of military time
289
295
  # zones](https://en.wikipedia.org/wiki/List_of_military_time_zones):
290
296
  #
291
297
  # t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
@@ -298,7 +304,7 @@
298
304
  # ### Integer Offsets
299
305
  #
300
306
  # The zone value may be an integer number of seconds in the range
301
- # `-86399..86399`:
307
+ # <code>-86399..86399</code>:
302
308
  #
303
309
  # t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
304
310
  # Time.at(t, in: -86399) # => 1999-12-31 20:15:02 -235959
@@ -315,7 +321,7 @@
315
321
  # * `local_to_utc`:
316
322
  #
317
323
  # Called when Time.new is invoked with `tz` as the value of positional
318
- # argument `zone` or keyword argument `in:`.
324
+ # argument `zone` or keyword argument <code>in:</code>.
319
325
  #
320
326
  # Argument
321
327
  # : a [Time-like object](rdoc-ref:Time@Time-Like+Objects).
@@ -328,8 +334,9 @@
328
334
  # * `utc_to_local`:
329
335
  #
330
336
  # Called when Time.at or Time.now is invoked with `tz` as the value for
331
- # keyword argument `in:`, and when Time#getlocal or Time#localtime is called
332
- # with `tz` as the value for positional argument `zone`.
337
+ # keyword argument <code>in:</code>, and when Time#getlocal or
338
+ # Time#localtime is called with `tz` as the value for positional argument
339
+ # `zone`.
333
340
  #
334
341
  # The UTC offset will be calculated as the difference between the original
335
342
  # time and the returned object as an `Integer`. If the object is in fixed
@@ -348,7 +355,8 @@
348
355
  #
349
356
  # * `abbr`:
350
357
  #
351
- # Called when Time#strftime is invoked with a format involving `%Z`.
358
+ # Called when Time#strftime is invoked with a format involving
359
+ # <code>%Z</code>.
352
360
  #
353
361
  # Argument
354
362
  # : a [Time-like object](rdoc-ref:Time@Time-Like+Objects).
@@ -357,11 +365,12 @@
357
365
  # : a string abbreviation for the timezone name.
358
366
  #
359
367
  #
360
- # * `dst?`:
368
+ # * <code>dst?</code>:
361
369
  #
362
370
  # Called when Time.at or Time.now is invoked with `tz` as the value for
363
- # keyword argument `in:`, and when Time#getlocal or Time#localtime is called
364
- # with `tz` as the value for positional argument `zone`.
371
+ # keyword argument <code>in:</code>, and when Time#getlocal or
372
+ # Time#localtime is called with `tz` as the value for positional argument
373
+ # `zone`.
365
374
  #
366
375
  # Argument
367
376
  # : a [Time-like object](rdoc-ref:Time@Time-Like+Objects).
@@ -372,7 +381,7 @@
372
381
  #
373
382
  # * `name`:
374
383
  #
375
- # Called when `Marshal.dump(t)` is invoked
384
+ # Called when <code>Marshal.dump(t)</code> is invoked
376
385
  #
377
386
  # Argument
378
387
  # : none.
@@ -466,7 +475,7 @@ class Time < Object
466
475
  # Required argument `time` may be either of:
467
476
  #
468
477
  # * A `Time` object, whose value is the basis for the returned time; also
469
- # influenced by optional keyword argument `in:` (see below).
478
+ # influenced by optional keyword argument <code>in:</code> (see below).
470
479
  # * A numeric number of [Epoch seconds](rdoc-ref:Time@Epoch+Seconds) for the
471
480
  # returned time.
472
481
  #
@@ -484,29 +493,29 @@ class Time < Object
484
493
  # together to specify subseconds for the returned time; argument `units`
485
494
  # specifies the units for `subsec`:
486
495
  #
487
- # * `:millisecond`: `subsec` in milliseconds:
496
+ # * <code>:millisecond</code>: `subsec` in milliseconds:
488
497
  #
489
498
  # Time.at(secs, 0, :millisecond) # => 2000-12-31 23:59:59 -0600
490
499
  # Time.at(secs, 500, :millisecond) # => 2000-12-31 23:59:59.5 -0600
491
500
  # Time.at(secs, 1000, :millisecond) # => 2001-01-01 00:00:00 -0600
492
501
  # Time.at(secs, -1000, :millisecond) # => 2000-12-31 23:59:58 -0600
493
502
  #
494
- # * `:microsecond` or `:usec`: `subsec` in microseconds:
503
+ # * <code>:microsecond</code> or <code>:usec</code>: `subsec` in microseconds:
495
504
  #
496
505
  # Time.at(secs, 0, :microsecond) # => 2000-12-31 23:59:59 -0600
497
506
  # Time.at(secs, 500000, :microsecond) # => 2000-12-31 23:59:59.5 -0600
498
507
  # Time.at(secs, 1000000, :microsecond) # => 2001-01-01 00:00:00 -0600
499
508
  # Time.at(secs, -1000000, :microsecond) # => 2000-12-31 23:59:58 -0600
500
509
  #
501
- # * `:nanosecond` or `:nsec`: `subsec` in nanoseconds:
510
+ # * <code>:nanosecond</code> or <code>:nsec</code>: `subsec` in nanoseconds:
502
511
  #
503
512
  # Time.at(secs, 0, :nanosecond) # => 2000-12-31 23:59:59 -0600
504
513
  # Time.at(secs, 500000000, :nanosecond) # => 2000-12-31 23:59:59.5 -0600
505
514
  # Time.at(secs, 1000000000, :nanosecond) # => 2001-01-01 00:00:00 -0600
506
515
  # Time.at(secs, -1000000000, :nanosecond) # => 2000-12-31 23:59:58 -0600
507
516
  #
508
- # Optional keyword argument `in: zone` specifies the timezone for the returned
509
- # time:
517
+ # Optional keyword argument <code>in: zone</code> specifies the timezone for the
518
+ # returned time:
510
519
  #
511
520
  # Time.at(secs, in: '+12:00') # => 2001-01-01 17:59:59 +1200
512
521
  # Time.at(secs, in: '-12:00') # => 2000-12-31 17:59:59 -1200
@@ -791,7 +800,7 @@ class Time < Object
791
800
  # -->
792
801
  # Compares `self` with `other_time`; returns:
793
802
  #
794
- # * `-1`, if `self` is less than `other_time`.
803
+ # * <code>-1</code>, if `self` is less than `other_time`.
795
804
  # * `0`, if `self` is equal to `other_time`.
796
805
  # * `1`, if `self` is greater then `other_time`.
797
806
  # * `nil`, if `self` and `other_time` are incomparable.
@@ -819,9 +828,9 @@ class Time < Object
819
828
  def >=: (Time arg0) -> bool
820
829
 
821
830
  # <!-- rdoc-file=time.c -->
822
- # Returns a string representation of `self`, formatted by `strftime('%a %b %e %T
823
- # %Y')` or its shorthand version `strftime('%c')`; see [Formats for Dates and
824
- # Times](rdoc-ref:strftime_formatting.rdoc):
831
+ # Returns a string representation of `self`, formatted by <code>strftime('%a %b
832
+ # %e %T %Y')</code> or its shorthand version <code>strftime('%c')</code>; see
833
+ # [Formats for Dates and Times](rdoc-ref:strftime_formatting.rdoc):
825
834
  #
826
835
  # t = Time.new(2000, 12, 31, 23, 59, 59, 0.5)
827
836
  # t.ctime # => "Sun Dec 31 23:59:59 2000"
@@ -839,9 +848,9 @@ class Time < Object
839
848
  # rdoc-file=time.c
840
849
  # - ctime -> string
841
850
  # -->
842
- # Returns a string representation of `self`, formatted by `strftime('%a %b %e %T
843
- # %Y')` or its shorthand version `strftime('%c')`; see [Formats for Dates and
844
- # Times](rdoc-ref:strftime_formatting.rdoc):
851
+ # Returns a string representation of `self`, formatted by <code>strftime('%a %b
852
+ # %e %T %Y')</code> or its shorthand version <code>strftime('%c')</code>; see
853
+ # [Formats for Dates and Times](rdoc-ref:strftime_formatting.rdoc):
845
854
  #
846
855
  # t = Time.new(2000, 12, 31, 23, 59, 59, 0.5)
847
856
  # t.ctime # => "Sun Dec 31 23:59:59 2000"
@@ -871,8 +880,10 @@ class Time < Object
871
880
  # - deconstruct_keys(array_of_names_or_nil) -> hash
872
881
  # -->
873
882
  # Returns a hash of the name/value pairs, to use in pattern matching. Possible
874
- # keys are: `:year`, `:month`, `:day`, `:yday`, `:wday`, `:hour`, `:min`,
875
- # `:sec`, `:subsec`, `:dst`, `:zone`.
883
+ # keys are: <code>:year</code>, <code>:month</code>, <code>:day</code>,
884
+ # <code>:yday</code>, <code>:wday</code>, <code>:hour</code>, <code>:min</code>,
885
+ # <code>:sec</code>, <code>:subsec</code>, <code>:dst</code>,
886
+ # <code>:zone</code>.
876
887
  #
877
888
  # Possible usages:
878
889
  #
@@ -984,10 +995,20 @@ class Time < Object
984
995
  # now = Time.now
985
996
  # # => 2022-08-18 10:24:13.5398485 -0500
986
997
  # now.utc? # => false
998
+ # now.getutc.utc? # => true
987
999
  # utc = Time.utc(2000, 1, 1, 20, 15, 1)
988
1000
  # # => 2000-01-01 20:15:01 UTC
989
1001
  # utc.utc? # => true
990
1002
  #
1003
+ # `Time` objects created with these methods are considered to be in UTC:
1004
+ #
1005
+ # * Time.utc
1006
+ # * Time#utc
1007
+ # * Time#getutc
1008
+ #
1009
+ # Objects created in other ways will not be treated as UTC even if the
1010
+ # environment variable "TZ" is "UTC".
1011
+ #
991
1012
  # Related: Time.utc.
992
1013
  #
993
1014
  def gmt?: () -> bool
@@ -1119,9 +1140,9 @@ class Time < Object
1119
1140
  # # => ["0", "1", "1", "0", "0", "0"]
1120
1141
  # Time.new(*a) # => 0000-01-01 00:00:00 -0600
1121
1142
  #
1122
- # When positional argument `zone` or keyword argument `in:` is given, the new
1123
- # `Time` object is in the specified timezone. For the forms of argument `zone`,
1124
- # see [Timezone Specifiers](rdoc-ref:Time@Timezone+Specifiers):
1143
+ # When positional argument `zone` or keyword argument <code>in:</code> is given,
1144
+ # the new `Time` object is in the specified timezone. For the forms of argument
1145
+ # `zone`, see [Timezone Specifiers](rdoc-ref:Time@Timezone+Specifiers):
1125
1146
  #
1126
1147
  # Time.new(2000, 1, 1, 0, 0, 0, '+12:00')
1127
1148
  # # => 2000-01-01 00:00:00 +1200
@@ -1130,9 +1151,9 @@ class Time < Object
1130
1151
  # Time.new(in: '-12:00')
1131
1152
  # # => 2022-08-23 08:49:26.1941467 -1200
1132
1153
  #
1133
- # Since `in:` keyword argument just provides the default, so if the first
1134
- # argument in single string form contains time zone information, this keyword
1135
- # argument will be silently ignored.
1154
+ # Since <code>in:</code> keyword argument just provides the default, so if the
1155
+ # first argument in single string form contains time zone information, this
1156
+ # keyword argument will be silently ignored.
1136
1157
  #
1137
1158
  # Time.new('2000-01-01 00:00:00 +0100', in: '-0500').utc_offset # => 3600
1138
1159
  #
@@ -1560,10 +1581,20 @@ class Time < Object
1560
1581
  # now = Time.now
1561
1582
  # # => 2022-08-18 10:24:13.5398485 -0500
1562
1583
  # now.utc? # => false
1584
+ # now.getutc.utc? # => true
1563
1585
  # utc = Time.utc(2000, 1, 1, 20, 15, 1)
1564
1586
  # # => 2000-01-01 20:15:01 UTC
1565
1587
  # utc.utc? # => true
1566
1588
  #
1589
+ # `Time` objects created with these methods are considered to be in UTC:
1590
+ #
1591
+ # * Time.utc
1592
+ # * Time#utc
1593
+ # * Time#getutc
1594
+ #
1595
+ # Objects created in other ways will not be treated as UTC even if the
1596
+ # environment variable "TZ" is "UTC".
1597
+ #
1567
1598
  # Related: Time.utc.
1568
1599
  #
1569
1600
  def utc?: () -> bool
data/core/trace_point.rbs CHANGED
@@ -21,61 +21,62 @@
21
21
  # If you don't specify the types of events you want to listen for, TracePoint
22
22
  # will include all available events.
23
23
  #
24
- # **Note:** Do not depend on the current event set, as this list is subject to
25
- # change. Instead, it is recommended to specify the types of events you want to
26
- # use.
24
+ # <strong>Note:</strong> Do not depend on the current event set, as this list is
25
+ # subject to change. Instead, it is recommended to specify the types of events
26
+ # you want to use.
27
27
  #
28
- # To filter what is traced, you can pass any of the following as `events`:
28
+ # To filter what is traced, you can pass any number of the following as
29
+ # `events`:
29
30
  #
30
- # `:line`
31
+ # <code>:line</code>
31
32
  # : Execute an expression or statement on a new line.
32
33
  #
33
- # `:class`
34
+ # <code>:class</code>
34
35
  # : Start a class or module definition.
35
36
  #
36
- # `:end`
37
+ # <code>:end</code>
37
38
  # : Finish a class or module definition.
38
39
  #
39
- # `:call`
40
+ # <code>:call</code>
40
41
  # : Call a Ruby method.
41
42
  #
42
- # `:return`
43
+ # <code>:return</code>
43
44
  # : Return from a Ruby method.
44
45
  #
45
- # `:c_call`
46
+ # <code>:c_call</code>
46
47
  # : Call a C-language routine.
47
48
  #
48
- # `:c_return`
49
+ # <code>:c_return</code>
49
50
  # : Return from a C-language routine.
50
51
  #
51
- # `:raise`
52
+ # <code>:raise</code>
52
53
  # : Raise an exception.
53
54
  #
54
- # `:rescue`
55
+ # <code>:rescue</code>
55
56
  # : Rescue an exception.
56
57
  #
57
- # `:b_call`
58
+ # <code>:b_call</code>
58
59
  # : Event hook at block entry.
59
60
  #
60
- # `:b_return`
61
+ # <code>:b_return</code>
61
62
  # : Event hook at block ending.
62
63
  #
63
- # `:a_call`
64
+ # <code>:a_call</code>
64
65
  # : Event hook at all calls (`call`, `b_call`, and `c_call`).
65
66
  #
66
- # `:a_return`
67
+ # <code>:a_return</code>
67
68
  # : Event hook at all returns (`return`, `b_return`, and `c_return`).
68
69
  #
69
- # `:thread_begin`
70
+ # <code>:thread_begin</code>
70
71
  # : Event hook at thread beginning.
71
72
  #
72
- # `:thread_end`
73
+ # <code>:thread_end</code>
73
74
  # : Event hook at thread ending.
74
75
  #
75
- # `:fiber_switch`
76
+ # <code>:fiber_switch</code>
76
77
  # : Event hook at fiber switch.
77
78
  #
78
- # `:script_compiled`
79
+ # <code>:script_compiled</code>
79
80
  # : New Ruby code compiled (with `eval`, `load`, or `require`).
80
81
  #
81
82
  class TracePoint
@@ -107,8 +108,8 @@ class TracePoint
107
108
  #
108
109
  # A block must be given; otherwise, an ArgumentError is raised.
109
110
  #
110
- # If the trace method isn't included in the given events filter, a RuntimeError
111
- # is raised.
111
+ # If the trace method isn't supported for the given event(s) filter, a
112
+ # RuntimeError is raised.
112
113
  #
113
114
  # TracePoint.trace(:line) do |tp|
114
115
  # p tp.raised_exception
@@ -122,7 +123,9 @@ class TracePoint
122
123
  # end
123
124
  # $tp.lineno #=> access from outside (RuntimeError)
124
125
  #
125
- # Access from other threads is also forbidden.
126
+ # Access from other ractors, threads or fibers is forbidden. TracePoints are
127
+ # active per-ractor so if you enable a TracePoint in one ractor, other ractors
128
+ # will not be affected.
126
129
  #
127
130
  def self.new: (*_ToSym events) { (instance tp) -> void } -> instance
128
131
 
@@ -137,7 +140,7 @@ class TracePoint
137
140
  #
138
141
  # If called when reentrance is already allowed, it raises a RuntimeError.
139
142
  #
140
- # **Example:**
143
+ # <strong>Example:</strong>
141
144
  #
142
145
  # # Without reentry
143
146
  # # ---------------
@@ -220,8 +223,8 @@ class TracePoint
220
223
  # -->
221
224
  # Returns the generated binding object from the event.
222
225
  #
223
- # Note that for `:c_call` and `:c_return` events, the method returns `nil`,
224
- # since C methods themselves do not have bindings.
226
+ # Note that for <code>:c_call</code> and <code>:c_return</code> events, the
227
+ # method returns `nil`, since C methods themselves do not have bindings.
225
228
  #
226
229
  def binding: () -> Binding?
227
230
 
@@ -256,12 +259,13 @@ class TracePoint
256
259
  # C.new.foo
257
260
  # end
258
261
  #
259
- # **Note:** #defined_class returns the singleton class.
262
+ # <strong>Note:</strong> #defined_class returns the singleton class.
260
263
  #
261
264
  # The 6th block parameter of Kernel#set_trace_func passes the original class
262
265
  # attached by the singleton class.
263
266
  #
264
- # **This is a difference between Kernel#set_trace_func and TracePoint.**
267
+ # <strong>This is a difference between Kernel#set_trace_func and
268
+ # TracePoint.</strong>
265
269
  #
266
270
  # class C; def self.foo; end; end
267
271
  # trace = TracePoint.new(:call) do |tp|
@@ -429,8 +433,8 @@ class TracePoint
429
433
  # rdoc-file=trace_point.rb
430
434
  # - raised_exception()
431
435
  # -->
432
- # Returns the exception raised on the `:raise` event or rescued on the `:rescue`
433
- # event.
436
+ # Returns the exception raised on the <code>:raise</code> event or rescued on
437
+ # the <code>:rescue</code> event.
434
438
  #
435
439
  def raised_exception: () -> Exception
436
440
 
@@ -438,7 +442,8 @@ class TracePoint
438
442
  # rdoc-file=trace_point.rb
439
443
  # - return_value()
440
444
  # -->
441
- # Returns the return value from `:return`, `:c_return`, and `:b_return` events.
445
+ # Returns the return value from <code>:return</code>, <code>:c_return</code>,
446
+ # and <code>:b_return</code> events.
442
447
  #
443
448
  def return_value: () -> untyped
444
449
 
@@ -449,7 +454,7 @@ class TracePoint
449
454
  # Returns the trace object during the event.
450
455
  #
451
456
  # Similar to the following, but it returns the correct object (the method
452
- # receiver) for `:c_call` and `:c_return` events:
457
+ # receiver) for <code>:c_call</code> and <code>:c_return</code> events:
453
458
  #
454
459
  # trace.binding.eval('self')
455
460
  #
@@ -460,7 +465,7 @@ class TracePoint
460
465
  # - eval_script()
461
466
  # -->
462
467
  # Returns the compiled source code (String) from eval methods on the
463
- # `:script_compiled` event. If loaded from a file, it returns `nil`.
468
+ # <code>:script_compiled</code> event. If loaded from a file, it returns `nil`.
464
469
  #
465
470
  def eval_script: () -> String?
466
471
 
@@ -469,7 +474,8 @@ class TracePoint
469
474
  # - instruction_sequence()
470
475
  # -->
471
476
  # Returns the compiled instruction sequence represented by a
472
- # RubyVM::InstructionSequence instance on the `:script_compiled` event.
477
+ # RubyVM::InstructionSequence instance on the <code>:script_compiled</code>
478
+ # event.
473
479
  #
474
480
  # Note that this method is CRuby-specific.
475
481
  #
data/core/true_class.rbs CHANGED
@@ -58,7 +58,7 @@ class TrueClass
58
58
  | (untyped obj) -> bool
59
59
 
60
60
  # <!-- rdoc-file=object.c -->
61
- # Returns string `'true'`:
61
+ # Returns string <code>'true'</code>:
62
62
  #
63
63
  # true.to_s # => "true"
64
64
  #
@@ -70,7 +70,7 @@ class TrueClass
70
70
  # rdoc-file=object.c
71
71
  # - true.to_s -> 'true'
72
72
  # -->
73
- # Returns string `'true'`:
73
+ # Returns string <code>'true'</code>:
74
74
  #
75
75
  # true.to_s # => "true"
76
76
  #
@@ -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.
@@ -150,7 +150,7 @@ class UnboundMethod
150
150
  # - umeth.bind(obj) -> method
151
151
  # -->
152
152
  # Bind *umeth* to *obj*. If Klass was the class from which *umeth* was obtained,
153
- # `obj.kind_of?(Klass)` must be true.
153
+ # <code>obj.kind_of?(Klass)</code> must be true.
154
154
  #
155
155
  # class A
156
156
  # def test
@@ -170,7 +170,7 @@ class UnboundMethod
170
170
  # bm = um.bind(A.new)
171
171
  # bm.call
172
172
  #
173
- # *produces:*
173
+ # <em>produces:</em>
174
174
  #
175
175
  # In test, class = C
176
176
  # In test, class = B
@@ -199,12 +199,12 @@ class UnboundMethod
199
199
  # Net::HTTP.method(:get).inspect
200
200
  # #=> "#<Method: Net::HTTP.get(uri_or_host, path=..., port=...) <skip>/lib/ruby/2.7.0/net/http.rb:457>"
201
201
  #
202
- # `...` in argument definition means argument is optional (has some default
203
- # value).
202
+ # <code>...</code> in argument definition means argument is optional (has some
203
+ # default value).
204
204
  #
205
205
  # For methods defined in C (language core and extensions), location and argument
206
206
  # names can't be extracted, and only generic information is provided in form of
207
- # `*` (any number of arguments) or `_` (some positional argument).
207
+ # <code>*</code> (any number of arguments) or `_` (some positional argument).
208
208
  #
209
209
  # "cat".method(:count).inspect #=> "#<Method: String#count(*)>"
210
210
  # "cat".method(:+).inspect #=> "#<Method: String#+(_)>""
@@ -227,12 +227,12 @@ class UnboundMethod
227
227
  # Net::HTTP.method(:get).inspect
228
228
  # #=> "#<Method: Net::HTTP.get(uri_or_host, path=..., port=...) <skip>/lib/ruby/2.7.0/net/http.rb:457>"
229
229
  #
230
- # `...` in argument definition means argument is optional (has some default
231
- # value).
230
+ # <code>...</code> in argument definition means argument is optional (has some
231
+ # default value).
232
232
  #
233
233
  # For methods defined in C (language core and extensions), location and argument
234
234
  # names can't be extracted, and only generic information is provided in form of
235
- # `*` (any number of arguments) or `_` (some positional argument).
235
+ # <code>*</code> (any number of arguments) or `_` (some positional argument).
236
236
  #
237
237
  # "cat".method(:count).inspect #=> "#<Method: String#count(*)>"
238
238
  # "cat".method(:+).inspect #=> "#<Method: String#+(_)>""
@@ -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 Ruby source filename and line number containing this method or nil
293
- # if this method was not defined in Ruby (i.e. native).
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 nil
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
 
@@ -322,8 +330,8 @@ class UnboundMethod
322
330
  # - umeth.bind_call(recv, args, ...) -> obj
323
331
  # -->
324
332
  # Bind *umeth* to *recv* and then invokes the method with the specified
325
- # arguments. This is semantically equivalent to `umeth.bind(recv).call(args,
326
- # ...)`.
333
+ # arguments. This is semantically equivalent to
334
+ # <code>umeth.bind(recv).call(args, ...)</code>.
327
335
  #
328
336
  def bind_call: (untyped recv, *untyped, **untyped) ?{ (?) -> untyped } -> untyped
329
337
  end
data/core/warning.rbs CHANGED
@@ -5,11 +5,11 @@
5
5
  #
6
6
  # Changing the behavior of Warning.warn is useful to customize how warnings are
7
7
  # handled by Ruby, for instance by filtering some warnings, and/or outputting
8
- # warnings somewhere other than `$stderr`.
8
+ # warnings somewhere other than <code>$stderr</code>.
9
9
  #
10
10
  # If you want to change the behavior of Warning.warn you should use
11
- # `Warning.extend(MyNewModuleWithWarnMethod)` and you can use `super` to get the
12
- # default behavior of printing the warning to `$stderr`.
11
+ # <code>Warning.extend(MyNewModuleWithWarnMethod)</code> and you can use `super`
12
+ # to get the default behavior of printing the warning to <code>$stderr</code>.
13
13
  #
14
14
  # Example:
15
15
  # module MyWarningFilter
@@ -41,18 +41,18 @@ module Warning
41
41
  # Returns the flag to show the warning messages for `category`. Supported
42
42
  # categories are:
43
43
  #
44
- # `:deprecated`
44
+ # <code>:deprecated</code>
45
45
  # : deprecation warnings
46
- # * assignment of non-nil value to `$,` and `$;`
46
+ # * assignment of non-nil value to <code>$,</code> and <code>$;</code>
47
47
  # * keyword arguments
48
48
  # etc.
49
49
  #
50
50
  #
51
- # `:experimental`
51
+ # <code>:experimental</code>
52
52
  # : experimental features
53
53
  #
54
54
  #
55
- # `:performance`
55
+ # <code>:performance</code>
56
56
  # : performance hints
57
57
  # * Shape variation limit
58
58
  #