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/marshal.rbs CHANGED
@@ -147,7 +147,7 @@ module Marshal
147
147
  # * anonymous Class/Module.
148
148
  # * objects which are related to system (ex: Dir, File::Stat, IO, File, Socket
149
149
  # and so on)
150
- # * an instance of MatchData, Data, Method, UnboundMethod, Proc, Thread,
150
+ # * an instance of MatchData, Method, UnboundMethod, Proc, Thread,
151
151
  # ThreadGroup, Continuation
152
152
  # * objects which define singleton methods
153
153
  #
@@ -167,9 +167,9 @@ module Marshal
167
167
  # Never pass untrusted data (including user supplied input) to this method.
168
168
  # Please see the overview for further details.
169
169
  #
170
- # If the `freeze: true` argument is passed, deserialized object would be deeply
171
- # frozen. Note that it may lead to more efficient memory usage due to frozen
172
- # strings deduplication:
170
+ # If the <code>freeze: true</code> argument is passed, deserialized object would
171
+ # be deeply frozen. Note that it may lead to more efficient memory usage due to
172
+ # frozen strings deduplication:
173
173
  #
174
174
  # serialized = Marshal.dump(['value1', 'value2', 'value1', 'value2'])
175
175
  #
data/core/match_data.rbs CHANGED
@@ -34,14 +34,16 @@
34
34
  # Parts of last MatchData (returned by Regexp.last_match) are also aliased as
35
35
  # global variables:
36
36
  #
37
- # * `$~` is Regexp.last_match;
38
- # * `$&` is Regexp.last_match`[ 0 ]`;
39
- # * `$1`, `$2`, and so on are Regexp.last_match`[ i ]` (captures by number);
40
- # * `$`` is Regexp.last_match`.pre_match`;
41
- # * `$'` is Regexp.last_match`.post_match`;
42
- # * `$+` is Regexp.last_match`[ -1 ]` (the last capture).
37
+ # * <code>$~</code> is Regexp.last_match;
38
+ # * <code>$&</code> is Regexp.last_match<code>[ 0 ]</code>;
39
+ # * <code>$1</code>, <code>$2</code>, and so on are Regexp.last_match<code>[ i
40
+ # ]</code> (captures by number);
41
+ # * <code>$`</code> is Regexp.last_match<code>.pre_match</code>;
42
+ # * <code>$'</code> is Regexp.last_match<code>.post_match</code>;
43
+ # * <code>$+</code> is Regexp.last_match<code>[ -1 ]</code> (the last
44
+ # capture).
43
45
  #
44
- # See also "Special global variables" section in Regexp documentation.
46
+ # See also Regexp@Global+Variables.
45
47
  #
46
48
  class MatchData
47
49
  type capture = String | Symbol | int
@@ -230,7 +232,7 @@ class MatchData
230
232
  # rdoc-file=re.c
231
233
  # - captures -> array
232
234
  # -->
233
- # Returns the array of captures, which are all matches except `m[0]`:
235
+ # Returns the array of captures, which are all matches except <code>m[0]</code>:
234
236
  #
235
237
  # m = /(.)(.)(\d+)(\d)/.match("THX1138.")
236
238
  # # => #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
@@ -242,7 +244,7 @@ class MatchData
242
244
  def captures: () -> Array[String?]
243
245
 
244
246
  # <!-- rdoc-file=re.c -->
245
- # Returns the array of captures, which are all matches except `m[0]`:
247
+ # Returns the array of captures, which are all matches except <code>m[0]</code>:
246
248
  #
247
249
  # m = /(.)(.)(\d+)(\d)/.match("THX1138.")
248
250
  # # => #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
@@ -511,8 +513,8 @@ class MatchData
511
513
  # - post_match -> str
512
514
  # -->
513
515
  # Returns the substring of the target string from the end of the first match in
514
- # `self` (that is, `self[0]`) to the end of the string; equivalent to regexp
515
- # global variable `$'`:
516
+ # `self` (that is, <code>self[0]</code>) to the end of the string; equivalent to
517
+ # regexp global variable <code>$'</code>:
516
518
  #
517
519
  # m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
518
520
  # # => #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
@@ -528,8 +530,8 @@ class MatchData
528
530
  # - pre_match -> string
529
531
  # -->
530
532
  # Returns the substring of the target string from its beginning up to the first
531
- # match in `self` (that is, `self[0]`); equivalent to regexp global variable
532
- # `$``:
533
+ # match in `self` (that is, <code>self[0]</code>); equivalent to regexp global
534
+ # variable <code>$`</code>:
533
535
  #
534
536
  # m = /(.)(.)(\d+)(\d)/.match("THX1138.")
535
537
  # # => #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
data/core/math.rbs CHANGED
@@ -41,8 +41,8 @@
41
41
  # because many such values are, in mathematics, of infinite precision, while in
42
42
  # numerical computation the precision is finite.
43
43
  #
44
- # Thus, in mathematics, *cos(π/2)* is exactly zero, but in our computation
45
- # `cos(PI/2)` is a number very close to zero:
44
+ # Thus, in mathematics, <em>cos(π/2)</em> is exactly zero, but in our
45
+ # computation <code>cos(PI/2)</code> is a number very close to zero:
46
46
  #
47
47
  # cos(PI/2) # => 6.123031769111886e-17
48
48
  #
@@ -114,7 +114,7 @@
114
114
  #
115
115
  # #### Hypotenuse Function
116
116
  #
117
- # * ::hypot: Returns `sqrt(a**2 + b**2)` for the given `a` and `b`.
117
+ # * ::hypot: Returns <code>sqrt(a**2 + b**2)</code> for the given `a` and `b`.
118
118
  #
119
119
  module Math
120
120
  # <!-- rdoc-file=math.c -->
@@ -137,7 +137,7 @@ module Math
137
137
  #
138
138
  # Math.acos(42)
139
139
  #
140
- # *produces:*
140
+ # <em>produces:</em>
141
141
  #
142
142
  # Math::DomainError: Numerical argument is out of domain - "acos"
143
143
  #
@@ -155,8 +155,8 @@ module Math
155
155
  # Returns the [arc
156
156
  # cosine](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions) of `x`.
157
157
  #
158
- # * Domain: `[-1, 1]`.
159
- # * Range: `[0, PI]`.
158
+ # * Domain: <code>[-1, 1]</code>.
159
+ # * Range: <code>[0, PI]</code>.
160
160
  #
161
161
  # Examples:
162
162
  #
@@ -173,8 +173,8 @@ module Math
173
173
  # Returns the [inverse hyperbolic
174
174
  # cosine](https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions) of `x`.
175
175
  #
176
- # * Domain: `[1, INFINITY]`.
177
- # * Range: `[0, INFINITY]`.
176
+ # * Domain: <code>[1, INFINITY]</code>.
177
+ # * Range: <code>[0, INFINITY]</code>.
178
178
  #
179
179
  # Examples:
180
180
  #
@@ -190,8 +190,8 @@ module Math
190
190
  # Returns the [arc
191
191
  # sine](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions) of `x`.
192
192
  #
193
- # * Domain: `[-1, -1]`.
194
- # * Range: `[-PI/2, PI/2]`.
193
+ # * Domain: <code>[-1, -1]</code>.
194
+ # * Range: <code>[-PI/2, PI/2]</code>.
195
195
  #
196
196
  # Examples:
197
197
  #
@@ -208,8 +208,8 @@ module Math
208
208
  # Returns the [inverse hyperbolic
209
209
  # sine](https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions) of `x`.
210
210
  #
211
- # * Domain: `[-INFINITY, INFINITY]`.
212
- # * Range: `[-INFINITY, INFINITY]`.
211
+ # * Domain: <code>[-INFINITY, INFINITY]</code>.
212
+ # * Range: <code>[-INFINITY, INFINITY]</code>.
213
213
  #
214
214
  # Examples:
215
215
  #
@@ -227,8 +227,8 @@ module Math
227
227
  # tangent](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions) of
228
228
  # `x`.
229
229
  #
230
- # * Domain: `[-INFINITY, INFINITY]`.
231
- # * Range: `[-PI/2, PI/2] `.
230
+ # * Domain: <code>[-INFINITY, INFINITY]</code>.
231
+ # * Range: <code>[-PI/2, PI/2] </code>.
232
232
  #
233
233
  # Examples:
234
234
  #
@@ -251,9 +251,9 @@ module Math
251
251
  # [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
252
252
  # _degrees).
253
253
  #
254
- # * Domain of `y`: `[-INFINITY, INFINITY]`.
255
- # * Domain of `x`: `[-INFINITY, INFINITY]`.
256
- # * Range: `[-PI, PI]`.
254
+ # * Domain of `y`: <code>[-INFINITY, INFINITY]</code>.
255
+ # * Domain of `x`: <code>[-INFINITY, INFINITY]</code>.
256
+ # * Range: <code>[-PI, PI]</code>.
257
257
  #
258
258
  # Examples:
259
259
  #
@@ -271,8 +271,8 @@ module Math
271
271
  # Returns the [inverse hyperbolic
272
272
  # tangent](https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions) of `x`.
273
273
  #
274
- # * Domain: `[-1, 1]`.
275
- # * Range: `[-INFINITY, INFINITY]`.
274
+ # * Domain: <code>[-1, 1]</code>.
275
+ # * Range: <code>[-INFINITY, INFINITY]</code>.
276
276
  #
277
277
  # Examples:
278
278
  #
@@ -288,8 +288,8 @@ module Math
288
288
  # -->
289
289
  # Returns the [cube root](https://en.wikipedia.org/wiki/Cube_root) of `x`.
290
290
  #
291
- # * Domain: `[-INFINITY, INFINITY]`.
292
- # * Range: `[-INFINITY, INFINITY]`.
291
+ # * Domain: <code>[-INFINITY, INFINITY]</code>.
292
+ # * Range: <code>[-INFINITY, INFINITY]</code>.
293
293
  #
294
294
  # Examples:
295
295
  #
@@ -315,8 +315,8 @@ module Math
315
315
  # [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
316
316
  # _degrees).
317
317
  #
318
- # * Domain: `(-INFINITY, INFINITY)`.
319
- # * Range: `[-1.0, 1.0]`.
318
+ # * Domain: <code>(-INFINITY, INFINITY)</code>.
319
+ # * Range: <code>[-1.0, 1.0]</code>.
320
320
  #
321
321
  # Examples:
322
322
  #
@@ -337,8 +337,8 @@ module Math
337
337
  # [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
338
338
  # _degrees).
339
339
  #
340
- # * Domain: `[-INFINITY, INFINITY]`.
341
- # * Range: `[1, INFINITY]`.
340
+ # * Domain: <code>[-INFINITY, INFINITY]</code>.
341
+ # * Range: <code>[1, INFINITY]</code>.
342
342
  #
343
343
  # Examples:
344
344
  #
@@ -355,8 +355,8 @@ module Math
355
355
  # Returns the value of the [Gauss error
356
356
  # function](https://en.wikipedia.org/wiki/Error_function) for `x`.
357
357
  #
358
- # * Domain: `[-INFINITY, INFINITY]`.
359
- # * Range: `[-1, 1]`.
358
+ # * Domain: <code>[-INFINITY, INFINITY]</code>.
359
+ # * Range: <code>[-1, 1]</code>.
360
360
  #
361
361
  # Examples:
362
362
  #
@@ -376,8 +376,8 @@ module Math
376
376
  # function](https://en.wikipedia.org/wiki/Error_function#Complementary_error_fun
377
377
  # ction) for `x`.
378
378
  #
379
- # * Domain: `[-INFINITY, INFINITY]`.
380
- # * Range: `[0, 2]`.
379
+ # * Domain: <code>[-INFINITY, INFINITY]</code>.
380
+ # * Range: <code>[0, 2]</code>.
381
381
  #
382
382
  # Examples:
383
383
  #
@@ -395,8 +395,8 @@ module Math
395
395
  # -->
396
396
  # Returns `e` raised to the `x` power.
397
397
  #
398
- # * Domain: `[-INFINITY, INFINITY]`.
399
- # * Range: `[0, INFINITY]`.
398
+ # * Domain: <code>[-INFINITY, INFINITY]</code>.
399
+ # * Range: <code>[0, INFINITY]</code>.
400
400
  #
401
401
  # Examples:
402
402
  #
@@ -410,6 +410,27 @@ module Math
410
410
  #
411
411
  def self.exp: (double x) -> Float
412
412
 
413
+ # <!--
414
+ # rdoc-file=math.c
415
+ # - Math.expm1(x) -> float
416
+ # -->
417
+ # Returns "exp(x) - 1", `e` raised to the `x` power, minus 1.
418
+ #
419
+ # * Domain: <code>[-INFINITY, INFINITY]</code>.
420
+ # * Range: <code>[-1.0, INFINITY]</code>.
421
+ #
422
+ # Examples:
423
+ #
424
+ # expm1(-INFINITY) # => 0.0
425
+ # expm1(-1.0) # => -0.6321205588285577 # 1.0/E - 1
426
+ # expm1(0.0) # => 0.0
427
+ # expm1(0.5) # => 0.6487212707001282 # sqrt(E) - 1
428
+ # expm1(1.0) # => 1.718281828459045 # E - 1
429
+ # expm1(2.0) # => 6.38905609893065 # E**2 - 1
430
+ # expm1(INFINITY) # => Infinity
431
+ #
432
+ def self.expm1: (double x) -> Float
433
+
413
434
  # <!--
414
435
  # rdoc-file=math.c
415
436
  # - Math.frexp(x) -> [fraction, exponent]
@@ -423,8 +444,8 @@ module Math
423
444
  # binary64](https://en.wikipedia.org/wiki/Double-precision_floating-point_format
424
445
  # #IEEE_754_double-precision_binary_floating-point_format:_binary64).
425
446
  #
426
- # * Domain: `[-INFINITY, INFINITY]`.
427
- # * Range `[-INFINITY, INFINITY]`.
447
+ # * Domain: <code>[-INFINITY, INFINITY]</code>.
448
+ # * Range <code>[-INFINITY, INFINITY]</code>.
428
449
  #
429
450
  # Examples:
430
451
  #
@@ -447,8 +468,8 @@ module Math
447
468
  # Returns the value of the [gamma
448
469
  # function](https://en.wikipedia.org/wiki/Gamma_function) for `x`.
449
470
  #
450
- # * Domain: `(-INFINITY, INFINITY]` excluding negative integers.
451
- # * Range: `[-INFINITY, INFINITY]`.
471
+ # * Domain: <code>(-INFINITY, INFINITY]</code> excluding negative integers.
472
+ # * Range: <code>[-INFINITY, INFINITY]</code>.
452
473
  #
453
474
  # Examples:
454
475
  #
@@ -470,12 +491,13 @@ module Math
470
491
  # rdoc-file=math.c
471
492
  # - Math.hypot(a, b) -> float
472
493
  # -->
473
- # Returns `sqrt(a**2 + b**2)`, which is the length of the longest side `c` (the
474
- # hypotenuse) of the right triangle whose other sides have lengths `a` and `b`.
494
+ # Returns <code>sqrt(a**2 + b**2)</code>, which is the length of the longest
495
+ # side `c` (the hypotenuse) of the right triangle whose other sides have lengths
496
+ # `a` and `b`.
475
497
  #
476
- # * Domain of `a`: `[-INFINITY, INFINITY]`.
477
- # * Domain of +ab: `[-INFINITY, INFINITY]`.
478
- # * Range: `[0, INFINITY]`.
498
+ # * Domain of `a`: <code>[-INFINITY, INFINITY]</code>.
499
+ # * Domain of +ab: <code>[-INFINITY, INFINITY]</code>.
500
+ # * Range: <code>[0, INFINITY]</code>.
479
501
  #
480
502
  # Examples:
481
503
  #
@@ -485,8 +507,8 @@ module Math
485
507
  # hypot(5.0, 12.0) # => 13.0
486
508
  # hypot(1.0, sqrt(3.0)) # => 1.9999999999999998 # Near 2.0
487
509
  #
488
- # Note that if either argument is `INFINITY` or `-INFINITY`, the result is
489
- # `Infinity`.
510
+ # Note that if either argument is `INFINITY` or <code>-INFINITY</code>, the
511
+ # result is `Infinity`.
490
512
  #
491
513
  def self.hypot: (double x, double y) -> Float
492
514
 
@@ -494,10 +516,11 @@ module Math
494
516
  # rdoc-file=math.c
495
517
  # - Math.ldexp(fraction, exponent) -> float
496
518
  # -->
497
- # Returns the value of `fraction * 2**exponent`.
519
+ # Returns the value of <code>fraction * 2**exponent</code>.
498
520
  #
499
- # * Domain of `fraction`: `[0.0, 1.0)`.
500
- # * Domain of `exponent`: `[0, 1024]` (larger values are equivalent to 1024).
521
+ # * Domain of `fraction`: <code>[0.0, 1.0)</code>.
522
+ # * Domain of `exponent`: <code>[0, 1024]</code> (larger values are equivalent
523
+ # to 1024).
501
524
  #
502
525
  # See [IEEE 754 double-precision binary floating-point format:
503
526
  # binary64](https://en.wikipedia.org/wiki/Double-precision_floating-point_format
@@ -525,12 +548,11 @@ module Math
525
548
  #
526
549
  # [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1]
527
550
  #
528
- # See [logarithmic gamma
529
- # function](https://en.wikipedia.org/wiki/Gamma_function#The_log-gamma_function)
530
- # .
551
+ # See [log gamma
552
+ # function](https://en.wikipedia.org/wiki/Gamma_function#Log-gamma_function).
531
553
  #
532
- # * Domain: `(-INFINITY, INFINITY]`.
533
- # * Range of first element: `(-INFINITY, INFINITY]`.
554
+ # * Domain: <code>(-INFINITY, INFINITY]</code>.
555
+ # * Range of first element: <code>(-INFINITY, INFINITY]</code>.
534
556
  # * Second element is -1 or 1.
535
557
  #
536
558
  # Examples:
@@ -564,8 +586,8 @@ module Math
564
586
  # Returns the base `base` [logarithm](https://en.wikipedia.org/wiki/Logarithm)
565
587
  # of `x`.
566
588
  #
567
- # * Domain: `[0, INFINITY]`.
568
- # * Range: `[-INFINITY, INFINITY)]`.
589
+ # * Domain: <code>[0, INFINITY]</code>.
590
+ # * Range: <code>[-INFINITY, INFINITY)]</code>.
569
591
  #
570
592
  # Examples:
571
593
  #
@@ -591,8 +613,8 @@ module Math
591
613
  # Returns the base 10 [logarithm](https://en.wikipedia.org/wiki/Logarithm) of
592
614
  # `x`.
593
615
  #
594
- # * Domain: `[0, INFINITY]`.
595
- # * Range: `[-INFINITY, INFINITY]`.
616
+ # * Domain: <code>[0, INFINITY]</code>.
617
+ # * Range: <code>[-INFINITY, INFINITY]</code>.
596
618
  #
597
619
  # Examples:
598
620
  #
@@ -603,6 +625,25 @@ module Math
603
625
  #
604
626
  def self.log10: (double x) -> Float
605
627
 
628
+ # <!--
629
+ # rdoc-file=math.c
630
+ # - Math.log1p(x) -> float
631
+ # -->
632
+ # Returns "log(x + 1)", the base E
633
+ # [logarithm](https://en.wikipedia.org/wiki/Logarithm) of (`x` + 1).
634
+ #
635
+ # * Domain: <code>[-1, INFINITY]</code>.
636
+ # * Range: <code>[-INFINITY, INFINITY]</code>.
637
+ #
638
+ # Examples:
639
+ #
640
+ # log1p(-1.0) # => -Infinity
641
+ # log1p(0.0) # => 0.0
642
+ # log1p(E - 1) # => 1.0
643
+ # log1p(INFINITY) # => Infinity
644
+ #
645
+ def self.log1p: (double x) -> Float
646
+
606
647
  # <!--
607
648
  # rdoc-file=math.c
608
649
  # - Math.log2(x) -> float
@@ -610,8 +651,8 @@ module Math
610
651
  # Returns the base 2 [logarithm](https://en.wikipedia.org/wiki/Logarithm) of
611
652
  # `x`.
612
653
  #
613
- # * Domain: `[0, INFINITY]`.
614
- # * Range: `[-INFINITY, INFINITY]`.
654
+ # * Domain: <code>[0, INFINITY]</code>.
655
+ # * Range: <code>[-INFINITY, INFINITY]</code>.
615
656
  #
616
657
  # Examples:
617
658
  #
@@ -630,8 +671,8 @@ module Math
630
671
  # [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
631
672
  # _degrees).
632
673
  #
633
- # * Domain: `(-INFINITY, INFINITY)`.
634
- # * Range: `[-1.0, 1.0]`.
674
+ # * Domain: <code>(-INFINITY, INFINITY)</code>.
675
+ # * Range: <code>[-1.0, 1.0]</code>.
635
676
  #
636
677
  # Examples:
637
678
  #
@@ -652,8 +693,8 @@ module Math
652
693
  # [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
653
694
  # _degrees).
654
695
  #
655
- # * Domain: `[-INFINITY, INFINITY]`.
656
- # * Range: `[-INFINITY, INFINITY]`.
696
+ # * Domain: <code>[-INFINITY, INFINITY]</code>.
697
+ # * Range: <code>[-INFINITY, INFINITY]</code>.
657
698
  #
658
699
  # Examples:
659
700
  #
@@ -670,8 +711,8 @@ module Math
670
711
  # Returns the principal (non-negative) [square
671
712
  # root](https://en.wikipedia.org/wiki/Square_root) of `x`.
672
713
  #
673
- # * Domain: `[0, INFINITY]`.
674
- # * Range: `[0, INFINITY]`.
714
+ # * Domain: <code>[0, INFINITY]</code>.
715
+ # * Range: <code>[0, INFINITY]</code>.
675
716
  #
676
717
  # Examples:
677
718
  #
@@ -694,8 +735,8 @@ module Math
694
735
  # [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
695
736
  # _degrees).
696
737
  #
697
- # * Domain: `(-INFINITY, INFINITY)`.
698
- # * Range: `(-INFINITY, INFINITY)`.
738
+ # * Domain: <code>(-INFINITY, INFINITY)</code>.
739
+ # * Range: <code>(-INFINITY, INFINITY)</code>.
699
740
  #
700
741
  # Examples:
701
742
  #
@@ -716,8 +757,8 @@ module Math
716
757
  # [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
717
758
  # _degrees).
718
759
  #
719
- # * Domain: `[-INFINITY, INFINITY]`.
720
- # * Range: `[-1, 1]`.
760
+ # * Domain: <code>[-INFINITY, INFINITY]</code>.
761
+ # * Range: <code>[-1, 1]</code>.
721
762
  #
722
763
  # Examples:
723
764
  #
data/core/method.rbs CHANGED
@@ -1,5 +1,5 @@
1
1
  # <!-- rdoc-file=proc.c -->
2
- # Method objects are created by Object#method, and are associated with a
2
+ # `Method` objects are created by Object#method, and are associated with a
3
3
  # particular object (not just with a class). They may be used to invoke the
4
4
  # method within the object, and as a block associated with an iterator. They
5
5
  # may also be unbound from one object (creating an UnboundMethod) and bound to
@@ -54,8 +54,6 @@ class Method
54
54
  #
55
55
  def hash: () -> Integer
56
56
 
57
- def dup: () -> self
58
-
59
57
  # <!--
60
58
  # rdoc-file=proc.c
61
59
  # - meth.to_s -> string
@@ -76,12 +74,12 @@ class Method
76
74
  # Net::HTTP.method(:get).inspect
77
75
  # #=> "#<Method: Net::HTTP.get(uri_or_host, path=..., port=...) <skip>/lib/ruby/2.7.0/net/http.rb:457>"
78
76
  #
79
- # `...` in argument definition means argument is optional (has some default
80
- # value).
77
+ # <code>...</code> in argument definition means argument is optional (has some
78
+ # default value).
81
79
  #
82
80
  # For methods defined in C (language core and extensions), location and argument
83
81
  # names can't be extracted, and only generic information is provided in form of
84
- # `*` (any number of arguments) or `_` (some positional argument).
82
+ # <code>*</code> (any number of arguments) or `_` (some positional argument).
85
83
  #
86
84
  # "cat".method(:count).inspect #=> "#<Method: String#count(*)>"
87
85
  # "cat".method(:+).inspect #=> "#<Method: String#+(_)>""
@@ -104,12 +102,12 @@ class Method
104
102
  # Net::HTTP.method(:get).inspect
105
103
  # #=> "#<Method: Net::HTTP.get(uri_or_host, path=..., port=...) <skip>/lib/ruby/2.7.0/net/http.rb:457>"
106
104
  #
107
- # `...` in argument definition means argument is optional (has some default
108
- # value).
105
+ # <code>...</code> in argument definition means argument is optional (has some
106
+ # default value).
109
107
  #
110
108
  # For methods defined in C (language core and extensions), location and argument
111
109
  # names can't be extracted, and only generic information is provided in form of
112
- # `*` (any number of arguments) or `_` (some positional argument).
110
+ # <code>*</code> (any number of arguments) or `_` (some positional argument).
113
111
  #
114
112
  # "cat".method(:count).inspect #=> "#<Method: String#count(*)>"
115
113
  # "cat".method(:+).inspect #=> "#<Method: String#+(_)>""
@@ -126,7 +124,9 @@ class Method
126
124
 
127
125
  # <!--
128
126
  # rdoc-file=proc.c
129
- # - meth.call(args, ...) -> obj
127
+ # - meth.call(args, ...) -> obj
128
+ # - meth[args, ...] -> obj
129
+ # - method === obj -> result_of_method
130
130
  # -->
131
131
  # Invokes the *meth* with the specified arguments, returning the method's return
132
132
  # value.
@@ -135,23 +135,32 @@ class Method
135
135
  # m.call(3) #=> 15
136
136
  # m.call(20) #=> 32
137
137
  #
138
+ # Using Method#=== allows a method object to be the target of a `when` clause in
139
+ # a case statement.
140
+ #
141
+ # require 'prime'
142
+ #
143
+ # case 1373
144
+ # when Prime.method(:prime?)
145
+ # # ...
146
+ # end
147
+ #
138
148
  def call: (?) -> untyped
139
149
 
140
150
  # <!--
141
151
  # rdoc-file=proc.c
142
- # - meth << g -> a_proc
152
+ # - self << g -> a_proc
143
153
  # -->
144
- # Returns a proc that is the composition of this method and the given *g*. The
145
- # returned proc takes a variable number of arguments, calls *g* with them then
146
- # calls this method with the result.
154
+ # Returns a proc that is the composition of the given `g` and this method.
147
155
  #
148
- # def f(x)
149
- # x * x
150
- # end
156
+ # The returned proc takes a variable number of arguments. It first calls `g`
157
+ # with the arguments, then calls `self` with the return value of `g`.
158
+ #
159
+ # def f(ary) = ary << 'in f'
151
160
  #
152
161
  # f = self.method(:f)
153
- # g = proc {|x| x + x }
154
- # p (f << g).call(2) #=> 16
162
+ # g = proc { |ary| ary << 'in proc' }
163
+ # (f << g).call([]) # => ["in proc", "in f"]
155
164
  #
156
165
  def <<: (Proc::_Callable g) -> Proc
157
166
 
@@ -163,23 +172,32 @@ class Method
163
172
  # m.call(3) #=> 15
164
173
  # m.call(20) #=> 32
165
174
  #
175
+ # Using Method#=== allows a method object to be the target of a `when` clause in
176
+ # a case statement.
177
+ #
178
+ # require 'prime'
179
+ #
180
+ # case 1373
181
+ # when Prime.method(:prime?)
182
+ # # ...
183
+ # end
184
+ #
166
185
  alias === call
167
186
 
168
187
  # <!--
169
188
  # rdoc-file=proc.c
170
- # - meth >> g -> a_proc
189
+ # - self >> g -> a_proc
171
190
  # -->
172
- # Returns a proc that is the composition of this method and the given *g*. The
173
- # returned proc takes a variable number of arguments, calls this method with
174
- # them then calls *g* with the result.
191
+ # Returns a proc that is the composition of this method and the given `g`.
175
192
  #
176
- # def f(x)
177
- # x * x
178
- # end
193
+ # The returned proc takes a variable number of arguments. It first calls `self`
194
+ # with the arguments, then calls `g` with the return value of `self`.
195
+ #
196
+ # def f(ary) = ary << 'in f'
179
197
  #
180
198
  # f = self.method(:f)
181
- # g = proc {|x| x + x }
182
- # p (f >> g).call(2) #=> 8
199
+ # g = proc { |ary| ary << 'in proc' }
200
+ # (f >> g).call([]) # => ["in f", "in proc"]
183
201
  #
184
202
  def >>: (Proc::_Callable g) -> Proc
185
203
 
@@ -191,6 +209,16 @@ class Method
191
209
  # m.call(3) #=> 15
192
210
  # m.call(20) #=> 32
193
211
  #
212
+ # Using Method#=== allows a method object to be the target of a `when` clause in
213
+ # a case statement.
214
+ #
215
+ # require 'prime'
216
+ #
217
+ # case 1373
218
+ # when Prime.method(:prime?)
219
+ # # ...
220
+ # end
221
+ #
194
222
  alias [] call
195
223
 
196
224
  # <!--
@@ -359,10 +387,18 @@ class Method
359
387
 
360
388
  # <!--
361
389
  # rdoc-file=proc.c
362
- # - meth.source_location -> [String, Integer]
390
+ # - meth.source_location -> [String, Integer, Integer, Integer, Integer]
363
391
  # -->
364
- # Returns the Ruby source filename and line number containing this method or nil
365
- # if this method was not defined in Ruby (i.e. native).
392
+ # Returns the location where the method was defined. The returned Array
393
+ # contains:
394
+ # (1) the Ruby source filename
395
+ # (2) the line number where the definition starts
396
+ # (3) the column number where the definition starts
397
+ # (4) the line number where the definition ends
398
+ # (5) the column number where the definitions ends
399
+ #
400
+ # This method will return `nil` if the method was not defined in Ruby (i.e.
401
+ # native).
366
402
  #
367
403
  def source_location: () -> [String, Integer]?
368
404
 
@@ -370,8 +406,8 @@ class Method
370
406
  # rdoc-file=proc.c
371
407
  # - meth.super_method -> method
372
408
  # -->
373
- # Returns a Method of superclass which would be called when super is used or nil
374
- # if there is no method on superclass.
409
+ # Returns a `Method` of superclass which would be called when super is used or
410
+ # nil if there is no method on superclass.
375
411
  #
376
412
  def super_method: () -> Method?
377
413