rbs 3.6.1 → 3.9.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 (268) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +2 -2
  3. data/.github/workflows/dependabot.yml +1 -1
  4. data/.github/workflows/ruby.yml +34 -10
  5. data/.github/workflows/windows.yml +20 -3
  6. data/.gitignore +1 -0
  7. data/.rubocop.yml +26 -1
  8. data/CHANGELOG.md +241 -0
  9. data/Rakefile +54 -4
  10. data/config.yml +317 -0
  11. data/core/array.rbs +1756 -1591
  12. data/core/basic_object.rbs +38 -35
  13. data/core/comparable.rbs +1 -1
  14. data/core/complex.rbs +166 -94
  15. data/core/data.rbs +2 -2
  16. data/core/dir.rbs +2 -18
  17. data/core/encoding.rbs +12 -32
  18. data/core/enumerable.rbs +270 -266
  19. data/core/enumerator.rbs +14 -4
  20. data/core/env.rbs +1 -1
  21. data/core/errno.rbs +33 -16
  22. data/core/errors.rbs +6 -2
  23. data/core/exception.rbs +342 -167
  24. data/core/fiber.rbs +3 -2
  25. data/core/file.rbs +26 -75
  26. data/core/float.rbs +125 -72
  27. data/core/gc.rbs +158 -42
  28. data/core/hash.rbs +122 -143
  29. data/core/integer.rbs +79 -50
  30. data/core/io/buffer.rbs +49 -43
  31. data/core/io.rbs +108 -151
  32. data/core/kernel.rbs +341 -209
  33. data/core/match_data.rbs +76 -2
  34. data/core/math.rbs +0 -36
  35. data/core/method.rbs +2 -2
  36. data/core/module.rbs +32 -27
  37. data/core/nil_class.rbs +2 -2
  38. data/core/numeric.rbs +101 -104
  39. data/core/object.rbs +1 -5
  40. data/core/object_space/weak_key_map.rbs +3 -4
  41. data/core/object_space.rbs +3 -3
  42. data/core/proc.rbs +82 -14
  43. data/core/process.rbs +110 -58
  44. data/core/ractor.rbs +57 -4
  45. data/core/range.rbs +114 -87
  46. data/core/rational.rbs +0 -2
  47. data/core/rbs/unnamed/argf.rbs +237 -36
  48. data/core/rbs/unnamed/env_class.rbs +35 -53
  49. data/core/rbs/unnamed/random.rbs +1 -2
  50. data/core/regexp.rbs +10 -56
  51. data/core/ruby_vm.rbs +88 -9
  52. data/core/rubygems/config_file.rbs +3 -0
  53. data/core/rubygems/errors.rbs +3 -6
  54. data/core/rubygems/platform.rbs +0 -9
  55. data/core/rubygems/rubygems.rbs +3 -6
  56. data/core/rubygems/version.rbs +8 -8
  57. data/core/set.rbs +4 -16
  58. data/core/string.rbs +271 -264
  59. data/core/struct.rbs +6 -18
  60. data/core/symbol.rbs +14 -21
  61. data/core/thread.rbs +32 -35
  62. data/core/time.rbs +131 -50
  63. data/core/trace_point.rbs +124 -113
  64. data/core/true_class.rbs +0 -1
  65. data/core/unbound_method.rbs +1 -1
  66. data/core/warning.rbs +9 -2
  67. data/docs/architecture.md +1 -1
  68. data/docs/syntax.md +17 -10
  69. data/ext/rbs_extension/extconf.rb +11 -0
  70. data/ext/rbs_extension/location.c +61 -29
  71. data/ext/rbs_extension/location.h +4 -3
  72. data/ext/rbs_extension/main.c +23 -1
  73. data/ext/rbs_extension/parser.c +506 -517
  74. data/ext/rbs_extension/parserstate.c +109 -30
  75. data/ext/rbs_extension/parserstate.h +6 -4
  76. data/ext/rbs_extension/rbs_extension.h +1 -10
  77. data/{ext/rbs_extension → include/rbs}/constants.h +21 -19
  78. data/include/rbs/ruby_objs.h +72 -0
  79. data/include/rbs/util/rbs_constant_pool.h +219 -0
  80. data/include/rbs.h +7 -0
  81. data/lib/rbs/annotate/annotations.rb +3 -3
  82. data/lib/rbs/annotate/rdoc_source.rb +2 -2
  83. data/lib/rbs/ast/declarations.rb +9 -4
  84. data/lib/rbs/ast/directives.rb +10 -0
  85. data/lib/rbs/ast/members.rb +2 -0
  86. data/lib/rbs/ast/type_param.rb +2 -12
  87. data/lib/rbs/cli/diff.rb +3 -3
  88. data/lib/rbs/cli/validate.rb +2 -1
  89. data/lib/rbs/cli.rb +16 -16
  90. data/lib/rbs/collection/config/lockfile_generator.rb +58 -8
  91. data/lib/rbs/collection/config.rb +5 -3
  92. data/lib/rbs/collection/sources/rubygems.rb +1 -1
  93. data/lib/rbs/collection.rb +1 -0
  94. data/lib/rbs/definition.rb +51 -34
  95. data/lib/rbs/definition_builder/ancestor_builder.rb +5 -3
  96. data/lib/rbs/definition_builder.rb +83 -24
  97. data/lib/rbs/environment.rb +33 -18
  98. data/lib/rbs/environment_loader.rb +6 -1
  99. data/lib/rbs/errors.rb +24 -0
  100. data/lib/rbs/locator.rb +2 -0
  101. data/lib/rbs/method_type.rb +2 -0
  102. data/lib/rbs/namespace.rb +1 -0
  103. data/lib/rbs/parser_aux.rb +40 -3
  104. data/lib/rbs/prototype/rb.rb +20 -12
  105. data/lib/rbs/prototype/rbi.rb +11 -6
  106. data/lib/rbs/prototype/runtime/value_object_generator.rb +7 -5
  107. data/lib/rbs/prototype/runtime.rb +7 -5
  108. data/lib/rbs/subtractor.rb +3 -3
  109. data/lib/rbs/test/hook.rb +47 -42
  110. data/lib/rbs/test/type_check.rb +7 -5
  111. data/lib/rbs/type_name.rb +14 -9
  112. data/lib/rbs/types.rb +63 -14
  113. data/lib/rbs/unit_test/spy.rb +4 -2
  114. data/lib/rbs/unit_test/type_assertions.rb +19 -13
  115. data/lib/rbs/unit_test/with_aliases.rb +3 -1
  116. data/lib/rbs/validator.rb +7 -1
  117. data/lib/rbs/version.rb +1 -1
  118. data/lib/rbs/writer.rb +10 -5
  119. data/lib/rbs.rb +1 -0
  120. data/lib/rdoc_plugin/parser.rb +2 -2
  121. data/rbs.gemspec +6 -2
  122. data/sig/ancestor_graph.rbs +5 -5
  123. data/sig/annotate/rdoc_source.rbs +2 -0
  124. data/sig/cli.rbs +2 -0
  125. data/sig/collection/config/lockfile_generator.rbs +9 -1
  126. data/sig/declarations.rbs +10 -3
  127. data/sig/definition.rbs +80 -12
  128. data/sig/definition_builder.rbs +18 -4
  129. data/sig/directives.rbs +17 -1
  130. data/sig/environment.rbs +3 -1
  131. data/sig/errors.rbs +19 -0
  132. data/sig/namespace.rbs +2 -3
  133. data/sig/parser.rbs +5 -1
  134. data/sig/prototype/rb.rbs +1 -1
  135. data/sig/resolver/constant_resolver.rbs +2 -2
  136. data/sig/resolver/context.rbs +1 -1
  137. data/sig/subtractor.rbs +1 -1
  138. data/sig/test/type_check.rbs +2 -2
  139. data/sig/type_alias_dependency.rbs +2 -2
  140. data/sig/type_alias_regularity.rbs +6 -6
  141. data/sig/type_param.rbs +4 -4
  142. data/sig/typename.rbs +8 -5
  143. data/sig/types.rbs +1 -1
  144. data/sig/unit_test/spy.rbs +2 -0
  145. data/sig/unit_test/type_assertions.rbs +2 -0
  146. data/sig/use_map.rbs +1 -1
  147. data/sig/validator.rbs +6 -2
  148. data/sig/vendorer.rbs +1 -1
  149. data/sig/writer.rbs +1 -1
  150. data/{ext/rbs_extension → src}/constants.c +35 -36
  151. data/src/ruby_objs.c +799 -0
  152. data/src/util/rbs_constant_pool.c +342 -0
  153. data/stdlib/base64/0/base64.rbs +0 -9
  154. data/stdlib/benchmark/0/benchmark.rbs +11 -2
  155. data/stdlib/bigdecimal/0/big_decimal.rbs +26 -182
  156. data/stdlib/cgi/0/core.rbs +60 -3
  157. data/stdlib/cgi/0/manifest.yaml +1 -0
  158. data/stdlib/coverage/0/coverage.rbs +0 -3
  159. data/stdlib/csv/0/csv.rbs +18 -58
  160. data/stdlib/csv/0/manifest.yaml +1 -0
  161. data/stdlib/date/0/date.rbs +27 -42
  162. data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -6
  163. data/stdlib/digest/0/digest.rbs +25 -2
  164. data/stdlib/erb/0/erb.rbs +0 -1
  165. data/stdlib/etc/0/etc.rbs +51 -34
  166. data/stdlib/fileutils/0/fileutils.rbs +3 -44
  167. data/stdlib/io-console/0/io-console.rbs +69 -15
  168. data/stdlib/ipaddr/0/ipaddr.rbs +16 -4
  169. data/stdlib/json/0/json.rbs +107 -120
  170. data/stdlib/logger/0/log_device.rbs +1 -1
  171. data/stdlib/logger/0/logger.rbs +3 -18
  172. data/stdlib/minitest/0/kernel.rbs +2 -2
  173. data/stdlib/minitest/0/minitest/abstract_reporter.rbs +4 -1
  174. data/stdlib/minitest/0/minitest/assertion.rbs +1 -0
  175. data/stdlib/minitest/0/minitest/assertions.rbs +58 -13
  176. data/stdlib/minitest/0/minitest/backtrace_filter.rbs +7 -0
  177. data/stdlib/minitest/0/minitest/bench_spec.rbs +8 -8
  178. data/stdlib/minitest/0/minitest/benchmark.rbs +17 -16
  179. data/stdlib/minitest/0/minitest/compress.rbs +13 -0
  180. data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
  181. data/stdlib/minitest/0/minitest/mock.rbs +9 -5
  182. data/stdlib/minitest/0/minitest/parallel/executor.rbs +4 -0
  183. data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +0 -1
  184. data/stdlib/minitest/0/minitest/pride_io.rbs +8 -0
  185. data/stdlib/minitest/0/minitest/pride_lol.rbs +2 -0
  186. data/stdlib/minitest/0/minitest/progress_reporter.rbs +1 -1
  187. data/stdlib/minitest/0/minitest/reportable.rbs +2 -0
  188. data/stdlib/minitest/0/minitest/runnable.rbs +33 -1
  189. data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +1 -1
  190. data/stdlib/minitest/0/minitest/spec/dsl.rbs +10 -6
  191. data/stdlib/minitest/0/minitest/spec.rbs +1 -1
  192. data/stdlib/minitest/0/minitest/statistics_reporter.rbs +5 -0
  193. data/stdlib/minitest/0/minitest/summary_reporter.rbs +0 -7
  194. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +1 -1
  195. data/stdlib/minitest/0/minitest/test.rbs +7 -14
  196. data/stdlib/minitest/0/minitest/unexpected_error.rbs +2 -0
  197. data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
  198. data/stdlib/minitest/0/minitest/unit.rbs +1 -2
  199. data/stdlib/minitest/0/minitest.rbs +41 -892
  200. data/stdlib/monitor/0/monitor.rbs +13 -4
  201. data/stdlib/net-http/0/net-http.rbs +42 -109
  202. data/stdlib/nkf/0/nkf.rbs +30 -0
  203. data/stdlib/objspace/0/objspace.rbs +1 -2
  204. data/stdlib/observable/0/observable.rbs +1 -1
  205. data/stdlib/open-uri/0/manifest.yaml +1 -0
  206. data/stdlib/open-uri/0/open-uri.rbs +52 -0
  207. data/stdlib/open3/0/open3.rbs +0 -8
  208. data/stdlib/openssl/0/manifest.yaml +1 -0
  209. data/stdlib/openssl/0/openssl.rbs +235 -143
  210. data/stdlib/optparse/0/optparse.rbs +58 -18
  211. data/stdlib/pathname/0/pathname.rbs +2 -8
  212. data/stdlib/pp/0/pp.rbs +3 -1
  213. data/stdlib/prettyprint/0/prettyprint.rbs +0 -4
  214. data/stdlib/pstore/0/pstore.rbs +0 -6
  215. data/stdlib/psych/0/core_ext.rbs +12 -0
  216. data/stdlib/psych/0/psych.rbs +15 -4
  217. data/stdlib/pty/0/pty.rbs +46 -4
  218. data/stdlib/rdoc/0/code_object.rbs +0 -4
  219. data/stdlib/rdoc/0/markup.rbs +10 -12
  220. data/stdlib/rdoc/0/rdoc.rbs +13 -8
  221. data/stdlib/resolv/0/resolv.rbs +21 -12
  222. data/stdlib/ripper/0/ripper.rbs +0 -2
  223. data/stdlib/securerandom/0/securerandom.rbs +7 -2
  224. data/stdlib/shellwords/0/shellwords.rbs +11 -12
  225. data/stdlib/singleton/0/singleton.rbs +0 -1
  226. data/stdlib/socket/0/addrinfo.rbs +1 -2
  227. data/stdlib/socket/0/basic_socket.rbs +0 -5
  228. data/stdlib/socket/0/socket.rbs +32 -27
  229. data/stdlib/socket/0/tcp_server.rbs +0 -3
  230. data/stdlib/socket/0/tcp_socket.rbs +36 -3
  231. data/stdlib/socket/0/udp_socket.rbs +0 -1
  232. data/stdlib/socket/0/unix_server.rbs +0 -3
  233. data/stdlib/socket/0/unix_socket.rbs +4 -2
  234. data/{core/string_io.rbs → stdlib/stringio/0/stringio.rbs} +1 -1
  235. data/stdlib/strscan/0/string_scanner.rbs +1265 -422
  236. data/stdlib/tempfile/0/tempfile.rbs +135 -28
  237. data/stdlib/time/0/time.rbs +48 -35
  238. data/stdlib/timeout/0/timeout.rbs +11 -8
  239. data/stdlib/tmpdir/0/tmpdir.rbs +10 -3
  240. data/stdlib/tsort/0/tsort.rbs +0 -4
  241. data/stdlib/uri/0/common.rbs +28 -30
  242. data/stdlib/uri/0/ftp.rbs +1 -1
  243. data/stdlib/uri/0/generic.rbs +22 -18
  244. data/stdlib/uri/0/http.rbs +2 -2
  245. data/stdlib/uri/0/rfc2396_parser.rbs +3 -0
  246. data/stdlib/zlib/0/buf_error.rbs +1 -70
  247. data/stdlib/zlib/0/data_error.rbs +1 -70
  248. data/stdlib/zlib/0/deflate.rbs +8 -72
  249. data/stdlib/zlib/0/error.rbs +1 -70
  250. data/stdlib/zlib/0/gzip_file/crc_error.rbs +2 -105
  251. data/stdlib/zlib/0/gzip_file/error.rbs +2 -105
  252. data/stdlib/zlib/0/gzip_file/length_error.rbs +2 -105
  253. data/stdlib/zlib/0/gzip_file/no_footer.rbs +2 -105
  254. data/stdlib/zlib/0/gzip_file.rbs +1 -71
  255. data/stdlib/zlib/0/gzip_reader.rbs +3 -74
  256. data/stdlib/zlib/0/gzip_writer.rbs +1 -70
  257. data/stdlib/zlib/0/inflate.rbs +4 -71
  258. data/stdlib/zlib/0/mem_error.rbs +1 -70
  259. data/stdlib/zlib/0/need_dict.rbs +1 -70
  260. data/stdlib/zlib/0/stream_end.rbs +1 -70
  261. data/stdlib/zlib/0/stream_error.rbs +1 -70
  262. data/stdlib/zlib/0/version_error.rbs +1 -70
  263. data/stdlib/zlib/0/zlib.rbs +0 -2
  264. data/stdlib/zlib/0/zstream.rbs +4 -72
  265. metadata +17 -13
  266. data/ext/rbs_extension/ruby_objs.c +0 -602
  267. data/ext/rbs_extension/ruby_objs.h +0 -51
  268. data/stdlib/minitest/0/manifest.yaml +0 -2
data/core/process.rbs CHANGED
@@ -13,7 +13,6 @@
13
13
  # without waiting for completion.
14
14
  # * Process.exec: Replaces the current process by executing the command.
15
15
  #
16
- #
17
16
  # In addition:
18
17
  #
19
18
  # * Method Kernel#system executes a given command-line (string) in a subshell;
@@ -23,7 +22,6 @@
23
22
  # * Module Open3 supports creating child processes with access to their
24
23
  # $stdin, $stdout, and $stderr streams.
25
24
  #
26
- #
27
25
  # ### Execution Environment
28
26
  #
29
27
  # Optional leading argument `env` is a hash of name/value pairs, where each name
@@ -52,15 +50,14 @@
52
50
  # built-in, or if it contains one or more meta characters.
53
51
  # * `exe_path` otherwise.
54
52
  #
55
- #
56
- # **Argument `command_line`**
53
+ # #### Argument `command_line`
57
54
  #
58
55
  # String argument `command_line` is a command line to be passed to a shell; it
59
56
  # must begin with a shell reserved word, begin with a special built-in, or
60
57
  # contain meta characters:
61
58
  #
62
59
  # system('if true; then echo "Foo"; fi') # => true # Shell reserved word.
63
- # system('echo') # => true # Built-in.
60
+ # system('exit') # => true # Built-in.
64
61
  # system('date > /tmp/date.tmp') # => true # Contains meta character.
65
62
  # system('date > /nop/date.tmp') # => false
66
63
  # system('date > /nop/date.tmp', exception: true) # Raises RuntimeError.
@@ -76,23 +73,85 @@
76
73
  # See [Execution Shell](rdoc-ref:Process@Execution+Shell) for details about the
77
74
  # shell.
78
75
  #
79
- # **Argument `exe_path`**
76
+ # #### Argument `exe_path`
80
77
  #
81
78
  # Argument `exe_path` is one of the following:
82
79
  #
83
- # * The string path to an executable to be called.
84
- # * A 2-element array containing the path to an executable to be called, and
85
- # the string to be used as the name of the executing process.
80
+ # * The string path to an executable file to be called:
81
+ #
82
+ # Example:
83
+ #
84
+ # system('/usr/bin/date') # => true # Path to date on Unix-style system.
85
+ # system('foo') # => nil # Command execlution failed.
86
+ #
87
+ # Output:
88
+ #
89
+ # Thu Aug 31 10:06:48 AM CDT 2023
90
+ #
91
+ # A path or command name containing spaces without arguments cannot be
92
+ # distinguished from `command_line` above, so you must quote or escape the
93
+ # entire command name using a shell in platform dependent manner, or use the
94
+ # array form below.
95
+ #
96
+ # If `exe_path` does not contain any path separator, an executable file is
97
+ # searched from directories specified with the `PATH` environment variable.
98
+ # What the word "executable" means here is depending on platforms.
99
+ #
100
+ # Even if the file considered "executable", its content may not be in proper
101
+ # executable format. In that case, Ruby tries to run it by using `/bin/sh`
102
+ # on a Unix-like system, like system(3) does.
103
+ #
104
+ # File.write('shell_command', 'echo $SHELL', perm: 0o755)
105
+ # system('./shell_command') # prints "/bin/sh" or something.
106
+ #
107
+ # * A 2-element array containing the path to an executable and the string to
108
+ # be used as the name of the executing process:
109
+ #
110
+ # Example:
111
+ #
112
+ # pid = spawn(['sleep', 'Hello!'], '1') # 2-element array.
113
+ # p `ps -p #{pid} -o command=`
114
+ #
115
+ # Output:
116
+ #
117
+ # "Hello! 1\n"
118
+ #
119
+ # ### Arguments `args`
120
+ #
121
+ # If `command_line` does not contain shell meta characters except for spaces and
122
+ # tabs, or `exe_path` is given, Ruby invokes the executable directly. This form
123
+ # does not use the shell:
86
124
  #
125
+ # spawn("doesnt_exist") # Raises Errno::ENOENT
126
+ # spawn("doesnt_exist", "\n") # Raises Errno::ENOENT
127
+ #
128
+ # spawn("doesnt_exist\n") # => false
129
+ # # sh: 1: doesnot_exist: not found
130
+ #
131
+ # The error message is from a shell and would vary depending on your system.
132
+ #
133
+ # If one or more `args` is given after `exe_path`, each is an argument or option
134
+ # to be passed to the executable:
87
135
  #
88
136
  # Example:
89
137
  #
90
- # system('/usr/bin/date') # => true # Path to date on Unix-style system.
91
- # system('foo') # => nil # Command failed.
138
+ # system('echo', '<', 'C*', '|', '$SHELL', '>') # => true
92
139
  #
93
140
  # Output:
94
141
  #
95
- # Mon Aug 28 11:43:10 AM CDT 2023
142
+ # < C* | $SHELL >
143
+ #
144
+ # However, there are exceptions on Windows. See [Execution Shell on
145
+ # Windows](rdoc-ref:Process@Execution+Shell+on+Windows).
146
+ #
147
+ # If you want to invoke a path containing spaces with no arguments without
148
+ # shell, you will need to use a 2-element array `exe_path`.
149
+ #
150
+ # Example:
151
+ #
152
+ # path = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
153
+ # spawn(path) # Raises Errno::ENOENT; No such file or directory - /Applications/Google
154
+ # spawn([path] * 2)
96
155
  #
97
156
  # ### Execution Options
98
157
  #
@@ -133,14 +192,12 @@
133
192
  #
134
193
  # * *n*: Specifies file descriptor *n*.
135
194
  #
136
- #
137
195
  # There are these shorthand symbols for fds:
138
196
  #
139
197
  # * `:in`: Specifies file descriptor 0 (STDIN).
140
198
  # * `:out`: Specifies file descriptor 1 (STDOUT).
141
199
  # * `:err`: Specifies file descriptor 2 (STDERR).
142
200
  #
143
- #
144
201
  # The value given with a source is one of:
145
202
  #
146
203
  # * *n*: Redirects to fd *n* in the parent process.
@@ -156,7 +213,6 @@
156
213
  # * `[:child, fd]`: Redirects to the redirected `fd`.
157
214
  # * `:close`: Closes the file descriptor in child process.
158
215
  #
159
- #
160
216
  # See [Access Modes](rdoc-ref:File@Access+Modes) and [File
161
217
  # Permissions](rdoc-ref:File@File+Permissions).
162
218
  #
@@ -194,7 +250,6 @@
194
250
  # * `true`: Create a new process group for the new process.
195
251
  # * *pgid*: Create the new process in the process group whose id is *pgid*.
196
252
  #
197
- #
198
253
  # On Windows only, use execution option `:new_pgroup` with value `true` to
199
254
  # create a new process group for the new process.
200
255
  #
@@ -212,7 +267,6 @@
212
267
  # * An integer, specifying both the current and maximum limits.
213
268
  # * A 2-element array of integers, specifying the current and maximum limits.
214
269
  #
215
- #
216
270
  # #### File Descriptor Inheritance
217
271
  #
218
272
  # By default, the new process inherits file descriptors from the parent process.
@@ -222,23 +276,48 @@
222
276
  #
223
277
  # ### Execution Shell
224
278
  #
225
- # On a Unix-like system, the shell invoked is `/bin/sh`; otherwise the shell
226
- # invoked is determined by environment variable `ENV['RUBYSHELL']`, if defined,
227
- # or `ENV['COMSPEC']` otherwise.
228
- #
229
- # Except for the `COMSPEC` case, the entire string `command_line` is passed as
230
- # an argument to [shell option
279
+ # On a Unix-like system, the shell invoked is `/bin/sh`; the entire string
280
+ # `command_line` is passed as an argument to [shell option
231
281
  # -c](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/sh.
232
282
  # html).
233
283
  #
234
284
  # The shell performs normal shell expansion on the command line:
235
285
  #
236
- # spawn('echo C*') # => 799139
237
- # Process.wait # => 799139
286
+ # Example:
287
+ #
288
+ # system('echo $SHELL: C*') # => true
289
+ #
290
+ # Output:
291
+ #
292
+ # /bin/bash: CONTRIBUTING.md COPYING COPYING.ja
293
+ #
294
+ # #### Execution Shell on Windows
295
+ #
296
+ # On Windows, the shell invoked is determined by environment variable
297
+ # `RUBYSHELL`, if defined, or `COMSPEC` otherwise; the entire string
298
+ # `command_line` is passed as an argument to `-c` option for `RUBYSHELL`, as
299
+ # well as `/bin/sh`, and [/c
300
+ # option](https://learn.microsoft.com/en-us/windows-server/administration/window
301
+ # s-commands/cmd) for `COMSPEC`. The shell is invoked automatically in the
302
+ # following cases:
303
+ #
304
+ # * The command is a built-in of `cmd.exe`, such as `echo`.
305
+ # * The executable file is a batch file; its name ends with `.bat` or `.cmd`.
306
+ #
307
+ # Note that the command will still be invoked as `command_line` form even when
308
+ # called in `exe_path` form, because `cmd.exe` does not accept a script name
309
+ # like `/bin/sh` does but only works with `/c` option.
310
+ #
311
+ # The standard shell `cmd.exe` performs environment variable expansion but does
312
+ # not have globbing functionality:
313
+ #
314
+ # Example:
315
+ #
316
+ # system("echo %COMSPEC%: C*")' # => true
238
317
  #
239
318
  # Output:
240
319
  #
241
- # CONTRIBUTING.md COPYING COPYING.ja
320
+ # C:\WINDOWS\system32\cmd.exe: C*
242
321
  #
243
322
  # ## What's Here
244
323
  #
@@ -254,7 +333,6 @@
254
333
  # * ::ppid: Returns the process ID of the parent process.
255
334
  # * ::uid: Returns the (real) user ID.
256
335
  #
257
- #
258
336
  # ### Current-Process Setters
259
337
  #
260
338
  # * ::egid=: Sets the effective group ID.
@@ -267,7 +345,6 @@
267
345
  # leader, with no controlling tty.
268
346
  # * ::uid=: Sets the user ID.
269
347
  #
270
- #
271
348
  # ### Current-Process Execution
272
349
  #
273
350
  # * ::abort: Immediately terminates the process.
@@ -281,7 +358,6 @@
281
358
  # application is completed, and that the VM may begin optimizing the
282
359
  # application.
283
360
  #
284
- #
285
361
  # ### Child Processes
286
362
  #
287
363
  # * ::detach: Guards against a child process becoming a zombie.
@@ -295,7 +371,6 @@
295
371
  # * ::waitall: Waits for all child processes to exit; returns their process
296
372
  # IDs and statuses.
297
373
  #
298
- #
299
374
  # ### Process Groups
300
375
  #
301
376
  # * ::getpgid: Returns the process group ID for a process.
@@ -317,7 +392,6 @@
317
392
  # * ::setpriority: Sets the scheduling priority for a process, process group,
318
393
  # or user.
319
394
  #
320
- #
321
395
  # ### Timing
322
396
  #
323
397
  # * ::clock_getres: Returns the resolution of a system clock.
@@ -448,7 +522,6 @@ module Process
448
522
  # * `:CLOCK_UPTIME_RAW_APPROX`: macOS 10.12.
449
523
  # * `:CLOCK_VIRTUAL`: FreeBSD 3.0, OpenBSD 2.1.
450
524
  #
451
- #
452
525
  # Note that SUS stands for Single Unix Specification. SUS contains POSIX and
453
526
  # clock_gettime is defined in the POSIX part. SUS defines `:CLOCK_REALTIME` as
454
527
  # mandatory but `:CLOCK_MONOTONIC`, `:CLOCK_PROCESS_CPUTIME_ID`, and
@@ -464,7 +537,6 @@ module Process
464
537
  # * `:TIME_BASED_CLOCK_REALTIME`: Use time() defined by ISO C. The
465
538
  # resolution is 1 second.
466
539
  #
467
- #
468
540
  # * Emulations for `:CLOCK_MONOTONIC`:
469
541
  #
470
542
  # * `:MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC`: Use mach_absolute_time(),
@@ -485,7 +557,6 @@ module Process
485
557
  # type, the resolution is 10 millisecond and cannot represent over 497
486
558
  # days.
487
559
  #
488
- #
489
560
  # * Emulations for `:CLOCK_PROCESS_CPUTIME_ID`:
490
561
  #
491
562
  # * `:GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID`: Use getrusage() defined
@@ -508,8 +579,6 @@ module Process
508
579
  # `CLOCKS_PER_SEC` is 1000000 and clock_t is a 32-bit integer type, it
509
580
  # cannot represent over 72 minutes.
510
581
  #
511
- #
512
- #
513
582
  # **Argument `unit`**
514
583
  #
515
584
  # Optional argument `unit` (default `:float_second`) specifies the unit for the
@@ -523,7 +592,6 @@ module Process
523
592
  # * `:nanosecond`: Number of nanoseconds as an integer.
524
593
  # * `::second`: Number of seconds as an integer.
525
594
  #
526
- #
527
595
  # Examples:
528
596
  #
529
597
  # Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :float_microsecond)
@@ -569,7 +637,6 @@ module Process
569
637
  # * Changes the current working directory to the root directory.
570
638
  # * Redirects $stdin, $stdout, and $stderr to the null device.
571
639
  #
572
- #
573
640
  # If optional argument `nochdir` is `true`, does not change the current working
574
641
  # directory.
575
642
  #
@@ -615,7 +682,7 @@ module Process
615
682
  #
616
683
  # thread.join.pid # => 313262
617
684
  #
618
- def self.detach: (Integer pid) -> Thread
685
+ def self.detach: (Integer pid) -> Process::Waiter
619
686
 
620
687
  # <!--
621
688
  # rdoc-file=process.c
@@ -698,7 +765,6 @@ module Process
698
765
  # * Process::PRIO_PGRP: return priority for process group.
699
766
  # * Process::PRIO_USER: return priority for user.
700
767
  #
701
- #
702
768
  # Argument `id` is the ID for the process, process group, or user; zero
703
769
  # specified the current ID for `kind`.
704
770
  #
@@ -787,7 +853,6 @@ module Process
787
853
  # * Whether the array includes duplicate group IDs.
788
854
  # * Whether the array size exceeds the value of Process.maxgroups.
789
855
  #
790
- #
791
856
  # Use this call to get a sorted and unique array:
792
857
  #
793
858
  # Process.groups.uniq.sort
@@ -816,7 +881,6 @@ module Process
816
881
  # belongs.
817
882
  # * The group ID `gid`.
818
883
  #
819
- #
820
884
  # Example:
821
885
  #
822
886
  # Process.groups # => [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27]
@@ -840,7 +904,6 @@ module Process
840
904
  # * Zero, send the signal to all processes in the current process group.
841
905
  # * Negative, sends the signal to a system-dependent collection of processes.
842
906
  #
843
- #
844
907
  # Argument `signal` specifies the signal to be sent; the argument may be:
845
908
  #
846
909
  # * An integer signal number: e.g., `-29`, `0`, `29`.
@@ -852,7 +915,6 @@ module Process
852
915
  # * `'-SIGPOLL'`.
853
916
  # * `'-POLL'`.
854
917
  #
855
- #
856
918
  # * A signal symbol, with or without leading `'SIG'`, and with or without a
857
919
  # further prefixed minus sign (`'-'`): e.g.:
858
920
  #
@@ -861,8 +923,6 @@ module Process
861
923
  # * `:'-SIGPOLL'`.
862
924
  # * `:'-POLL'`.
863
925
  #
864
- #
865
- #
866
926
  # If `signal` is:
867
927
  #
868
928
  # * A non-negative integer, or a signal name or symbol without prefixed `'-'`,
@@ -870,7 +930,6 @@ module Process
870
930
  # * A negative integer, or a signal name or symbol with prefixed `'-'`, each
871
931
  # process group with group ID `id` is signalled.
872
932
  #
873
- #
874
933
  # Use method Signal.list to see which signals are supported by Ruby on the
875
934
  # underlying platform; the method returns a hash of the string names and
876
935
  # non-negative integer values of the supported signals. The size and content of
@@ -899,7 +958,6 @@ module Process
899
958
  # * Raises Errno::ESRCH or RangeError if one of `ids` is invalid.
900
959
  # * Raises Errno::EPERM if needed permissions are not in force.
901
960
  #
902
- #
903
961
  # In the last two cases, signals may have been sent to some processes.
904
962
  #
905
963
  def self.kill: (Integer | interned signal, *Integer pids) -> Integer
@@ -1031,7 +1089,6 @@ module Process
1031
1089
  # * `:SIGPENDING`: Number of queued signals allowed (signals) (GNU/Linux).
1032
1090
  # * `:STACK`: Stack size (bytes) (SUSv3).
1033
1091
  #
1034
- #
1035
1092
  # Arguments `cur_limit` and `max_limit` may be:
1036
1093
  #
1037
1094
  # * Integers (`max_limit` should not be smaller than `cur_limit`).
@@ -1042,7 +1099,6 @@ module Process
1042
1099
  # * Symbol `:INFINITY`, string `'INFINITY'`, or constant
1043
1100
  # `Process::RLIM_INFINITY`: no limit on resource.
1044
1101
  #
1045
- #
1046
1102
  # This example raises the soft limit of core size to the hard limit to try to
1047
1103
  # make core dump possible:
1048
1104
  #
@@ -1221,15 +1277,13 @@ module Process
1221
1277
  # Process.wait(-child1_pid) returned pid 230109, which is child 1 pid.
1222
1278
  # Raised Errno::ECHILD, because there's no longer a child with process group id 230109.
1223
1279
  #
1224
- #
1225
1280
  # Argument `flags` should be given as one of the following constants, or as the
1226
1281
  # logical OR of both:
1227
1282
  #
1228
1283
  # * Process::WNOHANG: Does not block if no child process is available.
1229
- # * Process:WUNTRACED: May return a stopped child process, even if not yet
1284
+ # * Process::WUNTRACED: May return a stopped child process, even if not yet
1230
1285
  # reported.
1231
1286
  #
1232
- #
1233
1287
  # Not all flags are available on all platforms.
1234
1288
  #
1235
1289
  # Raises Errno::ECHILD if there is no suitable child process.
@@ -1251,7 +1305,7 @@ module Process
1251
1305
  # Process.wait2(pid)
1252
1306
  # # => [309581, #<Process::Status: pid 309581 exit 13>]
1253
1307
  #
1254
- # Process.waitpid2 is an alias for Process.waitpid.
1308
+ # Process.waitpid2 is an alias for Process.wait2.
1255
1309
  #
1256
1310
  def self.wait2: (?Integer pid, ?Integer flags) -> [ Integer, Process::Status ]
1257
1311
 
@@ -1388,15 +1442,13 @@ module Process
1388
1442
  # Process.wait(-child1_pid) returned pid 230109, which is child 1 pid.
1389
1443
  # Raised Errno::ECHILD, because there's no longer a child with process group id 230109.
1390
1444
  #
1391
- #
1392
1445
  # Argument `flags` should be given as one of the following constants, or as the
1393
1446
  # logical OR of both:
1394
1447
  #
1395
1448
  # * Process::WNOHANG: Does not block if no child process is available.
1396
- # * Process:WUNTRACED: May return a stopped child process, even if not yet
1449
+ # * Process::WUNTRACED: May return a stopped child process, even if not yet
1397
1450
  # reported.
1398
1451
  #
1399
- #
1400
1452
  # Not all flags are available on all platforms.
1401
1453
  #
1402
1454
  # Raises Errno::ECHILD if there is no suitable child process.
@@ -1418,7 +1470,7 @@ module Process
1418
1470
  # Process.wait2(pid)
1419
1471
  # # => [309581, #<Process::Status: pid 309581 exit 13>]
1420
1472
  #
1421
- # Process.waitpid2 is an alias for Process.waitpid.
1473
+ # Process.waitpid2 is an alias for Process.wait2.
1422
1474
  #
1423
1475
  def self.waitpid2: (?Integer pid, ?Integer flags) -> [ Integer, Process::Status ]
1424
1476
 
data/core/ractor.rbs CHANGED
@@ -50,7 +50,6 @@
50
50
  # * Ractor.yield and Ractor#take for when the *receiver* knows the sender
51
51
  # (pull);
52
52
  #
53
- #
54
53
  # In addition to that, any arguments passed to Ractor.new are passed to the
55
54
  # block and available there as if received by Ractor.receive, and the last block
56
55
  # value is sent outside of the ractor as if sent by Ractor.yield.
@@ -250,6 +249,30 @@
250
249
  # See [Ractor design doc](rdoc-ref:ractor.md) for more details.
251
250
  #
252
251
  class Ractor
252
+ # <!--
253
+ # rdoc-file=ractor.rb
254
+ # - _require(feature)
255
+ # -->
256
+ # internal method
257
+ #
258
+ def self._require: (String feature) -> bool
259
+
260
+ # <!--
261
+ # rdoc-file=ractor.rb
262
+ # - [](sym)
263
+ # -->
264
+ # get a value from ractor-local storage of current Ractor
265
+ #
266
+ def self.[]: (Symbol) -> untyped
267
+
268
+ # <!--
269
+ # rdoc-file=ractor.rb
270
+ # - []=(sym, val)
271
+ # -->
272
+ # set a value in ractor-local storage of current Ractor
273
+ #
274
+ def self.[]=: (Symbol, untyped) -> untyped
275
+
253
276
  # <!--
254
277
  # rdoc-file=ractor.rb
255
278
  # - count()
@@ -281,7 +304,15 @@ class Ractor
281
304
  # -->
282
305
  # returns main ractor
283
306
  #
284
- def self.main: () -> untyped
307
+ def self.main: () -> Ractor
308
+
309
+ # <!--
310
+ # rdoc-file=ractor.rb
311
+ # - main?()
312
+ # -->
313
+ # return true if the current ractor is main ractor
314
+ #
315
+ def self.main?: () -> boolish
285
316
 
286
317
  # <!--
287
318
  # rdoc-file=ractor.rb
@@ -557,6 +588,23 @@ class Ractor
557
588
  #
558
589
  def self.shareable?: (untyped obj) -> bool
559
590
 
591
+ # <!--
592
+ # rdoc-file=ractor.rb
593
+ # - Ractor.store_if_absent(key){ init_block }
594
+ # -->
595
+ # If the correponding value is not set, yield a value with init_block and store
596
+ # the value in thread-safe manner. This method returns corresponding stored
597
+ # value.
598
+ #
599
+ # (1..10).map{
600
+ # Thread.new(it){|i|
601
+ # Ractor.store_if_absent(:s){ f(); i }
602
+ # #=> return stored value of key :s
603
+ # }
604
+ # }.map(&:value).uniq.size #=> 1 and f() is called only once
605
+ #
606
+ def self.store_if_absent: [A] (Symbol) { (nil) -> A } -> A
607
+
560
608
  # <!--
561
609
  # rdoc-file=ractor.rb
562
610
  # - Ractor.yield(msg, move: false) -> nil
@@ -608,7 +656,8 @@ class Ractor
608
656
  # rdoc-file=ractor.rb
609
657
  # - [](sym)
610
658
  # -->
611
- # get a value from ractor-local storage
659
+ # get a value from ractor-local storage of current Ractor Obsolete and use
660
+ # Ractor.[] instead.
612
661
  #
613
662
  def []: (interned sym) -> untyped
614
663
 
@@ -616,7 +665,8 @@ class Ractor
616
665
  # rdoc-file=ractor.rb
617
666
  # - []=(sym, val)
618
667
  # -->
619
- # set a value in ractor-local storage
668
+ # set a value in ractor-local storage of current Ractor Obsolete and use
669
+ # Ractor.[]= instead.
620
670
  #
621
671
  def []=: [T] (interned sym, T val) -> T
622
672
 
@@ -1003,6 +1053,9 @@ class Ractor
1003
1053
  # end
1004
1054
  #
1005
1055
  class RemoteError < Ractor::Error
1056
+ # <!-- rdoc-file=ractor.rb -->
1057
+ # The Ractor an uncaught exception is raised in.
1058
+ #
1006
1059
  def ractor: () -> Ractor
1007
1060
  end
1008
1061