rbs 4.1.0.pre.2-java

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 (574) hide show
  1. checksums.yaml +7 -0
  2. data/.clang-format +75 -0
  3. data/.clangd +2 -0
  4. data/.github/dependabot.yml +24 -0
  5. data/.github/workflows/bundle-update.yml +63 -0
  6. data/.github/workflows/c-check.yml +61 -0
  7. data/.github/workflows/comments.yml +37 -0
  8. data/.github/workflows/dependabot.yml +30 -0
  9. data/.github/workflows/jruby.yml +67 -0
  10. data/.github/workflows/milestone.yml +83 -0
  11. data/.github/workflows/ruby.yml +158 -0
  12. data/.github/workflows/rust.yml +184 -0
  13. data/.github/workflows/truffleruby.yml +54 -0
  14. data/.github/workflows/typecheck.yml +39 -0
  15. data/.github/workflows/wasm.yml +53 -0
  16. data/.github/workflows/windows.yml +49 -0
  17. data/.gitignore +38 -0
  18. data/.rubocop.yml +72 -0
  19. data/BSDL +22 -0
  20. data/CHANGELOG.md +2292 -0
  21. data/COPYING +56 -0
  22. data/README.md +240 -0
  23. data/Rakefile +869 -0
  24. data/Steepfile +53 -0
  25. data/config.yml +913 -0
  26. data/core/array.rbs +4142 -0
  27. data/core/basic_object.rbs +376 -0
  28. data/core/binding.rbs +148 -0
  29. data/core/builtin.rbs +278 -0
  30. data/core/class.rbs +223 -0
  31. data/core/comparable.rbs +192 -0
  32. data/core/complex.rbs +812 -0
  33. data/core/constants.rbs +96 -0
  34. data/core/data.rbs +415 -0
  35. data/core/dir.rbs +993 -0
  36. data/core/encoding.rbs +1368 -0
  37. data/core/enumerable.rbs +2506 -0
  38. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  39. data/core/enumerator/product.rbs +92 -0
  40. data/core/enumerator.rbs +705 -0
  41. data/core/env.rbs +6 -0
  42. data/core/errno.rbs +682 -0
  43. data/core/errors.rbs +789 -0
  44. data/core/exception.rbs +485 -0
  45. data/core/false_class.rbs +82 -0
  46. data/core/fiber.rbs +570 -0
  47. data/core/fiber_error.rbs +11 -0
  48. data/core/file.rbs +2045 -0
  49. data/core/file_constants.rbs +463 -0
  50. data/core/file_stat.rbs +534 -0
  51. data/core/file_test.rbs +331 -0
  52. data/core/float.rbs +1316 -0
  53. data/core/gc.rbs +788 -0
  54. data/core/global_variables.rbs +184 -0
  55. data/core/hash.rbs +2183 -0
  56. data/core/integer.rbs +1374 -0
  57. data/core/io/buffer.rbs +995 -0
  58. data/core/io/wait.rbs +48 -0
  59. data/core/io.rbs +3472 -0
  60. data/core/kernel.rbs +3172 -0
  61. data/core/marshal.rbs +207 -0
  62. data/core/match_data.rbs +637 -0
  63. data/core/math.rbs +770 -0
  64. data/core/method.rbs +422 -0
  65. data/core/module.rbs +1856 -0
  66. data/core/nil_class.rbs +210 -0
  67. data/core/numeric.rbs +832 -0
  68. data/core/object.rbs +108 -0
  69. data/core/object_space/weak_key_map.rbs +166 -0
  70. data/core/object_space.rbs +197 -0
  71. data/core/pathname.rbs +1322 -0
  72. data/core/proc.rbs +905 -0
  73. data/core/process.rbs +2316 -0
  74. data/core/ractor.rbs +924 -0
  75. data/core/random.rbs +255 -0
  76. data/core/range.rbs +1209 -0
  77. data/core/rational.rbs +502 -0
  78. data/core/rb_config.rbs +88 -0
  79. data/core/rbs/ops.rbs +154 -0
  80. data/core/rbs/unnamed/argf.rbs +1236 -0
  81. data/core/rbs/unnamed/env_class.rbs +1214 -0
  82. data/core/rbs/unnamed/main_class.rbs +123 -0
  83. data/core/rbs/unnamed/random.rbs +186 -0
  84. data/core/refinement.rbs +59 -0
  85. data/core/regexp.rbs +1974 -0
  86. data/core/ruby.rbs +53 -0
  87. data/core/ruby_vm.rbs +809 -0
  88. data/core/rubygems/basic_specification.rbs +6 -0
  89. data/core/rubygems/config_file.rbs +38 -0
  90. data/core/rubygems/dependency_installer.rbs +6 -0
  91. data/core/rubygems/errors.rbs +109 -0
  92. data/core/rubygems/installer.rbs +15 -0
  93. data/core/rubygems/path_support.rbs +6 -0
  94. data/core/rubygems/platform.rbs +7 -0
  95. data/core/rubygems/request_set.rbs +49 -0
  96. data/core/rubygems/requirement.rbs +148 -0
  97. data/core/rubygems/rubygems.rbs +1105 -0
  98. data/core/rubygems/source_list.rbs +15 -0
  99. data/core/rubygems/specification.rbs +23 -0
  100. data/core/rubygems/stream_ui.rbs +5 -0
  101. data/core/rubygems/uninstaller.rbs +10 -0
  102. data/core/rubygems/version.rbs +293 -0
  103. data/core/set.rbs +751 -0
  104. data/core/signal.rbs +110 -0
  105. data/core/string.rbs +5532 -0
  106. data/core/struct.rbs +668 -0
  107. data/core/symbol.rbs +482 -0
  108. data/core/thread.rbs +1826 -0
  109. data/core/thread_group.rbs +79 -0
  110. data/core/time.rbs +1793 -0
  111. data/core/trace_point.rbs +483 -0
  112. data/core/true_class.rbs +98 -0
  113. data/core/unbound_method.rbs +337 -0
  114. data/core/warning.rbs +87 -0
  115. data/docs/CONTRIBUTING.md +107 -0
  116. data/docs/aliases.md +79 -0
  117. data/docs/architecture.md +110 -0
  118. data/docs/collection.md +192 -0
  119. data/docs/config.md +171 -0
  120. data/docs/data_and_struct.md +86 -0
  121. data/docs/encoding.md +56 -0
  122. data/docs/gem.md +56 -0
  123. data/docs/inline.md +634 -0
  124. data/docs/rbs_by_example.md +309 -0
  125. data/docs/repo.md +125 -0
  126. data/docs/rust.md +96 -0
  127. data/docs/sigs.md +167 -0
  128. data/docs/stdlib.md +147 -0
  129. data/docs/syntax.md +940 -0
  130. data/docs/tools.md +17 -0
  131. data/docs/type_fingerprint.md +21 -0
  132. data/docs/wasm_serialization.md +80 -0
  133. data/exe/rbs +7 -0
  134. data/ext/rbs_extension/ast_translation.c +1855 -0
  135. data/ext/rbs_extension/ast_translation.h +41 -0
  136. data/ext/rbs_extension/class_constants.c +187 -0
  137. data/ext/rbs_extension/class_constants.h +104 -0
  138. data/ext/rbs_extension/compat.h +10 -0
  139. data/ext/rbs_extension/extconf.rb +40 -0
  140. data/ext/rbs_extension/legacy_location.c +294 -0
  141. data/ext/rbs_extension/legacy_location.h +82 -0
  142. data/ext/rbs_extension/main.c +613 -0
  143. data/ext/rbs_extension/rbs_extension.h +16 -0
  144. data/ext/rbs_extension/rbs_string_bridging.c +9 -0
  145. data/ext/rbs_extension/rbs_string_bridging.h +24 -0
  146. data/goodcheck.yml +91 -0
  147. data/include/rbs/ast.h +1047 -0
  148. data/include/rbs/defines.h +99 -0
  149. data/include/rbs/lexer.h +207 -0
  150. data/include/rbs/location.h +40 -0
  151. data/include/rbs/parser.h +153 -0
  152. data/include/rbs/serialize.h +39 -0
  153. data/include/rbs/string.h +47 -0
  154. data/include/rbs/util/rbs_allocator.h +59 -0
  155. data/include/rbs/util/rbs_assert.h +20 -0
  156. data/include/rbs/util/rbs_buffer.h +83 -0
  157. data/include/rbs/util/rbs_constant_pool.h +155 -0
  158. data/include/rbs/util/rbs_encoding.h +282 -0
  159. data/include/rbs/util/rbs_unescape.h +24 -0
  160. data/include/rbs.h +14 -0
  161. data/lib/rbs/ancestor_graph.rb +92 -0
  162. data/lib/rbs/annotate/annotations.rb +199 -0
  163. data/lib/rbs/annotate/formatter.rb +82 -0
  164. data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
  165. data/lib/rbs/annotate/rdoc_source.rb +131 -0
  166. data/lib/rbs/annotate.rb +8 -0
  167. data/lib/rbs/ast/annotation.rb +29 -0
  168. data/lib/rbs/ast/comment.rb +29 -0
  169. data/lib/rbs/ast/declarations.rb +472 -0
  170. data/lib/rbs/ast/directives.rb +49 -0
  171. data/lib/rbs/ast/members.rb +451 -0
  172. data/lib/rbs/ast/ruby/annotations.rb +451 -0
  173. data/lib/rbs/ast/ruby/comment_block.rb +247 -0
  174. data/lib/rbs/ast/ruby/declarations.rb +291 -0
  175. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +28 -0
  176. data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
  177. data/lib/rbs/ast/ruby/members.rb +762 -0
  178. data/lib/rbs/ast/type_param.rb +235 -0
  179. data/lib/rbs/ast/visitor.rb +137 -0
  180. data/lib/rbs/buffer.rb +189 -0
  181. data/lib/rbs/builtin_names.rb +58 -0
  182. data/lib/rbs/cli/colored_io.rb +48 -0
  183. data/lib/rbs/cli/diff.rb +84 -0
  184. data/lib/rbs/cli/validate.rb +294 -0
  185. data/lib/rbs/cli.rb +1253 -0
  186. data/lib/rbs/collection/cleaner.rb +38 -0
  187. data/lib/rbs/collection/config/lockfile.rb +92 -0
  188. data/lib/rbs/collection/config/lockfile_generator.rb +269 -0
  189. data/lib/rbs/collection/config.rb +81 -0
  190. data/lib/rbs/collection/installer.rb +32 -0
  191. data/lib/rbs/collection/sources/base.rb +14 -0
  192. data/lib/rbs/collection/sources/git.rb +265 -0
  193. data/lib/rbs/collection/sources/local.rb +81 -0
  194. data/lib/rbs/collection/sources/rubygems.rb +48 -0
  195. data/lib/rbs/collection/sources/stdlib.rb +50 -0
  196. data/lib/rbs/collection/sources.rb +38 -0
  197. data/lib/rbs/collection.rb +16 -0
  198. data/lib/rbs/constant.rb +28 -0
  199. data/lib/rbs/definition.rb +415 -0
  200. data/lib/rbs/definition_builder/ancestor_builder.rb +678 -0
  201. data/lib/rbs/definition_builder/method_builder.rb +295 -0
  202. data/lib/rbs/definition_builder.rb +1054 -0
  203. data/lib/rbs/diff.rb +131 -0
  204. data/lib/rbs/environment/class_entry.rb +69 -0
  205. data/lib/rbs/environment/module_entry.rb +66 -0
  206. data/lib/rbs/environment/use_map.rb +77 -0
  207. data/lib/rbs/environment.rb +1028 -0
  208. data/lib/rbs/environment_loader.rb +167 -0
  209. data/lib/rbs/environment_walker.rb +155 -0
  210. data/lib/rbs/errors.rb +634 -0
  211. data/lib/rbs/factory.rb +18 -0
  212. data/lib/rbs/file_finder.rb +28 -0
  213. data/lib/rbs/inline_parser/comment_association.rb +117 -0
  214. data/lib/rbs/inline_parser.rb +568 -0
  215. data/lib/rbs/location_aux.rb +170 -0
  216. data/lib/rbs/locator.rb +247 -0
  217. data/lib/rbs/method_type.rb +145 -0
  218. data/lib/rbs/namespace.rb +154 -0
  219. data/lib/rbs/parser/lex_result.rb +15 -0
  220. data/lib/rbs/parser/token.rb +23 -0
  221. data/lib/rbs/parser_aux.rb +142 -0
  222. data/lib/rbs/prototype/helpers.rb +197 -0
  223. data/lib/rbs/prototype/node_usage.rb +99 -0
  224. data/lib/rbs/prototype/rb.rb +816 -0
  225. data/lib/rbs/prototype/rbi.rb +625 -0
  226. data/lib/rbs/prototype/runtime/helpers.rb +59 -0
  227. data/lib/rbs/prototype/runtime/reflection.rb +19 -0
  228. data/lib/rbs/prototype/runtime/value_object_generator.rb +279 -0
  229. data/lib/rbs/prototype/runtime.rb +680 -0
  230. data/lib/rbs/repository.rb +127 -0
  231. data/lib/rbs/resolver/constant_resolver.rb +219 -0
  232. data/lib/rbs/resolver/type_name_resolver.rb +167 -0
  233. data/lib/rbs/rewriter.rb +70 -0
  234. data/lib/rbs/sorter.rb +198 -0
  235. data/lib/rbs/source.rb +99 -0
  236. data/lib/rbs/substitution.rb +83 -0
  237. data/lib/rbs/subtractor.rb +204 -0
  238. data/lib/rbs/test/errors.rb +80 -0
  239. data/lib/rbs/test/guaranteed.rb +30 -0
  240. data/lib/rbs/test/hook.rb +212 -0
  241. data/lib/rbs/test/observer.rb +19 -0
  242. data/lib/rbs/test/setup.rb +84 -0
  243. data/lib/rbs/test/setup_helper.rb +50 -0
  244. data/lib/rbs/test/tester.rb +167 -0
  245. data/lib/rbs/test/type_check.rb +457 -0
  246. data/lib/rbs/test.rb +112 -0
  247. data/lib/rbs/type_alias_dependency.rb +100 -0
  248. data/lib/rbs/type_alias_regularity.rb +126 -0
  249. data/lib/rbs/type_name.rb +122 -0
  250. data/lib/rbs/types.rb +1604 -0
  251. data/lib/rbs/unit_test/convertibles.rb +177 -0
  252. data/lib/rbs/unit_test/spy.rb +138 -0
  253. data/lib/rbs/unit_test/type_assertions.rb +383 -0
  254. data/lib/rbs/unit_test/with_aliases.rb +145 -0
  255. data/lib/rbs/unit_test.rb +6 -0
  256. data/lib/rbs/validator.rb +186 -0
  257. data/lib/rbs/variance_calculator.rb +189 -0
  258. data/lib/rbs/vendorer.rb +71 -0
  259. data/lib/rbs/version.rb +5 -0
  260. data/lib/rbs/wasm/deserializer.rb +213 -0
  261. data/lib/rbs/wasm/jars/asm-analysis.jar +0 -0
  262. data/lib/rbs/wasm/jars/asm-commons.jar +0 -0
  263. data/lib/rbs/wasm/jars/asm-tree.jar +0 -0
  264. data/lib/rbs/wasm/jars/asm-util.jar +0 -0
  265. data/lib/rbs/wasm/jars/asm.jar +0 -0
  266. data/lib/rbs/wasm/jars/compiler.jar +0 -0
  267. data/lib/rbs/wasm/jars/log.jar +0 -0
  268. data/lib/rbs/wasm/jars/runtime.jar +0 -0
  269. data/lib/rbs/wasm/jars/wasi.jar +0 -0
  270. data/lib/rbs/wasm/jars/wasm.jar +0 -0
  271. data/lib/rbs/wasm/location.rb +61 -0
  272. data/lib/rbs/wasm/parser.rb +137 -0
  273. data/lib/rbs/wasm/rbs_parser.wasm +0 -0
  274. data/lib/rbs/wasm/runtime.rb +217 -0
  275. data/lib/rbs/wasm/serialization_schema.rb +110 -0
  276. data/lib/rbs/writer.rb +424 -0
  277. data/lib/rbs.rb +117 -0
  278. data/lib/rdoc/discover.rb +20 -0
  279. data/lib/rdoc_plugin/parser.rb +163 -0
  280. data/rbs.gemspec +68 -0
  281. data/schema/annotation.json +14 -0
  282. data/schema/comment.json +26 -0
  283. data/schema/decls.json +326 -0
  284. data/schema/function.json +87 -0
  285. data/schema/location.json +56 -0
  286. data/schema/members.json +266 -0
  287. data/schema/methodType.json +50 -0
  288. data/schema/typeParam.json +52 -0
  289. data/schema/types.json +317 -0
  290. data/sig/ancestor_builder.rbs +163 -0
  291. data/sig/ancestor_graph.rbs +60 -0
  292. data/sig/annotate/annotations.rbs +102 -0
  293. data/sig/annotate/formatter.rbs +24 -0
  294. data/sig/annotate/rdoc_annotater.rbs +85 -0
  295. data/sig/annotate/rdoc_source.rbs +32 -0
  296. data/sig/annotation.rbs +27 -0
  297. data/sig/ast/ruby/annotations.rbs +470 -0
  298. data/sig/ast/ruby/comment_block.rbs +127 -0
  299. data/sig/ast/ruby/declarations.rbs +158 -0
  300. data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
  301. data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
  302. data/sig/ast/ruby/members.rbs +198 -0
  303. data/sig/buffer.rbs +108 -0
  304. data/sig/builtin_names.rbs +44 -0
  305. data/sig/cli/colored_io.rbs +15 -0
  306. data/sig/cli/diff.rbs +15 -0
  307. data/sig/cli/validate.rbs +47 -0
  308. data/sig/cli.rbs +89 -0
  309. data/sig/collection/cleaner.rbs +13 -0
  310. data/sig/collection/config/lockfile.rbs +74 -0
  311. data/sig/collection/config/lockfile_generator.rbs +68 -0
  312. data/sig/collection/config.rbs +46 -0
  313. data/sig/collection/installer.rbs +17 -0
  314. data/sig/collection/sources.rbs +214 -0
  315. data/sig/collection.rbs +4 -0
  316. data/sig/comment.rbs +26 -0
  317. data/sig/constant.rbs +21 -0
  318. data/sig/declarations.rbs +274 -0
  319. data/sig/definition.rbs +232 -0
  320. data/sig/definition_builder.rbs +181 -0
  321. data/sig/diff.rbs +28 -0
  322. data/sig/directives.rbs +77 -0
  323. data/sig/environment/class_entry.rbs +50 -0
  324. data/sig/environment/module_entry.rbs +50 -0
  325. data/sig/environment.rbs +286 -0
  326. data/sig/environment_loader.rbs +111 -0
  327. data/sig/environment_walker.rbs +65 -0
  328. data/sig/errors.rbs +408 -0
  329. data/sig/factory.rbs +5 -0
  330. data/sig/file_finder.rbs +28 -0
  331. data/sig/inline_parser/comment_association.rbs +71 -0
  332. data/sig/inline_parser.rbs +126 -0
  333. data/sig/location.rbs +135 -0
  334. data/sig/locator.rbs +56 -0
  335. data/sig/manifest.yaml +5 -0
  336. data/sig/members.rbs +258 -0
  337. data/sig/method_builder.rbs +89 -0
  338. data/sig/method_types.rbs +58 -0
  339. data/sig/namespace.rbs +161 -0
  340. data/sig/parser.rbs +164 -0
  341. data/sig/prototype/helpers.rbs +29 -0
  342. data/sig/prototype/node_usage.rbs +20 -0
  343. data/sig/prototype/rb.rbs +96 -0
  344. data/sig/prototype/rbi.rbs +75 -0
  345. data/sig/prototype/runtime.rbs +182 -0
  346. data/sig/rbs.rbs +21 -0
  347. data/sig/rdoc/rbs.rbs +67 -0
  348. data/sig/repository.rbs +85 -0
  349. data/sig/resolver/constant_resolver.rbs +92 -0
  350. data/sig/resolver/context.rbs +34 -0
  351. data/sig/resolver/type_name_resolver.rbs +61 -0
  352. data/sig/rewriter.rbs +45 -0
  353. data/sig/shims/bundler.rbs +38 -0
  354. data/sig/shims/enumerable.rbs +5 -0
  355. data/sig/shims/rubygems.rbs +19 -0
  356. data/sig/sorter.rbs +41 -0
  357. data/sig/source.rbs +48 -0
  358. data/sig/substitution.rbs +48 -0
  359. data/sig/subtractor.rbs +37 -0
  360. data/sig/test/errors.rbs +52 -0
  361. data/sig/test/guranteed.rbs +9 -0
  362. data/sig/test/type_check.rbs +19 -0
  363. data/sig/test.rbs +82 -0
  364. data/sig/type_alias_dependency.rbs +53 -0
  365. data/sig/type_alias_regularity.rbs +98 -0
  366. data/sig/type_param.rbs +115 -0
  367. data/sig/typename.rbs +89 -0
  368. data/sig/types.rbs +578 -0
  369. data/sig/unit_test/convertibles.rbs +154 -0
  370. data/sig/unit_test/spy.rbs +22 -0
  371. data/sig/unit_test/type_assertions.rbs +211 -0
  372. data/sig/unit_test/with_aliases.rbs +136 -0
  373. data/sig/use_map.rbs +35 -0
  374. data/sig/util.rbs +9 -0
  375. data/sig/validator.rbs +63 -0
  376. data/sig/variance_calculator.rbs +87 -0
  377. data/sig/vendorer.rbs +51 -0
  378. data/sig/version.rbs +3 -0
  379. data/sig/visitor.rbs +47 -0
  380. data/sig/wasm/deserializer.rbs +66 -0
  381. data/sig/wasm/serialization_schema.rbs +13 -0
  382. data/sig/writer.rbs +127 -0
  383. data/src/ast.c +1628 -0
  384. data/src/lexer.c +3217 -0
  385. data/src/lexer.re +155 -0
  386. data/src/lexstate.c +217 -0
  387. data/src/location.c +31 -0
  388. data/src/parser.c +4255 -0
  389. data/src/serialize.c +958 -0
  390. data/src/string.c +41 -0
  391. data/src/util/rbs_allocator.c +162 -0
  392. data/src/util/rbs_assert.c +19 -0
  393. data/src/util/rbs_buffer.c +54 -0
  394. data/src/util/rbs_constant_pool.c +268 -0
  395. data/src/util/rbs_encoding.c +21308 -0
  396. data/src/util/rbs_unescape.c +167 -0
  397. data/stdlib/abbrev/0/abbrev.rbs +66 -0
  398. data/stdlib/abbrev/0/array.rbs +26 -0
  399. data/stdlib/base64/0/base64.rbs +355 -0
  400. data/stdlib/benchmark/0/benchmark.rbs +452 -0
  401. data/stdlib/bigdecimal/0/big_decimal.rbs +1647 -0
  402. data/stdlib/bigdecimal-math/0/big_math.rbs +280 -0
  403. data/stdlib/bigdecimal-math/0/manifest.yaml +2 -0
  404. data/stdlib/cgi/0/core.rbs +911 -0
  405. data/stdlib/cgi/0/manifest.yaml +4 -0
  406. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  407. data/stdlib/coverage/0/coverage.rbs +266 -0
  408. data/stdlib/csv/0/csv.rbs +3776 -0
  409. data/stdlib/csv/0/manifest.yaml +3 -0
  410. data/stdlib/date/0/date.rbs +1598 -0
  411. data/stdlib/date/0/date_time.rbs +617 -0
  412. data/stdlib/date/0/time.rbs +26 -0
  413. data/stdlib/dbm/0/dbm.rbs +421 -0
  414. data/stdlib/delegate/0/delegator.rbs +187 -0
  415. data/stdlib/delegate/0/kernel.rbs +47 -0
  416. data/stdlib/delegate/0/simple_delegator.rbs +96 -0
  417. data/stdlib/did_you_mean/0/did_you_mean.rbs +344 -0
  418. data/stdlib/digest/0/digest.rbs +687 -0
  419. data/stdlib/erb/0/erb.rbs +933 -0
  420. data/stdlib/etc/0/etc.rbs +884 -0
  421. data/stdlib/fileutils/0/fileutils.rbs +1753 -0
  422. data/stdlib/find/0/find.rbs +49 -0
  423. data/stdlib/forwardable/0/forwardable.rbs +271 -0
  424. data/stdlib/io-console/0/io-console.rbs +414 -0
  425. data/stdlib/ipaddr/0/ipaddr.rbs +436 -0
  426. data/stdlib/json/0/json.rbs +1963 -0
  427. data/stdlib/kconv/0/kconv.rbs +166 -0
  428. data/stdlib/logger/0/formatter.rbs +45 -0
  429. data/stdlib/logger/0/log_device.rbs +100 -0
  430. data/stdlib/logger/0/logger.rbs +796 -0
  431. data/stdlib/logger/0/manifest.yaml +2 -0
  432. data/stdlib/logger/0/period.rbs +17 -0
  433. data/stdlib/logger/0/severity.rbs +34 -0
  434. data/stdlib/minitest/0/kernel.rbs +42 -0
  435. data/stdlib/minitest/0/minitest/abstract_reporter.rbs +52 -0
  436. data/stdlib/minitest/0/minitest/assertion.rbs +17 -0
  437. data/stdlib/minitest/0/minitest/assertions.rbs +590 -0
  438. data/stdlib/minitest/0/minitest/backtrace_filter.rbs +23 -0
  439. data/stdlib/minitest/0/minitest/bench_spec.rbs +102 -0
  440. data/stdlib/minitest/0/minitest/benchmark.rbs +259 -0
  441. data/stdlib/minitest/0/minitest/composite_reporter.rbs +25 -0
  442. data/stdlib/minitest/0/minitest/compress.rbs +13 -0
  443. data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
  444. data/stdlib/minitest/0/minitest/expectation.rbs +2 -0
  445. data/stdlib/minitest/0/minitest/expectations.rbs +21 -0
  446. data/stdlib/minitest/0/minitest/guard.rbs +64 -0
  447. data/stdlib/minitest/0/minitest/mock.rbs +64 -0
  448. data/stdlib/minitest/0/minitest/parallel/executor.rbs +46 -0
  449. data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +5 -0
  450. data/stdlib/minitest/0/minitest/parallel/test.rbs +3 -0
  451. data/stdlib/minitest/0/minitest/parallel.rbs +2 -0
  452. data/stdlib/minitest/0/minitest/pride_io.rbs +62 -0
  453. data/stdlib/minitest/0/minitest/pride_lol.rbs +19 -0
  454. data/stdlib/minitest/0/minitest/progress_reporter.rbs +11 -0
  455. data/stdlib/minitest/0/minitest/reportable.rbs +53 -0
  456. data/stdlib/minitest/0/minitest/reporter.rbs +5 -0
  457. data/stdlib/minitest/0/minitest/result.rbs +28 -0
  458. data/stdlib/minitest/0/minitest/runnable.rbs +163 -0
  459. data/stdlib/minitest/0/minitest/skip.rbs +6 -0
  460. data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +48 -0
  461. data/stdlib/minitest/0/minitest/spec/dsl.rbs +129 -0
  462. data/stdlib/minitest/0/minitest/spec.rbs +11 -0
  463. data/stdlib/minitest/0/minitest/statistics_reporter.rbs +81 -0
  464. data/stdlib/minitest/0/minitest/summary_reporter.rbs +18 -0
  465. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +92 -0
  466. data/stdlib/minitest/0/minitest/test.rbs +69 -0
  467. data/stdlib/minitest/0/minitest/unexpected_error.rbs +12 -0
  468. data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
  469. data/stdlib/minitest/0/minitest/unit/test_case.rbs +3 -0
  470. data/stdlib/minitest/0/minitest/unit.rbs +4 -0
  471. data/stdlib/minitest/0/minitest.rbs +115 -0
  472. data/stdlib/monitor/0/monitor.rbs +363 -0
  473. data/stdlib/mutex_m/0/mutex_m.rbs +104 -0
  474. data/stdlib/net-http/0/manifest.yaml +3 -0
  475. data/stdlib/net-http/0/net-http.rbs +5580 -0
  476. data/stdlib/net-protocol/0/manifest.yaml +2 -0
  477. data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
  478. data/stdlib/net-smtp/0/manifest.yaml +2 -0
  479. data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
  480. data/stdlib/nkf/0/nkf.rbs +402 -0
  481. data/stdlib/objspace/0/objspace.rbs +470 -0
  482. data/stdlib/observable/0/observable.rbs +217 -0
  483. data/stdlib/open-uri/0/manifest.yaml +4 -0
  484. data/stdlib/open-uri/0/open-uri.rbs +433 -0
  485. data/stdlib/open3/0/open3.rbs +606 -0
  486. data/stdlib/openssl/0/manifest.yaml +3 -0
  487. data/stdlib/openssl/0/openssl.rbs +12231 -0
  488. data/stdlib/optparse/0/optparse.rbs +1734 -0
  489. data/stdlib/pathname/0/pathname.rbs +36 -0
  490. data/stdlib/pp/0/manifest.yaml +2 -0
  491. data/stdlib/pp/0/pp.rbs +301 -0
  492. data/stdlib/prettyprint/0/prettyprint.rbs +383 -0
  493. data/stdlib/pstore/0/pstore.rbs +608 -0
  494. data/stdlib/psych/0/core_ext.rbs +12 -0
  495. data/stdlib/psych/0/dbm.rbs +237 -0
  496. data/stdlib/psych/0/manifest.yaml +3 -0
  497. data/stdlib/psych/0/psych.rbs +455 -0
  498. data/stdlib/psych/0/store.rbs +57 -0
  499. data/stdlib/pty/0/pty.rbs +240 -0
  500. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  501. data/stdlib/rdoc/0/code_object.rbs +52 -0
  502. data/stdlib/rdoc/0/comment.rbs +61 -0
  503. data/stdlib/rdoc/0/context.rbs +153 -0
  504. data/stdlib/rdoc/0/markup.rbs +117 -0
  505. data/stdlib/rdoc/0/options.rbs +76 -0
  506. data/stdlib/rdoc/0/parser.rbs +56 -0
  507. data/stdlib/rdoc/0/rdoc.rbs +393 -0
  508. data/stdlib/rdoc/0/ri.rbs +17 -0
  509. data/stdlib/rdoc/0/store.rbs +48 -0
  510. data/stdlib/rdoc/0/top_level.rbs +97 -0
  511. data/stdlib/resolv/0/manifest.yaml +3 -0
  512. data/stdlib/resolv/0/resolv.rbs +1787 -0
  513. data/stdlib/ripper/0/ripper.rbs +1654 -0
  514. data/stdlib/securerandom/0/manifest.yaml +2 -0
  515. data/stdlib/securerandom/0/securerandom.rbs +49 -0
  516. data/stdlib/shellwords/0/shellwords.rbs +229 -0
  517. data/stdlib/singleton/0/singleton.rbs +134 -0
  518. data/stdlib/socket/0/addrinfo.rbs +666 -0
  519. data/stdlib/socket/0/basic_socket.rbs +590 -0
  520. data/stdlib/socket/0/constants.rbs +2295 -0
  521. data/stdlib/socket/0/ip_socket.rbs +94 -0
  522. data/stdlib/socket/0/socket.rbs +4170 -0
  523. data/stdlib/socket/0/socket_error.rbs +5 -0
  524. data/stdlib/socket/0/tcp_server.rbs +192 -0
  525. data/stdlib/socket/0/tcp_socket.rbs +87 -0
  526. data/stdlib/socket/0/udp_socket.rbs +133 -0
  527. data/stdlib/socket/0/unix_server.rbs +169 -0
  528. data/stdlib/socket/0/unix_socket.rbs +172 -0
  529. data/stdlib/stringio/0/stringio.rbs +1681 -0
  530. data/stdlib/strscan/0/string_scanner.rbs +1648 -0
  531. data/stdlib/tempfile/0/tempfile.rbs +483 -0
  532. data/stdlib/time/0/time.rbs +434 -0
  533. data/stdlib/timeout/0/timeout.rbs +137 -0
  534. data/stdlib/tmpdir/0/tmpdir.rbs +69 -0
  535. data/stdlib/tsort/0/cyclic.rbs +8 -0
  536. data/stdlib/tsort/0/interfaces.rbs +20 -0
  537. data/stdlib/tsort/0/tsort.rbs +410 -0
  538. data/stdlib/uri/0/common.rbs +621 -0
  539. data/stdlib/uri/0/file.rbs +118 -0
  540. data/stdlib/uri/0/ftp.rbs +13 -0
  541. data/stdlib/uri/0/generic.rbs +1116 -0
  542. data/stdlib/uri/0/http.rbs +104 -0
  543. data/stdlib/uri/0/https.rbs +14 -0
  544. data/stdlib/uri/0/ldap.rbs +230 -0
  545. data/stdlib/uri/0/ldaps.rbs +14 -0
  546. data/stdlib/uri/0/mailto.rbs +92 -0
  547. data/stdlib/uri/0/rfc2396_parser.rbs +189 -0
  548. data/stdlib/uri/0/rfc3986_parser.rbs +2 -0
  549. data/stdlib/uri/0/ws.rbs +13 -0
  550. data/stdlib/uri/0/wss.rbs +9 -0
  551. data/stdlib/yaml/0/manifest.yaml +2 -0
  552. data/stdlib/yaml/0/yaml.rbs +1 -0
  553. data/stdlib/zlib/0/buf_error.rbs +10 -0
  554. data/stdlib/zlib/0/data_error.rbs +10 -0
  555. data/stdlib/zlib/0/deflate.rbs +211 -0
  556. data/stdlib/zlib/0/error.rbs +20 -0
  557. data/stdlib/zlib/0/gzip_file/crc_error.rbs +12 -0
  558. data/stdlib/zlib/0/gzip_file/error.rbs +23 -0
  559. data/stdlib/zlib/0/gzip_file/length_error.rbs +12 -0
  560. data/stdlib/zlib/0/gzip_file/no_footer.rbs +11 -0
  561. data/stdlib/zlib/0/gzip_file.rbs +156 -0
  562. data/stdlib/zlib/0/gzip_reader.rbs +293 -0
  563. data/stdlib/zlib/0/gzip_writer.rbs +168 -0
  564. data/stdlib/zlib/0/inflate.rbs +180 -0
  565. data/stdlib/zlib/0/mem_error.rbs +10 -0
  566. data/stdlib/zlib/0/need_dict.rbs +13 -0
  567. data/stdlib/zlib/0/stream_end.rbs +11 -0
  568. data/stdlib/zlib/0/stream_error.rbs +11 -0
  569. data/stdlib/zlib/0/version_error.rbs +11 -0
  570. data/stdlib/zlib/0/zlib.rbs +449 -0
  571. data/stdlib/zlib/0/zstream.rbs +201 -0
  572. data/wasm/README.md +59 -0
  573. data/wasm/rbs_wasm.c +411 -0
  574. metadata +660 -0
data/core/proc.rbs ADDED
@@ -0,0 +1,905 @@
1
+ # <!-- rdoc-file=proc.c -->
2
+ # A `Proc` object is an encapsulation of a block of code, which can be stored in
3
+ # a local variable, passed to a method or another Proc, and can be called. Proc
4
+ # is an essential concept in Ruby and a core of its functional programming
5
+ # features.
6
+ #
7
+ # square = Proc.new {|x| x**2 }
8
+ #
9
+ # square.call(3) #=> 9
10
+ # # shorthands:
11
+ # square.(3) #=> 9
12
+ # square[3] #=> 9
13
+ #
14
+ # Proc objects are *closures*, meaning they remember and can use the entire
15
+ # context in which they were created.
16
+ #
17
+ # def gen_times(factor)
18
+ # Proc.new {|n| n*factor } # remembers the value of factor at the moment of creation
19
+ # end
20
+ #
21
+ # times3 = gen_times(3)
22
+ # times5 = gen_times(5)
23
+ #
24
+ # times3.call(12) #=> 36
25
+ # times5.call(5) #=> 25
26
+ # times3.call(times5.call(4)) #=> 60
27
+ #
28
+ # ## Creation
29
+ #
30
+ # There are several methods to create a Proc
31
+ #
32
+ # * Use the Proc class constructor:
33
+ #
34
+ # proc1 = Proc.new {|x| x**2 }
35
+ #
36
+ # * Use the Kernel#proc method as a shorthand of Proc.new:
37
+ #
38
+ # proc2 = proc {|x| x**2 }
39
+ #
40
+ # * Receiving a block of code into proc argument (note the <code>&</code>):
41
+ #
42
+ # def make_proc(&block)
43
+ # block
44
+ # end
45
+ #
46
+ # proc3 = make_proc {|x| x**2 }
47
+ #
48
+ # * Construct a proc with lambda semantics using the Kernel#lambda method (see
49
+ # below for explanations about lambdas):
50
+ #
51
+ # lambda1 = lambda {|x| x**2 }
52
+ #
53
+ # * Use the [Lambda proc
54
+ # literal](rdoc-ref:syntax/literals.rdoc@Lambda+Proc+Literals) syntax (also
55
+ # constructs a proc with lambda semantics):
56
+ #
57
+ # lambda2 = ->(x) { x**2 }
58
+ #
59
+ # ## Lambda and non-lambda semantics
60
+ #
61
+ # Procs are coming in two flavors: lambda and non-lambda (regular procs).
62
+ # Differences are:
63
+ #
64
+ # * In lambdas, `return` and `break` means exit from this lambda;
65
+ # * In non-lambda procs, `return` means exit from embracing method (and will
66
+ # throw `LocalJumpError` if invoked outside the method);
67
+ # * In non-lambda procs, `break` means exit from the method which the block
68
+ # given for. (and will throw `LocalJumpError` if invoked after the method
69
+ # returns);
70
+ # * In lambdas, arguments are treated in the same way as in methods: strict,
71
+ # with `ArgumentError` for mismatching argument number, and no additional
72
+ # argument processing;
73
+ # * Regular procs accept arguments more generously: missing arguments are
74
+ # filled with `nil`, single Array arguments are deconstructed if the proc
75
+ # has multiple arguments, and there is no error raised on extra arguments.
76
+ #
77
+ # Examples:
78
+ #
79
+ # # +return+ in non-lambda proc, +b+, exits +m2+.
80
+ # # (The block +{ return }+ is given for +m1+ and embraced by +m2+.)
81
+ # $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1 { return }; $a << :m2 end; m2; p $a
82
+ # #=> []
83
+ #
84
+ # # +break+ in non-lambda proc, +b+, exits +m1+.
85
+ # # (The block +{ break }+ is given for +m1+ and embraced by +m2+.)
86
+ # $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1 { break }; $a << :m2 end; m2; p $a
87
+ # #=> [:m2]
88
+ #
89
+ # # +next+ in non-lambda proc, +b+, exits the block.
90
+ # # (The block +{ next }+ is given for +m1+ and embraced by +m2+.)
91
+ # $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1 { next }; $a << :m2 end; m2; p $a
92
+ # #=> [:m1, :m2]
93
+ #
94
+ # # Using +proc+ method changes the behavior as follows because
95
+ # # The block is given for +proc+ method and embraced by +m2+.
96
+ # $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { return }); $a << :m2 end; m2; p $a
97
+ # #=> []
98
+ # $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { break }); $a << :m2 end; m2; p $a
99
+ # # break from proc-closure (LocalJumpError)
100
+ # $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { next }); $a << :m2 end; m2; p $a
101
+ # #=> [:m1, :m2]
102
+ #
103
+ # # +return+, +break+ and +next+ in the stubby lambda exits the block.
104
+ # # (+lambda+ method behaves same.)
105
+ # # (The block is given for stubby lambda syntax and embraced by +m2+.)
106
+ # $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { return }); $a << :m2 end; m2; p $a
107
+ # #=> [:m1, :m2]
108
+ # $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { break }); $a << :m2 end; m2; p $a
109
+ # #=> [:m1, :m2]
110
+ # $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { next }); $a << :m2 end; m2; p $a
111
+ # #=> [:m1, :m2]
112
+ #
113
+ # p = proc {|x, y| "x=#{x}, y=#{y}" }
114
+ # p.call(1, 2) #=> "x=1, y=2"
115
+ # p.call([1, 2]) #=> "x=1, y=2", array deconstructed
116
+ # p.call(1, 2, 8) #=> "x=1, y=2", extra argument discarded
117
+ # p.call(1) #=> "x=1, y=", nil substituted instead of error
118
+ #
119
+ # l = lambda {|x, y| "x=#{x}, y=#{y}" }
120
+ # l.call(1, 2) #=> "x=1, y=2"
121
+ # l.call([1, 2]) # ArgumentError: wrong number of arguments (given 1, expected 2)
122
+ # l.call(1, 2, 8) # ArgumentError: wrong number of arguments (given 3, expected 2)
123
+ # l.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2)
124
+ #
125
+ # def test_return
126
+ # -> { return 3 }.call # just returns from lambda into method body
127
+ # proc { return 4 }.call # returns from method
128
+ # return 5
129
+ # end
130
+ #
131
+ # test_return # => 4, return from proc
132
+ #
133
+ # Lambdas are useful as self-sufficient functions, in particular useful as
134
+ # arguments to higher-order functions, behaving exactly like Ruby methods.
135
+ #
136
+ # Procs are useful for implementing iterators:
137
+ #
138
+ # def test
139
+ # [[1, 2], [3, 4], [5, 6]].map {|a, b| return a if a + b > 10 }
140
+ # # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
141
+ # end
142
+ #
143
+ # Inside `map`, the block of code is treated as a regular (non-lambda) proc,
144
+ # which means that the internal arrays will be deconstructed to pairs of
145
+ # arguments, and `return` will exit from the method `test`. That would not be
146
+ # possible with a stricter lambda.
147
+ #
148
+ # You can tell a lambda from a regular proc by using the #lambda? instance
149
+ # method.
150
+ #
151
+ # Lambda semantics is typically preserved during the proc lifetime, including
152
+ # <code>&</code>-deconstruction to a block of code:
153
+ #
154
+ # p = proc {|x, y| x }
155
+ # l = lambda {|x, y| x }
156
+ # [[1, 2], [3, 4]].map(&p) #=> [1, 3]
157
+ # [[1, 2], [3, 4]].map(&l) # ArgumentError: wrong number of arguments (given 1, expected 2)
158
+ #
159
+ # The only exception is dynamic method definition: even if defined by passing a
160
+ # non-lambda proc, methods still have normal semantics of argument checking.
161
+ #
162
+ # class C
163
+ # define_method(:e, &proc {})
164
+ # end
165
+ # C.new.e(1,2) #=> ArgumentError
166
+ # C.new.method(:e).to_proc.lambda? #=> true
167
+ #
168
+ # This exception ensures that methods never have unusual argument passing
169
+ # conventions, and makes it easy to have wrappers defining methods that behave
170
+ # as usual.
171
+ #
172
+ # class C
173
+ # def self.def2(name, &body)
174
+ # define_method(name, &body)
175
+ # end
176
+ #
177
+ # def2(:f) {}
178
+ # end
179
+ # C.new.f(1,2) #=> ArgumentError
180
+ #
181
+ # The wrapper `def2` receives *body* as a non-lambda proc, yet defines a method
182
+ # which has normal semantics.
183
+ #
184
+ # ## Conversion of other objects to procs
185
+ #
186
+ # Any object that implements the `to_proc` method can be converted into a proc
187
+ # by the <code>&</code> operator, and therefore can be consumed by iterators.
188
+ #
189
+ # class Greeter
190
+ # def initialize(greeting)
191
+ # @greeting = greeting
192
+ # end
193
+ #
194
+ # def to_proc
195
+ # proc {|name| "#{@greeting}, #{name}!" }
196
+ # end
197
+ # end
198
+ #
199
+ # hi = Greeter.new("Hi")
200
+ # hey = Greeter.new("Hey")
201
+ # ["Bob", "Jane"].map(&hi) #=> ["Hi, Bob!", "Hi, Jane!"]
202
+ # ["Bob", "Jane"].map(&hey) #=> ["Hey, Bob!", "Hey, Jane!"]
203
+ #
204
+ # Of the Ruby core classes, this method is implemented by `Symbol`, `Method`,
205
+ # and `Hash`.
206
+ #
207
+ # :to_s.to_proc.call(1) #=> "1"
208
+ # [1, 2].map(&:to_s) #=> ["1", "2"]
209
+ #
210
+ # method(:puts).to_proc.call(1) # prints 1
211
+ # [1, 2].each(&method(:puts)) # prints 1, 2
212
+ #
213
+ # {test: 1}.to_proc.call(:test) #=> 1
214
+ # %i[test many keys].map(&{test: 1}) #=> [1, nil, nil]
215
+ #
216
+ # ## Orphaned Proc
217
+ #
218
+ # `return` and `break` in a block exit a method. If a Proc object is generated
219
+ # from the block and the Proc object survives until the method is returned,
220
+ # `return` and `break` cannot work. In such case, `return` and `break` raises
221
+ # LocalJumpError. A Proc object in such situation is called as orphaned Proc
222
+ # object.
223
+ #
224
+ # Note that the method to exit is different for `return` and `break`. There is a
225
+ # situation that orphaned for `break` but not orphaned for `return`.
226
+ #
227
+ # def m1(&b) b.call end; def m2(); m1 { return } end; m2 # ok
228
+ # def m1(&b) b.call end; def m2(); m1 { break } end; m2 # ok
229
+ #
230
+ # def m1(&b) b end; def m2(); m1 { return }.call end; m2 # ok
231
+ # def m1(&b) b end; def m2(); m1 { break }.call end; m2 # LocalJumpError
232
+ #
233
+ # def m1(&b) b end; def m2(); m1 { return } end; m2.call # LocalJumpError
234
+ # def m1(&b) b end; def m2(); m1 { break } end; m2.call # LocalJumpError
235
+ #
236
+ # Since `return` and `break` exits the block itself in lambdas, lambdas cannot
237
+ # be orphaned.
238
+ #
239
+ # ## Anonymous block parameters
240
+ #
241
+ # To simplify writing short blocks, Ruby provides two different types of
242
+ # anonymous parameters: `it` (single parameter) and numbered ones: `_1`, `_2`
243
+ # and so on.
244
+ #
245
+ # # Explicit parameter:
246
+ # %w[test me please].each { |str| puts str.upcase } # prints TEST, ME, PLEASE
247
+ # (1..5).map { |i| i**2 } # => [1, 4, 9, 16, 25]
248
+ #
249
+ # # it:
250
+ # %w[test me please].each { puts it.upcase } # prints TEST, ME, PLEASE
251
+ # (1..5).map { it**2 } # => [1, 4, 9, 16, 25]
252
+ #
253
+ # # Numbered parameter:
254
+ # %w[test me please].each { puts _1.upcase } # prints TEST, ME, PLEASE
255
+ # (1..5).map { _1**2 } # => [1, 4, 9, 16, 25]
256
+ #
257
+ # ### `it`
258
+ #
259
+ # `it` is a name that is available inside a block when no explicit parameters
260
+ # defined, as shown above.
261
+ #
262
+ # %w[test me please].each { puts it.upcase } # prints TEST, ME, PLEASE
263
+ # (1..5).map { it**2 } # => [1, 4, 9, 16, 25]
264
+ #
265
+ # `it` is a "soft keyword": it is not a reserved name, and can be used as a name
266
+ # for methods and local variables:
267
+ #
268
+ # it = 5 # no warnings
269
+ # def it(&block) # RSpec-like API, no warnings
270
+ # # ...
271
+ # end
272
+ #
273
+ # `it` can be used as a local variable even in blocks that use it as an implicit
274
+ # parameter (though this style is obviously confusing):
275
+ #
276
+ # [1, 2, 3].each {
277
+ # # takes a value of implicit parameter "it" and uses it to
278
+ # # define a local variable with the same name
279
+ # it = it**2
280
+ # p it
281
+ # }
282
+ #
283
+ # In a block with explicit parameters defined `it` usage raises an exception:
284
+ #
285
+ # [1, 2, 3].each { |x| p it }
286
+ # # syntax error found (SyntaxError)
287
+ # # [1, 2, 3].each { |x| p it }
288
+ # # ^~ 'it' is not allowed when an ordinary parameter is defined
289
+ #
290
+ # But if a local name (variable or method) is available, it would be used:
291
+ #
292
+ # it = 5
293
+ # [1, 2, 3].each { |x| p it }
294
+ # # Prints 5, 5, 5
295
+ #
296
+ # Blocks using `it` can be nested:
297
+ #
298
+ # %w[test me].each { it.each_char { p it } }
299
+ # # Prints "t", "e", "s", "t", "m", "e"
300
+ #
301
+ # Blocks using `it` are considered to have one parameter:
302
+ #
303
+ # p = proc { it**2 }
304
+ # l = lambda { it**2 }
305
+ # p.parameters # => [[:opt]]
306
+ # p.arity # => 1
307
+ # l.parameters # => [[:req]]
308
+ # l.arity # => 1
309
+ #
310
+ # ### Numbered parameters
311
+ #
312
+ # Numbered parameters are another way to name block parameters implicitly.
313
+ # Unlike `it`, numbered parameters allow to refer to several parameters in one
314
+ # block.
315
+ #
316
+ # %w[test me please].each { puts _1.upcase } # prints TEST, ME, PLEASE
317
+ # {a: 100, b: 200}.map { "#{_1} = #{_2}" } # => "a = 100", "b = 200"
318
+ #
319
+ # Parameter names from `_1` to `_9` are supported:
320
+ #
321
+ # [10, 20, 30].zip([40, 50, 60], [70, 80, 90]).map { _1 + _2 + _3 }
322
+ # # => [120, 150, 180]
323
+ #
324
+ # Though, it is advised to resort to them wisely, probably limiting yourself to
325
+ # `_1` and `_2`, and to one-line blocks.
326
+ #
327
+ # Numbered parameters can't be used together with explicitly named ones:
328
+ #
329
+ # [10, 20, 30].map { |x| _1**2 }
330
+ # # SyntaxError (ordinary parameter is defined)
331
+ #
332
+ # Numbered parameters can't be mixed with `it` either:
333
+ #
334
+ # [10, 20, 30].map { _1 + it }
335
+ # # SyntaxError: 'it' is not allowed when a numbered parameter is already used
336
+ #
337
+ # To avoid conflicts, naming local variables or method arguments `_1`, `_2` and
338
+ # so on, causes an error.
339
+ #
340
+ # _1 = 'test'
341
+ # # ^~ _1 is reserved for numbered parameters (SyntaxError)
342
+ #
343
+ # Using implicit numbered parameters affects block's arity:
344
+ #
345
+ # p = proc { _1 + _2 }
346
+ # l = lambda { _1 + _2 }
347
+ # p.parameters # => [[:opt, :_1], [:opt, :_2]]
348
+ # p.arity # => 2
349
+ # l.parameters # => [[:req, :_1], [:req, :_2]]
350
+ # l.arity # => 2
351
+ #
352
+ # Blocks with numbered parameters can't be nested:
353
+ #
354
+ # %w[test me].each { _1.each_char { p _1 } }
355
+ # # numbered parameter is already used in outer block (SyntaxError)
356
+ # # %w[test me].each { _1.each_char { p _1 } }
357
+ # # ^~
358
+ #
359
+ class Proc
360
+ interface _Callable
361
+ def call: (?) -> untyped
362
+ end
363
+
364
+ # <!--
365
+ # rdoc-file=proc.c
366
+ # - Proc.new {|...| block } -> a_proc
367
+ # -->
368
+ # Creates a new Proc object, bound to the current context.
369
+ #
370
+ # proc = Proc.new { "hello" }
371
+ # proc.call #=> "hello"
372
+ #
373
+ # Raises ArgumentError if called without a block.
374
+ #
375
+ # Proc.new #=> ArgumentError
376
+ #
377
+ def self.new: () { (?) -> untyped } -> instance
378
+
379
+ def clone: () -> self
380
+
381
+ # <!-- rdoc-file=proc.c -->
382
+ # Invokes the block, setting the block's parameters to the arguments using
383
+ # something close to method calling semantics. Returns the value of the last
384
+ # expression evaluated in the block.
385
+ #
386
+ # a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } }
387
+ # a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
388
+ # a_proc[9, 1, 2, 3] #=> [9, 18, 27]
389
+ # a_proc.(9, 1, 2, 3) #=> [9, 18, 27]
390
+ # a_proc.yield(9, 1, 2, 3) #=> [9, 18, 27]
391
+ #
392
+ # Note that <code>prc.()</code> invokes <code>prc.call()</code> with the
393
+ # parameters given. It's syntactic sugar to hide "call".
394
+ #
395
+ # For procs created using #lambda or <code>->()</code> an error is generated if
396
+ # the wrong number of parameters are passed to the proc. For procs created
397
+ # using Proc.new or Kernel.proc, extra parameters are silently discarded and
398
+ # missing parameters are set to `nil`.
399
+ #
400
+ # a_proc = proc {|a,b| [a,b] }
401
+ # a_proc.call(1) #=> [1, nil]
402
+ #
403
+ # a_proc = lambda {|a,b| [a,b] }
404
+ # a_proc.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2)
405
+ #
406
+ # See also Proc#lambda?.
407
+ #
408
+ alias === call
409
+
410
+ # <!-- rdoc-file=proc.c -->
411
+ # Invokes the block, setting the block's parameters to the arguments using
412
+ # something close to method calling semantics. Returns the value of the last
413
+ # expression evaluated in the block.
414
+ #
415
+ # a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } }
416
+ # a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
417
+ # a_proc[9, 1, 2, 3] #=> [9, 18, 27]
418
+ # a_proc.(9, 1, 2, 3) #=> [9, 18, 27]
419
+ # a_proc.yield(9, 1, 2, 3) #=> [9, 18, 27]
420
+ #
421
+ # Note that <code>prc.()</code> invokes <code>prc.call()</code> with the
422
+ # parameters given. It's syntactic sugar to hide "call".
423
+ #
424
+ # For procs created using #lambda or <code>->()</code> an error is generated if
425
+ # the wrong number of parameters are passed to the proc. For procs created
426
+ # using Proc.new or Kernel.proc, extra parameters are silently discarded and
427
+ # missing parameters are set to `nil`.
428
+ #
429
+ # a_proc = proc {|a,b| [a,b] }
430
+ # a_proc.call(1) #=> [1, nil]
431
+ #
432
+ # a_proc = lambda {|a,b| [a,b] }
433
+ # a_proc.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2)
434
+ #
435
+ # See also Proc#lambda?.
436
+ #
437
+ alias yield call
438
+
439
+ # <!--
440
+ # rdoc-file=proc.c
441
+ # - prc << g -> a_proc
442
+ # -->
443
+ # Returns a proc that is the composition of this proc and the given *g*. The
444
+ # returned proc takes a variable number of arguments, calls *g* with them then
445
+ # calls this proc with the result.
446
+ #
447
+ # f = proc {|x| x * x }
448
+ # g = proc {|x| x + x }
449
+ # p (f << g).call(2) #=> 16
450
+ #
451
+ # See Proc#>> for detailed explanations.
452
+ #
453
+ def <<: (_Callable callable) -> Proc
454
+
455
+ # <!--
456
+ # rdoc-file=proc.c
457
+ # - prc >> g -> a_proc
458
+ # -->
459
+ # Returns a proc that is the composition of this proc and the given *g*. The
460
+ # returned proc takes a variable number of arguments, calls this proc with them
461
+ # then calls *g* with the result.
462
+ #
463
+ # f = proc {|x| x * x }
464
+ # g = proc {|x| x + x }
465
+ # p (f >> g).call(2) #=> 8
466
+ #
467
+ # *g* could be other Proc, or Method, or any other object responding to `call`
468
+ # method:
469
+ #
470
+ # class Parser
471
+ # def self.call(text)
472
+ # # ...some complicated parsing logic...
473
+ # end
474
+ # end
475
+ #
476
+ # pipeline = File.method(:read) >> Parser >> proc { |data| puts "data size: #{data.count}" }
477
+ # pipeline.call('data.json')
478
+ #
479
+ # See also Method#>> and Method#<<.
480
+ #
481
+ def >>: (_Callable callable) -> Proc
482
+
483
+ # <!--
484
+ # rdoc-file=proc.c
485
+ # - prc == other -> true or false
486
+ # - prc.eql?(other) -> true or false
487
+ # -->
488
+ # Two procs are the same if, and only if, they were created from the same code
489
+ # block.
490
+ #
491
+ # def return_block(&block)
492
+ # block
493
+ # end
494
+ #
495
+ # def pass_block_twice(&block)
496
+ # [return_block(&block), return_block(&block)]
497
+ # end
498
+ #
499
+ # block1, block2 = pass_block_twice { puts 'test' }
500
+ # # Blocks might be instantiated into Proc's lazily, so they may, or may not,
501
+ # # be the same object.
502
+ # # But they are produced from the same code block, so they are equal
503
+ # block1 == block2
504
+ # #=> true
505
+ #
506
+ # # Another Proc will never be equal, even if the code is the "same"
507
+ # block1 == proc { puts 'test' }
508
+ # #=> false
509
+ #
510
+ def ==: (untyped other) -> bool
511
+
512
+ # <!-- rdoc-file=proc.c -->
513
+ # Two procs are the same if, and only if, they were created from the same code
514
+ # block.
515
+ #
516
+ # def return_block(&block)
517
+ # block
518
+ # end
519
+ #
520
+ # def pass_block_twice(&block)
521
+ # [return_block(&block), return_block(&block)]
522
+ # end
523
+ #
524
+ # block1, block2 = pass_block_twice { puts 'test' }
525
+ # # Blocks might be instantiated into Proc's lazily, so they may, or may not,
526
+ # # be the same object.
527
+ # # But they are produced from the same code block, so they are equal
528
+ # block1 == block2
529
+ # #=> true
530
+ #
531
+ # # Another Proc will never be equal, even if the code is the "same"
532
+ # block1 == proc { puts 'test' }
533
+ # #=> false
534
+ #
535
+ alias eql? ==
536
+
537
+ # <!--
538
+ # rdoc-file=proc.c
539
+ # - prc.arity -> integer
540
+ # -->
541
+ # Returns the number of mandatory arguments. If the block is declared to take no
542
+ # arguments, returns 0. If the block is known to take exactly n arguments,
543
+ # returns n. If the block has optional arguments, returns -n-1, where n is the
544
+ # number of mandatory arguments, with the exception for blocks that are not
545
+ # lambdas and have only a finite number of optional arguments; in this latter
546
+ # case, returns n. Keyword arguments will be considered as a single additional
547
+ # argument, that argument being mandatory if any keyword argument is mandatory.
548
+ # A #proc with no argument declarations is the same as a block declaring
549
+ # <code>||</code> as its arguments.
550
+ #
551
+ # proc {}.arity #=> 0
552
+ # proc { || }.arity #=> 0
553
+ # proc { |a| }.arity #=> 1
554
+ # proc { |a, b| }.arity #=> 2
555
+ # proc { |a, b, c| }.arity #=> 3
556
+ # proc { |*a| }.arity #=> -1
557
+ # proc { |a, *b| }.arity #=> -2
558
+ # proc { |a, *b, c| }.arity #=> -3
559
+ # proc { |x:, y:, z:0| }.arity #=> 1
560
+ # proc { |*a, x:, y:0| }.arity #=> -2
561
+ #
562
+ # proc { |a=0| }.arity #=> 0
563
+ # lambda { |a=0| }.arity #=> -1
564
+ # proc { |a=0, b| }.arity #=> 1
565
+ # lambda { |a=0, b| }.arity #=> -2
566
+ # proc { |a=0, b=0| }.arity #=> 0
567
+ # lambda { |a=0, b=0| }.arity #=> -1
568
+ # proc { |a, b=0| }.arity #=> 1
569
+ # lambda { |a, b=0| }.arity #=> -2
570
+ # proc { |(a, b), c=0| }.arity #=> 1
571
+ # lambda { |(a, b), c=0| }.arity #=> -2
572
+ # proc { |a, x:0, y:0| }.arity #=> 1
573
+ # lambda { |a, x:0, y:0| }.arity #=> -2
574
+ #
575
+ def arity: () -> Integer
576
+
577
+ # <!--
578
+ # rdoc-file=proc.c
579
+ # - prc.binding -> binding
580
+ # -->
581
+ # Returns the binding associated with *prc*.
582
+ #
583
+ # def fred(param)
584
+ # proc {}
585
+ # end
586
+ #
587
+ # b = fred(99)
588
+ # eval("param", b.binding) #=> 99
589
+ #
590
+ def binding: () -> Binding
591
+
592
+ # <!--
593
+ # rdoc-file=proc.c
594
+ # - call(...) -> obj
595
+ # - self[...] -> obj
596
+ # - yield(...) -> obj
597
+ # -->
598
+ # Invokes the block, setting the block's parameters to the arguments using
599
+ # something close to method calling semantics. Returns the value of the last
600
+ # expression evaluated in the block.
601
+ #
602
+ # a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } }
603
+ # a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
604
+ # a_proc[9, 1, 2, 3] #=> [9, 18, 27]
605
+ # a_proc.(9, 1, 2, 3) #=> [9, 18, 27]
606
+ # a_proc.yield(9, 1, 2, 3) #=> [9, 18, 27]
607
+ #
608
+ # Note that <code>prc.()</code> invokes <code>prc.call()</code> with the
609
+ # parameters given. It's syntactic sugar to hide "call".
610
+ #
611
+ # For procs created using #lambda or <code>->()</code> an error is generated if
612
+ # the wrong number of parameters are passed to the proc. For procs created
613
+ # using Proc.new or Kernel.proc, extra parameters are silently discarded and
614
+ # missing parameters are set to `nil`.
615
+ #
616
+ # a_proc = proc {|a,b| [a,b] }
617
+ # a_proc.call(1) #=> [1, nil]
618
+ #
619
+ # a_proc = lambda {|a,b| [a,b] }
620
+ # a_proc.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2)
621
+ #
622
+ # See also Proc#lambda?.
623
+ #
624
+ def call: (?) -> untyped
625
+
626
+ # <!-- rdoc-file=proc.c -->
627
+ # Invokes the block, setting the block's parameters to the arguments using
628
+ # something close to method calling semantics. Returns the value of the last
629
+ # expression evaluated in the block.
630
+ #
631
+ # a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } }
632
+ # a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
633
+ # a_proc[9, 1, 2, 3] #=> [9, 18, 27]
634
+ # a_proc.(9, 1, 2, 3) #=> [9, 18, 27]
635
+ # a_proc.yield(9, 1, 2, 3) #=> [9, 18, 27]
636
+ #
637
+ # Note that <code>prc.()</code> invokes <code>prc.call()</code> with the
638
+ # parameters given. It's syntactic sugar to hide "call".
639
+ #
640
+ # For procs created using #lambda or <code>->()</code> an error is generated if
641
+ # the wrong number of parameters are passed to the proc. For procs created
642
+ # using Proc.new or Kernel.proc, extra parameters are silently discarded and
643
+ # missing parameters are set to `nil`.
644
+ #
645
+ # a_proc = proc {|a,b| [a,b] }
646
+ # a_proc.call(1) #=> [1, nil]
647
+ #
648
+ # a_proc = lambda {|a,b| [a,b] }
649
+ # a_proc.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2)
650
+ #
651
+ # See also Proc#lambda?.
652
+ #
653
+ alias [] call
654
+
655
+ # <!--
656
+ # rdoc-file=proc.c
657
+ # - prc.curry -> a_proc
658
+ # - prc.curry(arity) -> a_proc
659
+ # -->
660
+ # Returns a curried proc. If the optional *arity* argument is given, it
661
+ # determines the number of arguments. A curried proc receives some arguments. If
662
+ # a sufficient number of arguments are supplied, it passes the supplied
663
+ # arguments to the original proc and returns the result. Otherwise, returns
664
+ # another curried proc that takes the rest of arguments.
665
+ #
666
+ # The optional *arity* argument should be supplied when currying procs with
667
+ # variable arguments to determine how many arguments are needed before the proc
668
+ # is called.
669
+ #
670
+ # b = proc {|x, y, z| (x||0) + (y||0) + (z||0) }
671
+ # p b.curry[1][2][3] #=> 6
672
+ # p b.curry[1, 2][3, 4] #=> 6
673
+ # p b.curry(5)[1][2][3][4][5] #=> 6
674
+ # p b.curry(5)[1, 2][3, 4][5] #=> 6
675
+ # p b.curry(1)[1] #=> 1
676
+ #
677
+ # b = proc {|x, y, z, *w| (x||0) + (y||0) + (z||0) + w.inject(0, &:+) }
678
+ # p b.curry[1][2][3] #=> 6
679
+ # p b.curry[1, 2][3, 4] #=> 10
680
+ # p b.curry(5)[1][2][3][4][5] #=> 15
681
+ # p b.curry(5)[1, 2][3, 4][5] #=> 15
682
+ # p b.curry(1)[1] #=> 1
683
+ #
684
+ # b = lambda {|x, y, z| (x||0) + (y||0) + (z||0) }
685
+ # p b.curry[1][2][3] #=> 6
686
+ # p b.curry[1, 2][3, 4] #=> wrong number of arguments (given 4, expected 3)
687
+ # p b.curry(5) #=> wrong number of arguments (given 5, expected 3)
688
+ # p b.curry(1) #=> wrong number of arguments (given 1, expected 3)
689
+ #
690
+ # b = lambda {|x, y, z, *w| (x||0) + (y||0) + (z||0) + w.inject(0, &:+) }
691
+ # p b.curry[1][2][3] #=> 6
692
+ # p b.curry[1, 2][3, 4] #=> 10
693
+ # p b.curry(5)[1][2][3][4][5] #=> 15
694
+ # p b.curry(5)[1, 2][3, 4][5] #=> 15
695
+ # p b.curry(1) #=> wrong number of arguments (given 1, expected 3)
696
+ #
697
+ # b = proc { :foo }
698
+ # p b.curry[] #=> :foo
699
+ #
700
+ def curry: (?int? arity) -> Proc
701
+
702
+ # <!--
703
+ # rdoc-file=proc.c
704
+ # - prc.hash -> integer
705
+ # -->
706
+ # Returns a hash value corresponding to proc body.
707
+ #
708
+ # See also Object#hash.
709
+ #
710
+ def hash: () -> Integer
711
+
712
+ # <!--
713
+ # rdoc-file=proc.c
714
+ # - prc.lambda? -> true or false
715
+ # -->
716
+ # Returns `true` if a Proc object is lambda. `false` if non-lambda.
717
+ #
718
+ # The lambda-ness affects argument handling and the behavior of `return` and
719
+ # `break`.
720
+ #
721
+ # A Proc object generated by `proc` ignores extra arguments.
722
+ #
723
+ # proc {|a,b| [a,b] }.call(1,2,3) #=> [1,2]
724
+ #
725
+ # It provides `nil` for missing arguments.
726
+ #
727
+ # proc {|a,b| [a,b] }.call(1) #=> [1,nil]
728
+ #
729
+ # It expands a single array argument.
730
+ #
731
+ # proc {|a,b| [a,b] }.call([1,2]) #=> [1,2]
732
+ #
733
+ # A Proc object generated by `lambda` doesn't have such tricks.
734
+ #
735
+ # lambda {|a,b| [a,b] }.call(1,2,3) #=> ArgumentError
736
+ # lambda {|a,b| [a,b] }.call(1) #=> ArgumentError
737
+ # lambda {|a,b| [a,b] }.call([1,2]) #=> ArgumentError
738
+ #
739
+ # Proc#lambda? is a predicate for the tricks. It returns `true` if no tricks
740
+ # apply.
741
+ #
742
+ # lambda {}.lambda? #=> true
743
+ # proc {}.lambda? #=> false
744
+ #
745
+ # Proc.new is the same as `proc`.
746
+ #
747
+ # Proc.new {}.lambda? #=> false
748
+ #
749
+ # `lambda`, `proc` and Proc.new preserve the tricks of a Proc object given by
750
+ # <code>&</code> argument.
751
+ #
752
+ # lambda(&lambda {}).lambda? #=> true
753
+ # proc(&lambda {}).lambda? #=> true
754
+ # Proc.new(&lambda {}).lambda? #=> true
755
+ #
756
+ # lambda(&proc {}).lambda? #=> false
757
+ # proc(&proc {}).lambda? #=> false
758
+ # Proc.new(&proc {}).lambda? #=> false
759
+ #
760
+ # A Proc object generated by <code>&</code> argument has the tricks
761
+ #
762
+ # def n(&b) b.lambda? end
763
+ # n {} #=> false
764
+ #
765
+ # The <code>&</code> argument preserves the tricks if a Proc object is given by
766
+ # <code>&</code> argument.
767
+ #
768
+ # n(&lambda {}) #=> true
769
+ # n(&proc {}) #=> false
770
+ # n(&Proc.new {}) #=> false
771
+ #
772
+ # A Proc object converted from a method has no tricks.
773
+ #
774
+ # def m() end
775
+ # method(:m).to_proc.lambda? #=> true
776
+ #
777
+ # n(&method(:m)) #=> true
778
+ # n(&method(:m).to_proc) #=> true
779
+ #
780
+ # `define_method` is treated the same as method definition. The defined method
781
+ # has no tricks.
782
+ #
783
+ # class C
784
+ # define_method(:d) {}
785
+ # end
786
+ # C.new.d(1,2) #=> ArgumentError
787
+ # C.new.method(:d).to_proc.lambda? #=> true
788
+ #
789
+ # `define_method` always defines a method without the tricks, even if a
790
+ # non-lambda Proc object is given. This is the only exception for which the
791
+ # tricks are not preserved.
792
+ #
793
+ # class C
794
+ # define_method(:e, &proc {})
795
+ # end
796
+ # C.new.e(1,2) #=> ArgumentError
797
+ # C.new.method(:e).to_proc.lambda? #=> true
798
+ #
799
+ # This exception ensures that methods never have tricks and makes it easy to
800
+ # have wrappers to define methods that behave as usual.
801
+ #
802
+ # class C
803
+ # def self.def2(name, &body)
804
+ # define_method(name, &body)
805
+ # end
806
+ #
807
+ # def2(:f) {}
808
+ # end
809
+ # C.new.f(1,2) #=> ArgumentError
810
+ #
811
+ # The wrapper *def2* defines a method which has no tricks.
812
+ #
813
+ def lambda?: () -> bool
814
+
815
+ # <!--
816
+ # rdoc-file=proc.c
817
+ # - prc.parameters(lambda: nil) -> array
818
+ # -->
819
+ # Returns the parameter information of this proc. If the lambda keyword is
820
+ # provided and not nil, treats the proc as a lambda if true and as a non-lambda
821
+ # if false.
822
+ #
823
+ # prc = proc{|x, y=42, *other|}
824
+ # prc.parameters #=> [[:opt, :x], [:opt, :y], [:rest, :other]]
825
+ # prc = lambda{|x, y=42, *other|}
826
+ # prc.parameters #=> [[:req, :x], [:opt, :y], [:rest, :other]]
827
+ # prc = proc{|x, y=42, *other|}
828
+ # prc.parameters(lambda: true) #=> [[:req, :x], [:opt, :y], [:rest, :other]]
829
+ # prc = lambda{|x, y=42, *other|}
830
+ # prc.parameters(lambda: false) #=> [[:opt, :x], [:opt, :y], [:rest, :other]]
831
+ #
832
+ def parameters: (?lambda: boolish) -> Method::param_types
833
+
834
+ # <!--
835
+ # rdoc-file=proc.c
836
+ # - proc.ruby2_keywords -> proc
837
+ # -->
838
+ # Marks the proc as passing keywords through a normal argument splat. This
839
+ # should only be called on procs that accept an argument splat
840
+ # (<code>*args</code>) but not explicit keywords or a keyword splat. It marks
841
+ # the proc such that if the proc is called with keyword arguments, the final
842
+ # hash argument is marked with a special flag such that if it is the final
843
+ # element of a normal argument splat to another method call, and that method
844
+ # call does not include explicit keywords or a keyword splat, the final element
845
+ # is interpreted as keywords. In other words, keywords will be passed through
846
+ # the proc to other methods.
847
+ #
848
+ # This should only be used for procs that delegate keywords to another method,
849
+ # and only for backwards compatibility with Ruby versions before 2.7.
850
+ #
851
+ # This method will probably be removed at some point, as it exists only for
852
+ # backwards compatibility. As it does not exist in Ruby versions before 2.7,
853
+ # check that the proc responds to this method before calling it. Also, be aware
854
+ # that if this method is removed, the behavior of the proc will change so that
855
+ # it does not pass through keywords.
856
+ #
857
+ # module Mod
858
+ # foo = ->(meth, *args, &block) do
859
+ # send(:"do_#{meth}", *args, &block)
860
+ # end
861
+ # foo.ruby2_keywords if foo.respond_to?(:ruby2_keywords)
862
+ # end
863
+ #
864
+ def ruby2_keywords: () -> self
865
+
866
+ # <!--
867
+ # rdoc-file=proc.c
868
+ # - prc.source_location -> [String, Integer, Integer, Integer, Integer]
869
+ # -->
870
+ # Returns the location where the Proc was defined. The returned Array contains:
871
+ # (1) the Ruby source filename
872
+ # (2) the line number where the definition starts
873
+ # (3) the column number where the definition starts
874
+ # (4) the line number where the definition ends
875
+ # (5) the column number where the definitions ends
876
+ #
877
+ # This method will return `nil` if the Proc was not defined in Ruby (i.e.
878
+ # native).
879
+ #
880
+ def source_location: () -> [String, Integer]?
881
+
882
+ # <!--
883
+ # rdoc-file=proc.c
884
+ # - prc.to_proc -> proc
885
+ # -->
886
+ # Part of the protocol for converting objects to Proc objects. Instances of
887
+ # class Proc simply return themselves.
888
+ #
889
+ def to_proc: () -> self
890
+
891
+ # <!--
892
+ # rdoc-file=proc.c
893
+ # - prc.to_s -> string
894
+ # -->
895
+ # Returns the unique identifier for this proc, along with an indication of where
896
+ # the proc was defined.
897
+ #
898
+ def to_s: () -> String
899
+
900
+ # <!-- rdoc-file=proc.c -->
901
+ # Returns the unique identifier for this proc, along with an indication of where
902
+ # the proc was defined.
903
+ #
904
+ alias inspect to_s
905
+ end