rbs 4.0.0.dev.4 → 4.0.0.dev.5

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 (223) 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 +11 -8
  5. data/.github/workflows/comments.yml +3 -3
  6. data/.github/workflows/dependabot.yml +1 -1
  7. data/.github/workflows/ruby.yml +17 -34
  8. data/.github/workflows/typecheck.yml +2 -2
  9. data/.github/workflows/valgrind.yml +42 -0
  10. data/.github/workflows/windows.yml +2 -2
  11. data/.rubocop.yml +1 -1
  12. data/README.md +1 -1
  13. data/Rakefile +32 -5
  14. data/config.yml +46 -0
  15. data/core/array.rbs +96 -46
  16. data/core/binding.rbs +0 -2
  17. data/core/builtin.rbs +2 -2
  18. data/core/comparable.rbs +13 -6
  19. data/core/complex.rbs +55 -41
  20. data/core/dir.rbs +4 -4
  21. data/core/encoding.rbs +7 -10
  22. data/core/enumerable.rbs +90 -3
  23. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  24. data/core/enumerator.rbs +63 -1
  25. data/core/errno.rbs +8 -0
  26. data/core/errors.rbs +28 -1
  27. data/core/exception.rbs +2 -2
  28. data/core/fiber.rbs +40 -20
  29. data/core/file.rbs +108 -78
  30. data/core/file_test.rbs +1 -1
  31. data/core/float.rbs +225 -69
  32. data/core/gc.rbs +417 -281
  33. data/core/hash.rbs +1023 -727
  34. data/core/integer.rbs +104 -110
  35. data/core/io/buffer.rbs +21 -10
  36. data/core/io/wait.rbs +11 -33
  37. data/core/io.rbs +82 -19
  38. data/core/kernel.rbs +70 -59
  39. data/core/marshal.rbs +1 -1
  40. data/core/match_data.rbs +1 -1
  41. data/core/math.rbs +42 -3
  42. data/core/method.rbs +63 -27
  43. data/core/module.rbs +103 -26
  44. data/core/nil_class.rbs +3 -3
  45. data/core/numeric.rbs +43 -35
  46. data/core/object.rbs +3 -3
  47. data/core/object_space.rbs +21 -15
  48. data/core/pathname.rbs +1272 -0
  49. data/core/proc.rbs +30 -25
  50. data/core/process.rbs +4 -2
  51. data/core/ractor.rbs +361 -509
  52. data/core/random.rbs +17 -0
  53. data/core/range.rbs +113 -16
  54. data/core/rational.rbs +56 -85
  55. data/core/rbs/unnamed/argf.rbs +2 -2
  56. data/core/rbs/unnamed/env_class.rbs +1 -1
  57. data/core/rbs/unnamed/random.rbs +4 -113
  58. data/core/regexp.rbs +25 -20
  59. data/core/ruby.rbs +53 -0
  60. data/core/ruby_vm.rbs +6 -4
  61. data/core/rubygems/errors.rbs +3 -70
  62. data/core/rubygems/rubygems.rbs +11 -79
  63. data/core/rubygems/version.rbs +2 -3
  64. data/core/set.rbs +488 -359
  65. data/core/signal.rbs +24 -14
  66. data/core/string.rbs +3171 -1241
  67. data/core/struct.rbs +1 -1
  68. data/core/symbol.rbs +17 -11
  69. data/core/thread.rbs +95 -33
  70. data/core/time.rbs +35 -9
  71. data/core/trace_point.rbs +7 -4
  72. data/core/unbound_method.rbs +14 -6
  73. data/docs/aliases.md +79 -0
  74. data/docs/collection.md +2 -2
  75. data/docs/encoding.md +56 -0
  76. data/docs/gem.md +0 -1
  77. data/docs/inline.md +470 -0
  78. data/docs/sigs.md +3 -3
  79. data/docs/syntax.md +33 -4
  80. data/docs/type_fingerprint.md +21 -0
  81. data/exe/rbs +1 -1
  82. data/ext/rbs_extension/ast_translation.c +77 -3
  83. data/ext/rbs_extension/ast_translation.h +3 -0
  84. data/ext/rbs_extension/class_constants.c +8 -2
  85. data/ext/rbs_extension/class_constants.h +4 -0
  86. data/ext/rbs_extension/extconf.rb +5 -1
  87. data/ext/rbs_extension/legacy_location.c +5 -5
  88. data/ext/rbs_extension/main.c +37 -20
  89. data/include/rbs/ast.h +85 -38
  90. data/include/rbs/defines.h +27 -0
  91. data/include/rbs/lexer.h +30 -11
  92. data/include/rbs/parser.h +6 -6
  93. data/include/rbs/string.h +0 -2
  94. data/include/rbs/util/rbs_allocator.h +34 -13
  95. data/include/rbs/util/rbs_assert.h +12 -1
  96. data/include/rbs/util/rbs_encoding.h +2 -0
  97. data/include/rbs/util/rbs_unescape.h +2 -1
  98. data/lib/rbs/ast/annotation.rb +1 -1
  99. data/lib/rbs/ast/comment.rb +1 -1
  100. data/lib/rbs/ast/declarations.rb +10 -10
  101. data/lib/rbs/ast/members.rb +14 -14
  102. data/lib/rbs/ast/ruby/annotations.rb +137 -0
  103. data/lib/rbs/ast/ruby/comment_block.rb +24 -0
  104. data/lib/rbs/ast/ruby/declarations.rb +198 -3
  105. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
  106. data/lib/rbs/ast/ruby/members.rb +159 -1
  107. data/lib/rbs/ast/type_param.rb +24 -4
  108. data/lib/rbs/buffer.rb +20 -15
  109. data/lib/rbs/cli/diff.rb +16 -15
  110. data/lib/rbs/cli/validate.rb +38 -51
  111. data/lib/rbs/cli.rb +52 -19
  112. data/lib/rbs/collection/config/lockfile_generator.rb +8 -0
  113. data/lib/rbs/collection/sources/git.rb +1 -0
  114. data/lib/rbs/definition.rb +1 -1
  115. data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
  116. data/lib/rbs/definition_builder/method_builder.rb +20 -0
  117. data/lib/rbs/definition_builder.rb +91 -2
  118. data/lib/rbs/diff.rb +7 -1
  119. data/lib/rbs/environment.rb +227 -74
  120. data/lib/rbs/environment_loader.rb +0 -6
  121. data/lib/rbs/errors.rb +27 -7
  122. data/lib/rbs/inline_parser.rb +341 -5
  123. data/lib/rbs/location_aux.rb +1 -1
  124. data/lib/rbs/locator.rb +5 -1
  125. data/lib/rbs/method_type.rb +5 -3
  126. data/lib/rbs/parser_aux.rb +2 -2
  127. data/lib/rbs/prototype/rb.rb +2 -2
  128. data/lib/rbs/prototype/rbi.rb +2 -0
  129. data/lib/rbs/prototype/runtime.rb +8 -0
  130. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  131. data/lib/rbs/resolver/type_name_resolver.rb +116 -38
  132. data/lib/rbs/subtractor.rb +3 -1
  133. data/lib/rbs/test/type_check.rb +16 -2
  134. data/lib/rbs/type_name.rb +1 -1
  135. data/lib/rbs/types.rb +27 -27
  136. data/lib/rbs/validator.rb +2 -2
  137. data/lib/rbs/version.rb +1 -1
  138. data/lib/rbs.rb +1 -1
  139. data/lib/rdoc/discover.rb +1 -1
  140. data/lib/rdoc_plugin/parser.rb +1 -1
  141. data/rbs.gemspec +3 -2
  142. data/schema/typeParam.json +17 -1
  143. data/sig/ast/ruby/annotations.rbs +124 -0
  144. data/sig/ast/ruby/comment_block.rbs +8 -0
  145. data/sig/ast/ruby/declarations.rbs +102 -4
  146. data/sig/ast/ruby/members.rbs +87 -1
  147. data/sig/cli/diff.rbs +5 -11
  148. data/sig/cli/validate.rbs +13 -4
  149. data/sig/cli.rbs +18 -18
  150. data/sig/definition.rbs +6 -1
  151. data/sig/environment.rbs +70 -12
  152. data/sig/errors.rbs +13 -6
  153. data/sig/inline_parser.rbs +39 -2
  154. data/sig/locator.rbs +0 -2
  155. data/sig/manifest.yaml +0 -1
  156. data/sig/method_builder.rbs +3 -1
  157. data/sig/method_types.rbs +1 -1
  158. data/sig/parser.rbs +16 -2
  159. data/sig/resolver/type_name_resolver.rbs +35 -7
  160. data/sig/source.rbs +3 -3
  161. data/sig/type_param.rbs +13 -8
  162. data/sig/types.rbs +4 -4
  163. data/src/ast.c +80 -1
  164. data/src/lexer.c +1392 -1313
  165. data/src/lexer.re +3 -0
  166. data/src/lexstate.c +58 -37
  167. data/src/location.c +4 -4
  168. data/src/parser.c +412 -145
  169. data/src/string.c +0 -48
  170. data/src/util/rbs_allocator.c +89 -71
  171. data/src/util/rbs_assert.c +1 -1
  172. data/src/util/rbs_buffer.c +2 -2
  173. data/src/util/rbs_constant_pool.c +10 -10
  174. data/src/util/rbs_encoding.c +4 -8
  175. data/src/util/rbs_unescape.c +56 -20
  176. data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
  177. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  178. data/stdlib/cgi/0/core.rbs +9 -393
  179. data/stdlib/cgi/0/manifest.yaml +1 -0
  180. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  181. data/stdlib/coverage/0/coverage.rbs +3 -1
  182. data/stdlib/date/0/date.rbs +67 -59
  183. data/stdlib/date/0/date_time.rbs +1 -1
  184. data/stdlib/delegate/0/delegator.rbs +10 -7
  185. data/stdlib/digest/0/digest.rbs +110 -0
  186. data/stdlib/erb/0/erb.rbs +737 -347
  187. data/stdlib/fileutils/0/fileutils.rbs +20 -14
  188. data/stdlib/forwardable/0/forwardable.rbs +3 -0
  189. data/stdlib/json/0/json.rbs +82 -28
  190. data/stdlib/net-http/0/net-http.rbs +3 -0
  191. data/stdlib/objspace/0/objspace.rbs +9 -27
  192. data/stdlib/open-uri/0/open-uri.rbs +40 -0
  193. data/stdlib/open3/0/open3.rbs +459 -1
  194. data/stdlib/openssl/0/openssl.rbs +331 -228
  195. data/stdlib/optparse/0/optparse.rbs +8 -3
  196. data/stdlib/pathname/0/pathname.rbs +9 -1379
  197. data/stdlib/psych/0/psych.rbs +4 -4
  198. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  199. data/stdlib/rdoc/0/code_object.rbs +2 -1
  200. data/stdlib/rdoc/0/parser.rbs +1 -1
  201. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  202. data/stdlib/rdoc/0/store.rbs +1 -1
  203. data/stdlib/resolv/0/resolv.rbs +25 -68
  204. data/stdlib/ripper/0/ripper.rbs +2 -2
  205. data/stdlib/securerandom/0/manifest.yaml +2 -0
  206. data/stdlib/securerandom/0/securerandom.rbs +6 -19
  207. data/stdlib/singleton/0/singleton.rbs +3 -0
  208. data/stdlib/socket/0/socket.rbs +13 -1
  209. data/stdlib/socket/0/tcp_socket.rbs +10 -2
  210. data/stdlib/stringio/0/stringio.rbs +1176 -85
  211. data/stdlib/strscan/0/string_scanner.rbs +31 -31
  212. data/stdlib/tempfile/0/tempfile.rbs +3 -3
  213. data/stdlib/time/0/time.rbs +1 -1
  214. data/stdlib/timeout/0/timeout.rbs +63 -7
  215. data/stdlib/tsort/0/cyclic.rbs +3 -0
  216. data/stdlib/uri/0/common.rbs +16 -2
  217. data/stdlib/uri/0/file.rbs +1 -1
  218. data/stdlib/uri/0/generic.rbs +24 -16
  219. data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
  220. data/stdlib/zlib/0/gzip_reader.rbs +2 -2
  221. data/stdlib/zlib/0/gzip_writer.rbs +1 -1
  222. data/stdlib/zlib/0/zstream.rbs +1 -0
  223. metadata +30 -4
data/core/integer.rbs CHANGED
@@ -146,9 +146,9 @@ class Integer < Numeric
146
146
 
147
147
  # <!--
148
148
  # rdoc-file=numeric.c
149
- # - self % other -> real_number
149
+ # - self % other -> real_numeric
150
150
  # -->
151
- # Returns `self` modulo `other` as a real number.
151
+ # Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
152
152
  #
153
153
  # For integer `n` and real number `r`, these expressions are equivalent:
154
154
  #
@@ -193,13 +193,13 @@ class Integer < Numeric
193
193
 
194
194
  # <!--
195
195
  # rdoc-file=numeric.c
196
- # - self * numeric -> numeric_result
196
+ # - self * other -> numeric
197
197
  # -->
198
- # Performs multiplication:
198
+ # Returns the numeric product of `self` and `other`:
199
199
  #
200
200
  # 4 * 2 # => 8
201
- # 4 * -2 # => -8
202
201
  # -4 * 2 # => -8
202
+ # 4 * -2 # => -8
203
203
  # 4 * 2.0 # => 8.0
204
204
  # 4 * Rational(1, 3) # => (4/3)
205
205
  # 4 * Complex(2, 0) # => (8+0i)
@@ -211,17 +211,47 @@ class Integer < Numeric
211
211
 
212
212
  # <!--
213
213
  # rdoc-file=numeric.c
214
- # - self ** numeric -> numeric_result
214
+ # - self ** exponent -> numeric
215
215
  # -->
216
- # Raises `self` to the power of `numeric`:
217
- #
218
- # 2 ** 3 # => 8
219
- # 2 ** -3 # => (1/8)
220
- # -2 ** 3 # => -8
221
- # -2 ** -3 # => (-1/8)
222
- # 2 ** 3.3 # => 9.849155306759329
223
- # 2 ** Rational(3, 1) # => (8/1)
224
- # 2 ** Complex(3, 0) # => (8+0i)
216
+ # Returns `self` raised to the power `exponent`:
217
+ #
218
+ # # Result for non-negative Integer exponent is Integer.
219
+ # 2 ** 0 # => 1
220
+ # 2 ** 1 # => 2
221
+ # 2 ** 2 # => 4
222
+ # 2 ** 3 # => 8
223
+ # -2 ** 3 # => -8
224
+ # # Result for negative Integer exponent is Rational, not Float.
225
+ # 2 ** -3 # => (1/8)
226
+ # -2 ** -3 # => (-1/8)
227
+ #
228
+ # # Result for Float exponent is Float.
229
+ # 2 ** 0.0 # => 1.0
230
+ # 2 ** 1.0 # => 2.0
231
+ # 2 ** 2.0 # => 4.0
232
+ # 2 ** 3.0 # => 8.0
233
+ # -2 ** 3.0 # => -8.0
234
+ # 2 ** -3.0 # => 0.125
235
+ # -2 ** -3.0 # => -0.125
236
+ #
237
+ # # Result for non-negative Complex exponent is Complex with Integer parts.
238
+ # 2 ** Complex(0, 0) # => (1+0i)
239
+ # 2 ** Complex(1, 0) # => (2+0i)
240
+ # 2 ** Complex(2, 0) # => (4+0i)
241
+ # 2 ** Complex(3, 0) # => (8+0i)
242
+ # -2 ** Complex(3, 0) # => (-8+0i)
243
+ # # Result for negative Complex exponent is Complex with Rational parts.
244
+ # 2 ** Complex(-3, 0) # => ((1/8)+(0/1)*i)
245
+ # -2 ** Complex(-3, 0) # => ((-1/8)+(0/1)*i)
246
+ #
247
+ # # Result for Rational exponent is Rational.
248
+ # 2 ** Rational(0, 1) # => (1/1)
249
+ # 2 ** Rational(1, 1) # => (2/1)
250
+ # 2 ** Rational(2, 1) # => (4/1)
251
+ # 2 ** Rational(3, 1) # => (8/1)
252
+ # -2 ** Rational(3, 1) # => (-8/1)
253
+ # 2 ** Rational(-3, 1) # => (1/8)
254
+ # -2 ** Rational(-3, 1) # => (-1/8)
225
255
  #
226
256
  def **: (Integer) -> Numeric
227
257
  | (Float) -> Numeric
@@ -230,29 +260,31 @@ class Integer < Numeric
230
260
 
231
261
  # <!--
232
262
  # rdoc-file=numeric.c
233
- # - self + numeric -> numeric_result
263
+ # - self + other -> numeric
234
264
  # -->
235
- # Performs addition:
265
+ # Returns the sum of `self` and `other`:
266
+ #
267
+ # 1 + 1 # => 2
268
+ # 1 + -1 # => 0
269
+ # 1 + 0 # => 1
270
+ # 1 + -2 # => -1
271
+ # 1 + Complex(1, 0) # => (2+0i)
272
+ # 1 + Rational(1, 1) # => (2/1)
273
+ #
274
+ # For a computation involving Floats, the result may be inexact (see Float#+):
236
275
  #
237
- # 2 + 2 # => 4
238
- # -2 + 2 # => 0
239
- # -2 + -2 # => -4
240
- # 2 + 2.0 # => 4.0
241
- # 2 + Rational(2, 1) # => (4/1)
242
- # 2 + Complex(2, 0) # => (4+0i)
276
+ # 1 + 3.14 # => 4.140000000000001
243
277
  #
244
278
  def +: (Integer) -> Integer
245
279
  | (Float) -> Float
246
280
  | (Rational) -> Rational
247
281
  | (Complex) -> Complex
248
282
 
249
- def +@: () -> Integer
250
-
251
283
  # <!--
252
284
  # rdoc-file=numeric.c
253
- # - self - numeric -> numeric_result
285
+ # - self - other -> numeric
254
286
  # -->
255
- # Performs subtraction:
287
+ # Returns the difference of `self` and `other`:
256
288
  #
257
289
  # 4 - 2 # => 2
258
290
  # -4 - 2 # => -6
@@ -268,28 +300,34 @@ class Integer < Numeric
268
300
 
269
301
  # <!--
270
302
  # rdoc-file=numeric.rb
271
- # - -int -> integer
303
+ # - -self -> integer
272
304
  # -->
273
- # Returns `self`, negated.
305
+ # Returns `self`, negated:
306
+ #
307
+ # -1 # => -1
308
+ # -(-1) # => 1
309
+ # -0 # => 0
274
310
  #
275
311
  def -@: () -> Integer
276
312
 
277
313
  # <!--
278
314
  # rdoc-file=numeric.c
279
- # - self / numeric -> numeric_result
315
+ # - self / other -> numeric
280
316
  # -->
281
- # Performs division; for integer `numeric`, truncates the result to an integer:
317
+ # Returns the quotient of `self` and `other`.
318
+ #
319
+ # For integer `other`, truncates the result to an integer:
282
320
  #
283
- # 4 / 3 # => 1
284
- # 4 / -3 # => -2
285
- # -4 / 3 # => -2
286
- # -4 / -3 # => 1
321
+ # 4 / 3 # => 1
322
+ # 4 / -3 # => -2
323
+ # -4 / 3 # => -2
324
+ # -4 / -3 # => 1
287
325
  #
288
- # For other +numeric+, returns non-integer result:
326
+ # For non-integer `other`, returns a non-integer result:
289
327
  #
290
- # 4 / 3.0 # => 1.3333333333333333
291
- # 4 / Rational(3, 1) # => (4/3)
292
- # 4 / Complex(3, 0) # => ((4/3)+0i)
328
+ # 4 / 3.0 # => 1.3333333333333333
329
+ # 4 / Rational(3, 1) # => (4/3)
330
+ # 4 / Complex(3, 0) # => ((4/3)+0i)
293
331
  #
294
332
  def /: (Integer) -> Integer
295
333
  | (Float) -> Float
@@ -300,15 +338,14 @@ class Integer < Numeric
300
338
  # rdoc-file=numeric.c
301
339
  # - self < other -> true or false
302
340
  # -->
303
- # Returns `true` if the value of `self` is less than that of `other`:
341
+ # Returns whether the value of `self` is less than the value of `other`; `other`
342
+ # must be numeric, but may not be Complex:
304
343
  #
305
- # 1 < 0 # => false
306
- # 1 < 1 # => false
307
- # 1 < 2 # => true
308
- # 1 < 0.5 # => false
309
- # 1 < Rational(1, 2) # => false
310
- #
311
- # Raises an exception if the comparison cannot be made.
344
+ # 1 < 0 # => false
345
+ # 1 < 1 # => false
346
+ # 1 < 2 # => true
347
+ # 1 < 0.5 # => false
348
+ # 1 < Rational(1, 2) # => false
312
349
  #
313
350
  def <: (Numeric) -> bool
314
351
 
@@ -331,44 +368,46 @@ class Integer < Numeric
331
368
 
332
369
  # <!--
333
370
  # rdoc-file=numeric.c
334
- # - self <= real -> true or false
371
+ # - self <= other -> true or false
335
372
  # -->
336
- # Returns `true` if the value of `self` is less than or equal to that of
337
- # `other`:
373
+ # Returns whether the value of `self` is less than or equal to the value of
374
+ # `other`; `other` must be numeric, but may not be Complex:
338
375
  #
339
- # 1 <= 0 # => false
340
- # 1 <= 1 # => true
341
- # 1 <= 2 # => true
342
- # 1 <= 0.5 # => false
343
- # 1 <= Rational(1, 2) # => false
376
+ # 1 <= 0 # => false
377
+ # 1 <= 1 # => true
378
+ # 1 <= 2 # => true
379
+ # 1 <= 0.5 # => false
380
+ # 1 <= Rational(1, 2) # => false
344
381
  #
345
- # Raises an exception if the comparison cannot be made.
382
+ # Raises an exception if the comparison cannot be made.
346
383
  #
347
384
  def <=: (Numeric) -> bool
348
385
 
349
386
  # <!--
350
387
  # rdoc-file=numeric.c
351
- # - self <=> other -> -1, 0, +1, or nil
388
+ # - self <=> other -> -1, 0, 1, or nil
352
389
  # -->
390
+ # Compares `self` and `other`.
391
+ #
353
392
  # Returns:
354
393
  #
355
- # * -1, if `self` is less than `other`.
356
- # * 0, if `self` is equal to `other`.
357
- # * 1, if `self` is greater then `other`.
394
+ # * `-1`, if `self` is less than `other`.
395
+ # * `0`, if `self` is equal to `other`.
396
+ # * `1`, if `self` is greater then `other`.
358
397
  # * `nil`, if `self` and `other` are incomparable.
359
398
  #
360
399
  # Examples:
361
400
  #
362
401
  # 1 <=> 2 # => -1
363
402
  # 1 <=> 1 # => 0
364
- # 1 <=> 0 # => 1
365
- # 1 <=> 'foo' # => nil
366
- #
367
403
  # 1 <=> 1.0 # => 0
368
404
  # 1 <=> Rational(1, 1) # => 0
369
405
  # 1 <=> Complex(1, 0) # => 0
406
+ # 1 <=> 0 # => 1
407
+ # 1 <=> 'foo' # => nil
370
408
  #
371
- # This method is the basis for comparisons in module Comparable.
409
+ # Class Integer includes module Comparable, each of whose methods uses
410
+ # Integer#<=> for comparison.
372
411
  #
373
412
  def <=>: (Integer | Rational) -> Integer
374
413
  | (untyped) -> Integer?
@@ -515,8 +554,6 @@ class Integer < Numeric
515
554
  #
516
555
  def abs: () -> Integer
517
556
 
518
- def abs2: () -> Integer
519
-
520
557
  # <!--
521
558
  # rdoc-file=numeric.c
522
559
  # - allbits?(mask) -> true or false
@@ -540,8 +577,6 @@ class Integer < Numeric
540
577
  #
541
578
  def allbits?: (int mask) -> bool
542
579
 
543
- def angle: () -> (Integer | Float)
544
-
545
580
  # <!--
546
581
  # rdoc-file=numeric.c
547
582
  # - anybits?(mask) -> true or false
@@ -706,10 +741,6 @@ class Integer < Numeric
706
741
  #
707
742
  def coerce: (Numeric) -> [ Numeric, Numeric ]
708
743
 
709
- def conj: () -> Integer
710
-
711
- def conjugate: () -> Integer
712
-
713
744
  # <!--
714
745
  # rdoc-file=numeric.rb
715
746
  # - denominator -> 1
@@ -801,10 +832,6 @@ class Integer < Numeric
801
832
  def downto: (Numeric limit) { (Integer) -> void } -> Integer
802
833
  | (Numeric limit) -> ::Enumerator[Integer, self]
803
834
 
804
- def dup: () -> self
805
-
806
- def eql?: (untyped) -> bool
807
-
808
835
  # <!--
809
836
  # rdoc-file=numeric.rb
810
837
  # - even? -> true or false
@@ -829,8 +856,6 @@ class Integer < Numeric
829
856
  #
830
857
  def fdiv: (Numeric) -> Float
831
858
 
832
- def finite?: () -> bool
833
-
834
859
  # <!--
835
860
  # rdoc-file=numeric.c
836
861
  # - floor(ndigits = 0) -> integer
@@ -901,14 +926,6 @@ class Integer < Numeric
901
926
  #
902
927
  def gcdlcm: (Integer) -> [ Integer, Integer ]
903
928
 
904
- def i: () -> Complex
905
-
906
- def imag: () -> Integer
907
-
908
- def imaginary: () -> Integer
909
-
910
- def infinite?: () -> Integer?
911
-
912
929
  # <!-- rdoc-file=numeric.c -->
913
930
  # Returns a string containing the place-value representation of `self` in radix
914
931
  # `base` (in 2..36).
@@ -955,7 +972,7 @@ class Integer < Numeric
955
972
  def magnitude: () -> Integer
956
973
 
957
974
  # <!-- rdoc-file=numeric.c -->
958
- # Returns `self` modulo `other` as a real number.
975
+ # Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
959
976
  #
960
977
  # For integer `n` and real number `r`, these expressions are equivalent:
961
978
  #
@@ -1015,8 +1032,6 @@ class Integer < Numeric
1015
1032
  #
1016
1033
  def nobits?: (int mask) -> bool
1017
1034
 
1018
- def nonzero?: () -> self?
1019
-
1020
1035
  # <!--
1021
1036
  # rdoc-file=numeric.rb
1022
1037
  # - numerator -> self
@@ -1041,8 +1056,6 @@ class Integer < Numeric
1041
1056
  #
1042
1057
  def ord: () -> Integer
1043
1058
 
1044
- alias phase angle
1045
-
1046
1059
  def polar: () -> [ Integer, Integer | Float ]
1047
1060
 
1048
1061
  def positive?: () -> bool
@@ -1091,14 +1104,8 @@ class Integer < Numeric
1091
1104
  #
1092
1105
  def rationalize: (?Numeric eps) -> Rational
1093
1106
 
1094
- def real: () -> self
1095
-
1096
- def real?: () -> true
1097
-
1098
1107
  def rect: () -> [ Integer, Numeric ]
1099
1108
 
1100
- alias rectangular rect
1101
-
1102
1109
  # <!--
1103
1110
  # rdoc-file=numeric.c
1104
1111
  # - remainder(other) -> real_number
@@ -1189,17 +1196,6 @@ class Integer < Numeric
1189
1196
  #
1190
1197
  def size: () -> Integer
1191
1198
 
1192
- def step: () { (Integer) -> void } -> void
1193
- | (Numeric limit, ?Integer step) { (Integer) -> void } -> void
1194
- | (Numeric limit, ?Numeric step) { (Numeric) -> void } -> void
1195
- | (to: Numeric, ?by: Integer) { (Integer) -> void } -> void
1196
- | (by: Numeric, ?to: Numeric) { (Numeric) -> void } -> void
1197
- | () -> Enumerator[Integer, bot]
1198
- | (Numeric limit, ?Integer step) -> Enumerator[Integer]
1199
- | (Numeric limit, ?Numeric step) -> Enumerator[Numeric]
1200
- | (to: Numeric, ?by: Integer) -> Enumerator[Integer]
1201
- | (by: Numeric, ?to: Numeric) -> Enumerator[Numeric]
1202
-
1203
1199
  # <!--
1204
1200
  # rdoc-file=numeric.c
1205
1201
  # - succ -> next_integer
@@ -1229,8 +1225,6 @@ class Integer < Numeric
1229
1225
  def times: () { (Integer) -> void } -> self
1230
1226
  | () -> ::Enumerator[Integer, self]
1231
1227
 
1232
- def to_c: () -> Complex
1233
-
1234
1228
  # <!--
1235
1229
  # rdoc-file=numeric.c
1236
1230
  # - to_f -> float
data/core/io/buffer.rbs CHANGED
@@ -64,9 +64,9 @@ class IO
64
64
  #
65
65
  # File.write('test.txt', 'test data')
66
66
  # # => 9
67
- # buffer = IO::Buffer.map(File.open('test.txt'))
67
+ # buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY)
68
68
  # # =>
69
- # # #<IO::Buffer 0x00007f3f0768c000+9 MAPPED IMMUTABLE>
69
+ # # #<IO::Buffer 0x00007f3f0768c000+9 EXTERNAL MAPPED FILE SHARED READONLY>
70
70
  # # ...
71
71
  # buffer.get_string(5, 2) # read 2 bytes, starting from offset 5
72
72
  # # => "da"
@@ -113,7 +113,7 @@ class IO
113
113
  # buffer.get_string(0, 1)
114
114
  # # => "t"
115
115
  # string
116
- # # => "best"
116
+ # # => "test"
117
117
  #
118
118
  # buffer.resize(100)
119
119
  # # in `resize': Cannot resize external buffer! (IO::Buffer::AccessError)
@@ -131,18 +131,25 @@ class IO
131
131
  # - IO::Buffer.map(file, [size, [offset, [flags]]]) -> io_buffer
132
132
  # -->
133
133
  # Create an IO::Buffer for reading from `file` by memory-mapping the file.
134
- # `file_io` should be a `File` instance, opened for reading.
134
+ # `file` should be a `File` instance, opened for reading or reading and writing.
135
+ #
136
+ # Optional `size` and `offset` of mapping can be specified. Trying to map an
137
+ # empty file or specify `size` of 0 will raise an error. Valid values for
138
+ # `offset` are system-dependent.
135
139
  #
136
- # Optional `size` and `offset` of mapping can be specified.
140
+ # By default, the buffer is writable and expects the file to be writable. It is
141
+ # also shared, so several processes can use the same mapping.
137
142
  #
138
- # By default, the buffer would be immutable (read only); to create a writable
139
- # mapping, you need to open a file in read-write mode, and explicitly pass
140
- # `flags` argument without IO::Buffer::IMMUTABLE.
143
+ # You can pass IO::Buffer::READONLY in `flags` argument to make a read-only
144
+ # buffer; this allows to work with files opened only for reading. Specifying
145
+ # IO::Buffer::PRIVATE in `flags` creates a private mapping, which will not
146
+ # impact other processes or the underlying file. It also allows updating a
147
+ # buffer created from a read-only file.
141
148
  #
142
149
  # File.write('test.txt', 'test')
143
150
  #
144
151
  # buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY)
145
- # # => #<IO::Buffer 0x00000001014a0000+4 MAPPED READONLY>
152
+ # # => #<IO::Buffer 0x00000001014a0000+4 EXTERNAL MAPPED FILE SHARED READONLY>
146
153
  #
147
154
  # buffer.readonly? # => true
148
155
  #
@@ -150,7 +157,7 @@ class IO
150
157
  # # => "test"
151
158
  #
152
159
  # buffer.set_string('b', 0)
153
- # # `set_string': Buffer is not writable! (IO::Buffer::AccessError)
160
+ # # 'IO::Buffer#set_string': Buffer is not writable! (IO::Buffer::AccessError)
154
161
  #
155
162
  # # create read/write mapping: length 4 bytes, offset 0, flags 0
156
163
  # buffer = IO::Buffer.map(File.open('test.txt', 'r+'), 4, 0)
@@ -382,6 +389,10 @@ class IO
382
389
  # * `:U64`: unsigned integer, 8 bytes, big-endian
383
390
  # * `:s64`: signed integer, 8 bytes, little-endian
384
391
  # * `:S64`: signed integer, 8 bytes, big-endian
392
+ # * `:u128`: unsigned integer, 16 bytes, little-endian
393
+ # * `:U128`: unsigned integer, 16 bytes, big-endian
394
+ # * `:s128`: signed integer, 16 bytes, little-endian
395
+ # * `:S128`: signed integer, 16 bytes, big-endian
385
396
  # * `:f32`: float, 4 bytes, little-endian
386
397
  # * `:F32`: float, 4 bytes, big-endian
387
398
  # * `:f64`: double, 8 bytes, little-endian
data/core/io/wait.rbs CHANGED
@@ -1,30 +1,9 @@
1
1
  %a{annotate:rdoc:skip}
2
2
  class IO
3
3
  # <!--
4
- # rdoc-file=ext/io/wait/wait.c
5
- # - io.nread -> int
6
- # -->
7
- # Returns number of bytes that can be read without blocking. Returns zero if no
8
- # information available.
9
- #
10
- # You must require 'io/wait' to use this method.
11
- #
12
- def nread: () -> Integer
13
-
14
- # <!--
15
- # rdoc-file=ext/io/wait/wait.c
16
- # - io.ready? -> truthy or falsy
17
- # -->
18
- # Returns a truthy value if input available without blocking, or a falsy value.
19
- #
20
- # You must require 'io/wait' to use this method.
21
- #
22
- def ready?: () -> boolish
23
-
24
- # <!--
25
- # rdoc-file=ext/io/wait/wait.c
4
+ # rdoc-file=io.c
26
5
  # - io.wait(events, timeout) -> event mask, false or nil
27
- # - io.wait(timeout = nil, mode = :read) -> self, true, or false
6
+ # - io.wait(*event_symbols[, timeout]) -> self, true, or false
28
7
  # -->
29
8
  # Waits until the IO becomes ready for the specified events and returns the
30
9
  # subset of events that become ready, or a falsy value when times out.
@@ -32,11 +11,14 @@ class IO
32
11
  # The events can be a bit mask of `IO::READABLE`, `IO::WRITABLE` or
33
12
  # `IO::PRIORITY`.
34
13
  #
35
- # Returns a truthy value immediately when buffered data is available.
36
- #
37
- # Optional parameter `mode` is one of `:read`, `:write`, or `:read_write`.
14
+ # Returns an event mask (truthy value) immediately when buffered data is
15
+ # available.
38
16
  #
39
- # You must require 'io/wait' to use this method.
17
+ # The second form: if one or more event symbols (`:read`, `:write`, or
18
+ # `:read_write`) are passed, the event mask is the bit OR of the bitmask
19
+ # corresponding to those symbols. In this form, `timeout` is optional, the
20
+ # order of the arguments is arbitrary, and returns `io` if any of the events is
21
+ # ready.
40
22
  #
41
23
  def wait: (Integer events, ?Time::_Timeout timeout) -> (Integer | false | nil)
42
24
  | (?Time::_Timeout? timeout, *wait_mode mode) -> (self | true | false)
@@ -44,7 +26,7 @@ class IO
44
26
  type wait_mode = :read | :r | :readable | :write | :w | :writable | :read_write | :rw | :readable_writable
45
27
 
46
28
  # <!--
47
- # rdoc-file=ext/io/wait/wait.c
29
+ # rdoc-file=io.c
48
30
  # - io.wait_readable -> truthy or falsy
49
31
  # - io.wait_readable(timeout) -> truthy or falsy
50
32
  # -->
@@ -52,19 +34,15 @@ class IO
52
34
  # times out. Returns a truthy value immediately when buffered data is
53
35
  # available.
54
36
  #
55
- # You must require 'io/wait' to use this method.
56
- #
57
37
  def wait_readable: (?Time::_Timeout? timeout) -> boolish
58
38
 
59
39
  # <!--
60
- # rdoc-file=ext/io/wait/wait.c
40
+ # rdoc-file=io.c
61
41
  # - io.wait_writable -> truthy or falsy
62
42
  # - io.wait_writable(timeout) -> truthy or falsy
63
43
  # -->
64
44
  # Waits until IO is writable and returns a truthy value or a falsy value when
65
45
  # times out.
66
46
  #
67
- # You must require 'io/wait' to use this method.
68
- #
69
47
  def wait_writable: (?Time::_Timeout? timeout) -> boolish
70
48
  end