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/trace_point.rbs CHANGED
@@ -1,107 +1,121 @@
1
1
  # <!-- rdoc-file=trace_point.rb -->
2
- # A class that provides the functionality of Kernel#set_trace_func in a nice
3
- # Object-Oriented API.
2
+ # A class that provides the functionality of Kernel#set_trace_func in a
3
+ # well-structured Object-Oriented API.
4
4
  #
5
5
  # ## Example
6
6
  #
7
- # We can use TracePoint to gather information specifically for exceptions:
7
+ # Use TracePoint to gather information specifically for exceptions:
8
8
  #
9
9
  # trace = TracePoint.new(:raise) do |tp|
10
- # p [tp.lineno, tp.event, tp.raised_exception]
10
+ # p [tp.lineno, tp.event, tp.raised_exception]
11
11
  # end
12
12
  # #=> #<TracePoint:disabled>
13
13
  #
14
- # trace.enable
15
- # #=> false
14
+ # trace.enable #=> false
16
15
  #
17
16
  # 0 / 0
18
17
  # #=> [5, :raise, #<ZeroDivisionError: divided by 0>]
19
18
  #
20
19
  # ## Events
21
20
  #
22
- # If you don't specify the type of events you want to listen for, TracePoint
21
+ # If you don't specify the types of events you want to listen for, TracePoint
23
22
  # will include all available events.
24
23
  #
25
- # **Note** do not depend on current event set, as this list is subject to
26
- # change. Instead, it is recommended you specify the type of events you want to
24
+ # **Note:** Do not depend on the current event set, as this list is subject to
25
+ # change. Instead, it is recommended to specify the types of events you want to
27
26
  # use.
28
27
  #
29
28
  # To filter what is traced, you can pass any of the following as `events`:
30
29
  #
31
30
  # `:line`
32
- # : execute an expression or statement on a new line
31
+ # : Execute an expression or statement on a new line.
32
+ #
33
33
  # `:class`
34
- # : start a class or module definition
34
+ # : Start a class or module definition.
35
+ #
35
36
  # `:end`
36
- # : finish a class or module definition
37
+ # : Finish a class or module definition.
38
+ #
37
39
  # `:call`
38
- # : call a Ruby method
40
+ # : Call a Ruby method.
41
+ #
39
42
  # `:return`
40
- # : return from a Ruby method
43
+ # : Return from a Ruby method.
44
+ #
41
45
  # `:c_call`
42
- # : call a C-language routine
46
+ # : Call a C-language routine.
47
+ #
43
48
  # `:c_return`
44
- # : return from a C-language routine
49
+ # : Return from a C-language routine.
50
+ #
45
51
  # `:raise`
46
- # : raise an exception
52
+ # : Raise an exception.
53
+ #
47
54
  # `:rescue`
48
- # : rescue an exception
55
+ # : Rescue an exception.
56
+ #
49
57
  # `:b_call`
50
- # : event hook at block entry
58
+ # : Event hook at block entry.
59
+ #
51
60
  # `:b_return`
52
- # : event hook at block ending
61
+ # : Event hook at block ending.
62
+ #
53
63
  # `:a_call`
54
- # : event hook at all calls (`call`, `b_call`, and `c_call`)
64
+ # : Event hook at all calls (`call`, `b_call`, and `c_call`).
65
+ #
55
66
  # `:a_return`
56
- # : event hook at all returns (`return`, `b_return`, and `c_return`)
67
+ # : Event hook at all returns (`return`, `b_return`, and `c_return`).
68
+ #
57
69
  # `:thread_begin`
58
- # : event hook at thread beginning
70
+ # : Event hook at thread beginning.
71
+ #
59
72
  # `:thread_end`
60
- # : event hook at thread ending
73
+ # : Event hook at thread ending.
74
+ #
61
75
  # `:fiber_switch`
62
- # : event hook at fiber switch
76
+ # : Event hook at fiber switch.
77
+ #
63
78
  # `:script_compiled`
64
- # : new Ruby code compiled (with `eval`, `load` or `require`)
79
+ # : New Ruby code compiled (with `eval`, `load`, or `require`).
65
80
  #
66
81
  class TracePoint
67
82
  # <!--
68
83
  # rdoc-file=trace_point.rb
69
- # - TracePoint.new(*events) { |obj| block } -> obj
84
+ # - TracePoint.new(*events) { |tp| block } -> tp
70
85
  # -->
71
86
  # Returns a new TracePoint object, not enabled by default.
72
87
  #
73
- # Next, in order to activate the trace, you must use TracePoint#enable
88
+ # To activate the TracePoint object, use TracePoint#enable:
74
89
  #
75
90
  # trace = TracePoint.new(:call) do |tp|
76
- # p [tp.lineno, tp.defined_class, tp.method_id, tp.event]
91
+ # p [tp.lineno, tp.defined_class, tp.method_id, tp.event]
77
92
  # end
78
93
  # #=> #<TracePoint:disabled>
79
94
  #
80
- # trace.enable
81
- # #=> false
95
+ # trace.enable #=> false
82
96
  #
83
97
  # puts "Hello, TracePoint!"
84
98
  # # ...
85
99
  # # [48, IRB::Notifier::AbstractNotifier, :printf, :call]
86
100
  # # ...
87
101
  #
88
- # When you want to deactivate the trace, you must use TracePoint#disable
102
+ # To deactivate the trace, use TracePoint#disable.
89
103
  #
90
104
  # trace.disable
91
105
  #
92
106
  # See TracePoint@Events for possible events and more information.
93
107
  #
94
- # A block must be given, otherwise an ArgumentError is raised.
108
+ # A block must be given; otherwise, an ArgumentError is raised.
95
109
  #
96
110
  # If the trace method isn't included in the given events filter, a RuntimeError
97
111
  # is raised.
98
112
  #
99
113
  # TracePoint.trace(:line) do |tp|
100
- # p tp.raised_exception
114
+ # p tp.raised_exception
101
115
  # end
102
116
  # #=> RuntimeError: 'raised_exception' not supported by this event
103
117
  #
104
- # If the trace method is called outside block, a RuntimeError is raised.
118
+ # If the trace method is called outside a block, a RuntimeError is raised.
105
119
  #
106
120
  # TracePoint.trace(:line) do |tp|
107
121
  # $tp = tp
@@ -116,13 +130,12 @@ class TracePoint
116
130
  # rdoc-file=trace_point.rb
117
131
  # - TracePoint.allow_reentry { block }
118
132
  # -->
119
- # In general, while a TracePoint callback is running, other registered callbacks
120
- # are not called to avoid confusion by reentrance. This method allows the
121
- # reentrance in a given block. This method should be used carefully, otherwise
122
- # the callback can be easily called infinitely.
133
+ # Generally, while a TracePoint callback is running, other registered callbacks
134
+ # are not called to avoid confusion from reentrance. This method allows
135
+ # reentrance within a given block. Use this method carefully to avoid infinite
136
+ # callback invocation.
123
137
  #
124
- # If this method is called when the reentrance is already allowed, it raises a
125
- # RuntimeError.
138
+ # If called when reentrance is already allowed, it raises a RuntimeError.
126
139
  #
127
140
  # **Example:**
128
141
  #
@@ -130,7 +143,7 @@ class TracePoint
130
143
  # # ---------------
131
144
  #
132
145
  # line_handler = TracePoint.new(:line) do |tp|
133
- # next if tp.path != __FILE__ # only work in this file
146
+ # next if tp.path != __FILE__ # Only works in this file
134
147
  # puts "Line handler"
135
148
  # binding.eval("class C; end")
136
149
  # end.enable
@@ -142,15 +155,15 @@ class TracePoint
142
155
  # class B
143
156
  # end
144
157
  #
145
- # # This script will print "Class handler" only once: when inside :line
146
- # # handler, all other handlers are ignored
158
+ # # This script will print "Class handler" only once: when inside the :line
159
+ # # handler, all other handlers are ignored.
147
160
  #
148
161
  # # With reentry
149
162
  # # ------------
150
163
  #
151
164
  # line_handler = TracePoint.new(:line) do |tp|
152
- # next if tp.path != __FILE__ # only work in this file
153
- # next if (__LINE__..__LINE__+3).cover?(tp.lineno) # don't be invoked from itself
165
+ # next if tp.path != __FILE__ # Only works in this file
166
+ # next if (__LINE__..__LINE__+3).cover?(tp.lineno) # Prevent infinite calls
154
167
  # puts "Line handler"
155
168
  # TracePoint.allow_reentry { binding.eval("class C; end") }
156
169
  # end.enable
@@ -162,15 +175,15 @@ class TracePoint
162
175
  # class B
163
176
  # end
164
177
  #
165
- # # This wil print "Class handler" twice: inside allow_reentry block in :line
178
+ # # This will print "Class handler" twice: inside the allow_reentry block in the :line
166
179
  # # handler, other handlers are enabled.
167
180
  #
168
181
  # Note that the example shows the principal effect of the method, but its
169
182
  # practical usage is for debugging libraries that sometimes require other
170
- # libraries hooks to not be affected by debugger being inside trace point
183
+ # libraries' hooks to not be affected by the debugger being inside trace point
171
184
  # handling. Precautions should be taken against infinite recursion in this case
172
- # (note that we needed to filter out calls by itself from :line handler,
173
- # otherwise it will call itself infinitely).
185
+ # (note that we needed to filter out calls by itself from the :line handler,
186
+ # otherwise it would call itself infinitely).
174
187
  #
175
188
  def self.allow_reentry: [T] () { (nil) -> T } -> T
176
189
 
@@ -180,8 +193,8 @@ class TracePoint
180
193
  # -->
181
194
  # Returns internal information of TracePoint.
182
195
  #
183
- # The contents of the returned value are implementation specific. It may be
184
- # changed in future.
196
+ # The contents of the returned value are implementation-specific and may change
197
+ # in the future.
185
198
  #
186
199
  # This method is only for debugging TracePoint itself.
187
200
  #
@@ -189,15 +202,15 @@ class TracePoint
189
202
 
190
203
  # <!--
191
204
  # rdoc-file=trace_point.rb
192
- # - TracePoint.trace(*events) { |obj| block } -> obj
205
+ # - TracePoint.trace(*events) { |tp| block } -> obj
193
206
  # -->
194
- # A convenience method for TracePoint.new, that activates the trace
207
+ # A convenience method for TracePoint.new that activates the trace
195
208
  # automatically.
196
209
  #
197
210
  # trace = TracePoint.trace(:call) { |tp| [tp.lineno, tp.event] }
198
211
  # #=> #<TracePoint:enabled>
199
212
  #
200
- # trace.enabled? #=> true
213
+ # trace.enabled? #=> true
201
214
  #
202
215
  def self.trace: (*_ToSym events) { (instance tp) -> void } -> instance
203
216
 
@@ -205,9 +218,9 @@ class TracePoint
205
218
  # rdoc-file=trace_point.rb
206
219
  # - binding()
207
220
  # -->
208
- # Return the generated binding object from event.
221
+ # Returns the generated binding object from the event.
209
222
  #
210
- # Note that for `:c_call` and `:c_return` events, the method will return `nil`,
223
+ # Note that for `:c_call` and `:c_return` events, the method returns `nil`,
211
224
  # since C methods themselves do not have bindings.
212
225
  #
213
226
  def binding: () -> Binding?
@@ -216,7 +229,7 @@ class TracePoint
216
229
  # rdoc-file=trace_point.rb
217
230
  # - callee_id()
218
231
  # -->
219
- # Return the called name of the method being called
232
+ # Returns the called name of the method being called.
220
233
  #
221
234
  def callee_id: () -> Symbol?
222
235
 
@@ -224,7 +237,7 @@ class TracePoint
224
237
  # rdoc-file=trace_point.rb
225
238
  # - defined_class()
226
239
  # -->
227
- # Return class or module of the method being called.
240
+ # Returns the class or module of the method being called.
228
241
  #
229
242
  # class C; def foo; end; end
230
243
  # trace = TracePoint.new(:call) do |tp|
@@ -233,20 +246,20 @@ class TracePoint
233
246
  # C.new.foo
234
247
  # end
235
248
  #
236
- # If method is defined by a module, then that module is returned.
249
+ # If the method is defined by a module, then that module is returned.
237
250
  #
238
251
  # module M; def foo; end; end
239
- # class C; include M; end;
252
+ # class C; include M; end
240
253
  # trace = TracePoint.new(:call) do |tp|
241
254
  # p tp.defined_class #=> M
242
255
  # end.enable do
243
256
  # C.new.foo
244
257
  # end
245
258
  #
246
- # **Note:** #defined_class returns singleton class.
259
+ # **Note:** #defined_class returns the singleton class.
247
260
  #
248
- # 6th block parameter of Kernel#set_trace_func passes original class of attached
249
- # by singleton class.
261
+ # The 6th block parameter of Kernel#set_trace_func passes the original class
262
+ # attached by the singleton class.
250
263
  #
251
264
  # **This is a difference between Kernel#set_trace_func and TracePoint.**
252
265
  #
@@ -261,31 +274,30 @@ class TracePoint
261
274
 
262
275
  # <!--
263
276
  # rdoc-file=trace_point.rb
264
- # - trace.disable -> true or false
277
+ # - trace.disable -> true or false
265
278
  # - trace.disable { block } -> obj
266
279
  # -->
267
- # Deactivates the trace
280
+ # Deactivates the trace.
268
281
  #
269
- # Return true if trace was enabled. Return false if trace was disabled.
282
+ # Returns `true` if the trace was enabled. Returns `false` if the trace was
283
+ # disabled.
270
284
  #
271
- # trace.enabled? #=> true
272
- # trace.disable #=> true (previous status)
273
- # trace.enabled? #=> false
274
- # trace.disable #=> false
285
+ # trace.enabled? #=> true
286
+ # trace.disable #=> true (previous status)
287
+ # trace.enabled? #=> false
288
+ # trace.disable #=> false
275
289
  #
276
- # If a block is given, the trace will only be disable within the scope of the
290
+ # If a block is given, the trace will only be disabled within the scope of the
277
291
  # block.
278
292
  #
279
- # trace.enabled?
280
- # #=> true
293
+ # trace.enabled? #=> true
281
294
  #
282
295
  # trace.disable do
283
- # trace.enabled?
284
- # # only disabled for this block
296
+ # trace.enabled?
297
+ # # Only disabled for this block
285
298
  # end
286
299
  #
287
- # trace.enabled?
288
- # #=> true
300
+ # trace.enabled? #=> true
289
301
  #
290
302
  # Note: You cannot access event hooks within the block.
291
303
  #
@@ -297,12 +309,13 @@ class TracePoint
297
309
 
298
310
  # <!--
299
311
  # rdoc-file=trace_point.rb
300
- # - trace.enable(target: nil, target_line: nil, target_thread: nil) -> true or false
301
- # - trace.enable(target: nil, target_line: nil, target_thread: :default) { block } -> obj
312
+ # - trace.enable(target: nil, target_line: nil, target_thread: nil) -> true or false
313
+ # - trace.enable(target: nil, target_line: nil, target_thread: :default) { block } -> obj
302
314
  # -->
303
315
  # Activates the trace.
304
316
  #
305
- # Returns `true` if trace was enabled. Returns `false` if trace was disabled.
317
+ # Returns `true` if the trace was enabled. Returns `false` if the trace was
318
+ # disabled.
306
319
  #
307
320
  # trace.enabled? #=> false
308
321
  # trace.enable #=> false (previous state)
@@ -311,24 +324,22 @@ class TracePoint
311
324
  # trace.enable #=> true (previous state)
312
325
  # # trace is still enabled
313
326
  #
314
- # If a block is given, the trace will only be enabled during the block call. If
315
- # target and target_line are both nil, then target_thread will default to the
316
- # current thread if a block is given.
327
+ # If a block is given, the trace will only be enabled during the block
328
+ # execution. If target and target_line are both nil, then target_thread will
329
+ # default to the current thread if a block is given.
317
330
  #
318
- # trace.enabled?
319
- # #=> false
331
+ # trace.enabled? #=> false
320
332
  #
321
333
  # trace.enable do
322
334
  # trace.enabled?
323
- # # only enabled for this block and thread
335
+ # # Only enabled for this block and thread
324
336
  # end
325
337
  #
326
- # trace.enabled?
327
- # #=> false
338
+ # trace.enabled? #=> false
328
339
  #
329
- # `target`, `target_line` and `target_thread` parameters are used to limit
330
- # tracing only to specified code objects. `target` should be a code object for
331
- # which RubyVM::InstructionSequence.of will return an instruction sequence.
340
+ # The `target`, `target_line`, and `target_thread` parameters are used to limit
341
+ # tracing to specified code objects. `target` should be a code object for which
342
+ # RubyVM::InstructionSequence.of will return an instruction sequence.
332
343
  #
333
344
  # t = TracePoint.new(:line) { |tp| p tp }
334
345
  #
@@ -343,9 +354,9 @@ class TracePoint
343
354
  # t.enable(target: method(:m1))
344
355
  #
345
356
  # m1
346
- # # prints #<TracePoint:line test.rb:4 in `m1'>
357
+ # # Prints #<TracePoint:line test.rb:4 in `m1'>
347
358
  # m2
348
- # # prints nothing
359
+ # # Prints nothing
349
360
  #
350
361
  # Note: You cannot access event hooks within the `enable` block.
351
362
  #
@@ -357,9 +368,9 @@ class TracePoint
357
368
 
358
369
  # <!--
359
370
  # rdoc-file=trace_point.rb
360
- # - trace.enabled? -> true or false
371
+ # - trace.enabled? -> true or false
361
372
  # -->
362
- # The current status of the trace
373
+ # Returns the current status of the trace.
363
374
  #
364
375
  def enabled?: () -> bool
365
376
 
@@ -367,7 +378,7 @@ class TracePoint
367
378
  # rdoc-file=trace_point.rb
368
379
  # - event()
369
380
  # -->
370
- # Type of event
381
+ # Returns the type of event.
371
382
  #
372
383
  # See TracePoint@Events for more information.
373
384
  #
@@ -375,9 +386,9 @@ class TracePoint
375
386
 
376
387
  # <!--
377
388
  # rdoc-file=trace_point.rb
378
- # - trace.inspect -> string
389
+ # - trace.inspect -> string
379
390
  # -->
380
- # Return a string containing a human-readable TracePoint status.
391
+ # Returns a string containing a human-readable TracePoint status.
381
392
  #
382
393
  def inspect: () -> String
383
394
 
@@ -385,7 +396,7 @@ class TracePoint
385
396
  # rdoc-file=trace_point.rb
386
397
  # - lineno()
387
398
  # -->
388
- # Line number of the event
399
+ # Returns the line number of the event.
389
400
  #
390
401
  def lineno: () -> Integer
391
402
 
@@ -393,7 +404,7 @@ class TracePoint
393
404
  # rdoc-file=trace_point.rb
394
405
  # - method_id()
395
406
  # -->
396
- # Return the name at the definition of the method being called
407
+ # Returns the name at the definition of the method being called.
397
408
  #
398
409
  def method_id: () -> Symbol?
399
410
 
@@ -401,7 +412,7 @@ class TracePoint
401
412
  # rdoc-file=trace_point.rb
402
413
  # - path()
403
414
  # -->
404
- # Path of the file being run
415
+ # Returns the path of the file being executed.
405
416
  #
406
417
  def path: () -> String
407
418
 
@@ -409,8 +420,8 @@ class TracePoint
409
420
  # rdoc-file=trace_point.rb
410
421
  # - parameters()
411
422
  # -->
412
- # Return the parameters definition of the method or block that the current hook
413
- # belongs to. Format is the same as for Method#parameters
423
+ # Returns the parameter definitions of the method or block that the current hook
424
+ # belongs to. The format is the same as for Method#parameters.
414
425
  #
415
426
  def parameters: () -> Method::param_types?
416
427
 
@@ -418,7 +429,7 @@ class TracePoint
418
429
  # rdoc-file=trace_point.rb
419
430
  # - raised_exception()
420
431
  # -->
421
- # Value from exception raised on the `:raise` event, or rescued on the `:rescue`
432
+ # Returns the exception raised on the `:raise` event or rescued on the `:rescue`
422
433
  # event.
423
434
  #
424
435
  def raised_exception: () -> Exception
@@ -427,7 +438,7 @@ class TracePoint
427
438
  # rdoc-file=trace_point.rb
428
439
  # - return_value()
429
440
  # -->
430
- # Return value from `:return`, `:c_return`, and `:b_return` event
441
+ # Returns the return value from `:return`, `:c_return`, and `:b_return` events.
431
442
  #
432
443
  def return_value: () -> untyped
433
444
 
@@ -435,9 +446,9 @@ class TracePoint
435
446
  # rdoc-file=trace_point.rb
436
447
  # - self()
437
448
  # -->
438
- # Return the trace object during event
449
+ # Returns the trace object during the event.
439
450
  #
440
- # Same as the following, except it returns the correct object (the method
451
+ # Similar to the following, but it returns the correct object (the method
441
452
  # receiver) for `:c_call` and `:c_return` events:
442
453
  #
443
454
  # trace.binding.eval('self')
@@ -448,8 +459,8 @@ class TracePoint
448
459
  # rdoc-file=trace_point.rb
449
460
  # - eval_script()
450
461
  # -->
451
- # Compiled source code (String) on *eval methods on the `:script_compiled`
452
- # event. If loaded from a file, it will return nil.
462
+ # Returns the compiled source code (String) from eval methods on the
463
+ # `:script_compiled` event. If loaded from a file, it returns `nil`.
453
464
  #
454
465
  def eval_script: () -> String?
455
466
 
@@ -457,10 +468,10 @@ class TracePoint
457
468
  # rdoc-file=trace_point.rb
458
469
  # - instruction_sequence()
459
470
  # -->
460
- # Compiled instruction sequence represented by a RubyVM::InstructionSequence
461
- # instance on the `:script_compiled` event.
471
+ # Returns the compiled instruction sequence represented by a
472
+ # RubyVM::InstructionSequence instance on the `:script_compiled` event.
462
473
  #
463
- # Note that this method is MRI specific.
474
+ # Note that this method is CRuby-specific.
464
475
  #
465
476
  def instruction_sequence: () -> RubyVM::InstructionSequence
466
477
  end
data/core/true_class.rbs CHANGED
@@ -8,7 +8,6 @@
8
8
  # * #===
9
9
  # * #^
10
10
  #
11
- #
12
11
  # One other method:
13
12
  #
14
13
  # * #to_s and its alias #inspect.
@@ -100,7 +100,7 @@ class UnboundMethod
100
100
  # m.call # => "bar"
101
101
  # n = m.clone.call # => "bar"
102
102
  #
103
- def clone: () -> instance
103
+ def clone: () -> self
104
104
 
105
105
  # <!--
106
106
  # rdoc-file=proc.c
data/core/warning.rbs CHANGED
@@ -45,12 +45,11 @@ module Warning
45
45
  # : deprecation warnings
46
46
  # * assignment of non-nil value to `$,` and `$;`
47
47
  # * keyword arguments
48
- #
49
48
  # etc.
50
49
  #
50
+ #
51
51
  # `:experimental`
52
52
  # : experimental features
53
- # * Pattern matching
54
53
  #
55
54
  #
56
55
  # `:performance`
@@ -67,6 +66,14 @@ module Warning
67
66
  #
68
67
  def self.[]=: [T] (category, T flag) -> T
69
68
 
69
+ # <!--
70
+ # rdoc-file=error.c
71
+ # - categories -> array
72
+ # -->
73
+ # Returns a list of the supported category symbols.
74
+ #
75
+ def self.categories: () -> Array[Symbol]
76
+
70
77
  # <!--
71
78
  # rdoc-file=error.c
72
79
  # - warn(msg, category: nil) -> nil
data/docs/architecture.md CHANGED
@@ -92,7 +92,7 @@ The `#build_singleton` calculates the type of `.new` methods based on the defini
92
92
  `DefinitionBuilder#expand_alias` and its variants provide one step *unfold* operation of type aliases.
93
93
 
94
94
  ```ruby
95
- builder.expand_alias2(TypeName("::int"), []) # => returns `::Integer | ::_ToInt`
95
+ builder.expand_alias2(RBS::TypeName.parse("::int"), []) # => returns `::Integer | ::_ToInt`
96
96
  ```
97
97
 
98
98
  We don't have *normalize* operation for type aliases, because RBS allows recursive type alias definition, which cannot be *fully* unfolded.
data/docs/syntax.md CHANGED
@@ -289,9 +289,11 @@ The following `class`/`instance` types are allowed.
289
289
  class Foo
290
290
  attr_reader parent: class
291
291
 
292
- def foo: () -> instance
292
+ def foo: () -> instance # behaves like `self` in this context
293
293
 
294
- @@foos: Array[instances]
294
+ def self?.bar: () -> instance # behaves like `class` for `def self.bar()` and `self` for `def bar()`
295
+
296
+ @@foos: Array[instance]
295
297
 
296
298
  include Enumerable[class]
297
299
  end
@@ -405,9 +407,12 @@ _ivar-member_ ::= _ivar-name_ `:` _type_
405
407
  | `self` `.` _ivar-name_ `:` _type_
406
408
  | _cvar-name_ `:` _type_
407
409
 
408
- _method-member_ ::= _visibility_ `def` _method-name_ `:` _method-types_ # Instance method
409
- | _visibility_ `def self.` _method-name_ `:` _method-types_ # Singleton method
410
- | `def self?.` _method-name_ `:` _method-types_ # Singleton and instance method
410
+ _method-member_ ::= _method-class-member_
411
+ | _method-interface-member_
412
+ _method-class-member_ ::= _visibility_ `def` _method-name_ `:` _method-types_ # Instance method
413
+ | _visibility_ `def self.` _method-name_ `:` _method-types_ # Singleton method
414
+ | `def self?.` _method-name_ `:` _method-types_ # Singleton and instance method
415
+ _method-interface-member_ ::= `def` _method-name_ `:` _method-types_ # Instance method
411
416
 
412
417
  _method-types_ ::= _method-type-parameters_ _method-type_ # Single method type
413
418
  | _method-type-parameters_ _method-type_ `|` _method-types_ # Overloading types
@@ -416,10 +421,12 @@ _method-types_ ::= _method-type-parameters_ _method-type_
416
421
  _method-type-parameters_ ::= # Empty
417
422
  | `[` _type-variable_ `,` ... `]`
418
423
 
419
- _attribute-member_ ::= _visibility_ _attribute-type_ _method-name_ `:` _type_ # Attribute
420
- | _visibility_ _attribute-type_ _method-name_ `(` _ivar-name_ `) :` _type_ # Attribute with variable name specification
421
- | _visibility_ _attribute-type_ _method-name_ `() :` _type_ # Attribute without variable
422
-
424
+ _attribute-member_ ::= _visibility_ _attribute-type_ _method-name_ `:` _type_ # Attribute
425
+ | _visibility_ _attribute-type_ _method-name_ `(` _ivar-name_ `) :` _type_ # Attribute with variable name specification
426
+ | _visibility_ _attribute-type_ _method-name_ `() :` _type_ # Attribute without variable
427
+ | _visibility_ _attribute-type_ `self.` _method-name_ `:` _type_ # Singleton attribute
428
+ | _visibility_ _attribute-type_ `self.` _method-name_ `(` _ivar-name_ `) :` _type_ # Singleton attribute with variable name specification
429
+ | _visibility_ _attribute-type_ `self.` _method-name_ `() :` _type_ # Singleton attribute without variable
423
430
  _visibility_ ::= `public` | `private`
424
431
 
425
432
  _attribute-type_ ::= `attr_reader` | `attr_writer` | `attr_accessor`
@@ -622,7 +629,7 @@ _module-self-types_ ::= _class-name_ _type-arguments_ `,` _module-self-types_
622
629
 
623
630
  _interface-decl_ ::= `interface` _interface-name_ _module-type-parameters_ _interface-members_ `end`
624
631
 
625
- _interface-members_ ::= _method-member_ # Method
632
+ _interface-members_ ::= _method-interface-member_ # Method
626
633
  | _include-interface-member_ # Mixin (include)
627
634
  | _alias-member_ # Alias
628
635
 
@@ -1,4 +1,15 @@
1
1
  require 'mkmf'
2
+
2
3
  $INCFLAGS << " -I$(top_srcdir)" if $extmk
4
+ $INCFLAGS << " -I$(srcdir)/../../include"
5
+
6
+ $VPATH << "$(srcdir)/../../src"
7
+ $VPATH << "$(srcdir)/../../src/util"
8
+ $VPATH << "$(srcdir)/ext/rbs_extension"
9
+
10
+ root_dir = File.expand_path('../../../', __FILE__)
11
+ $srcs = Dir.glob("#{root_dir}/src/**/*.c") +
12
+ Dir.glob("#{root_dir}/ext/rbs_extension/*.c")
13
+
3
14
  append_cflags ['-std=gnu99']
4
15
  create_makefile 'rbs_extension'