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.
- checksums.yaml +4 -4
- data/.github/workflows/comments.yml +2 -2
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/ruby.yml +34 -10
- data/.github/workflows/windows.yml +20 -3
- data/.gitignore +1 -0
- data/.rubocop.yml +26 -1
- data/CHANGELOG.md +241 -0
- data/Rakefile +54 -4
- data/config.yml +317 -0
- data/core/array.rbs +1756 -1591
- data/core/basic_object.rbs +38 -35
- data/core/comparable.rbs +1 -1
- data/core/complex.rbs +166 -94
- data/core/data.rbs +2 -2
- data/core/dir.rbs +2 -18
- data/core/encoding.rbs +12 -32
- data/core/enumerable.rbs +270 -266
- data/core/enumerator.rbs +14 -4
- data/core/env.rbs +1 -1
- data/core/errno.rbs +33 -16
- data/core/errors.rbs +6 -2
- data/core/exception.rbs +342 -167
- data/core/fiber.rbs +3 -2
- data/core/file.rbs +26 -75
- data/core/float.rbs +125 -72
- data/core/gc.rbs +158 -42
- data/core/hash.rbs +122 -143
- data/core/integer.rbs +79 -50
- data/core/io/buffer.rbs +49 -43
- data/core/io.rbs +108 -151
- data/core/kernel.rbs +341 -209
- data/core/match_data.rbs +76 -2
- data/core/math.rbs +0 -36
- data/core/method.rbs +2 -2
- data/core/module.rbs +32 -27
- data/core/nil_class.rbs +2 -2
- data/core/numeric.rbs +101 -104
- data/core/object.rbs +1 -5
- data/core/object_space/weak_key_map.rbs +3 -4
- data/core/object_space.rbs +3 -3
- data/core/proc.rbs +82 -14
- data/core/process.rbs +110 -58
- data/core/ractor.rbs +57 -4
- data/core/range.rbs +114 -87
- data/core/rational.rbs +0 -2
- data/core/rbs/unnamed/argf.rbs +237 -36
- data/core/rbs/unnamed/env_class.rbs +35 -53
- data/core/rbs/unnamed/random.rbs +1 -2
- data/core/regexp.rbs +10 -56
- data/core/ruby_vm.rbs +88 -9
- data/core/rubygems/config_file.rbs +3 -0
- data/core/rubygems/errors.rbs +3 -6
- data/core/rubygems/platform.rbs +0 -9
- data/core/rubygems/rubygems.rbs +3 -6
- data/core/rubygems/version.rbs +8 -8
- data/core/set.rbs +4 -16
- data/core/string.rbs +271 -264
- data/core/struct.rbs +6 -18
- data/core/symbol.rbs +14 -21
- data/core/thread.rbs +32 -35
- data/core/time.rbs +131 -50
- data/core/trace_point.rbs +124 -113
- data/core/true_class.rbs +0 -1
- data/core/unbound_method.rbs +1 -1
- data/core/warning.rbs +9 -2
- data/docs/architecture.md +1 -1
- data/docs/syntax.md +17 -10
- data/ext/rbs_extension/extconf.rb +11 -0
- data/ext/rbs_extension/location.c +61 -29
- data/ext/rbs_extension/location.h +4 -3
- data/ext/rbs_extension/main.c +23 -1
- data/ext/rbs_extension/parser.c +506 -517
- data/ext/rbs_extension/parserstate.c +109 -30
- data/ext/rbs_extension/parserstate.h +6 -4
- data/ext/rbs_extension/rbs_extension.h +1 -10
- data/{ext/rbs_extension → include/rbs}/constants.h +21 -19
- data/include/rbs/ruby_objs.h +72 -0
- data/include/rbs/util/rbs_constant_pool.h +219 -0
- data/include/rbs.h +7 -0
- data/lib/rbs/annotate/annotations.rb +3 -3
- data/lib/rbs/annotate/rdoc_source.rb +2 -2
- data/lib/rbs/ast/declarations.rb +9 -4
- data/lib/rbs/ast/directives.rb +10 -0
- data/lib/rbs/ast/members.rb +2 -0
- data/lib/rbs/ast/type_param.rb +2 -12
- data/lib/rbs/cli/diff.rb +3 -3
- data/lib/rbs/cli/validate.rb +2 -1
- data/lib/rbs/cli.rb +16 -16
- data/lib/rbs/collection/config/lockfile_generator.rb +58 -8
- data/lib/rbs/collection/config.rb +5 -3
- data/lib/rbs/collection/sources/rubygems.rb +1 -1
- data/lib/rbs/collection.rb +1 -0
- data/lib/rbs/definition.rb +51 -34
- data/lib/rbs/definition_builder/ancestor_builder.rb +5 -3
- data/lib/rbs/definition_builder.rb +83 -24
- data/lib/rbs/environment.rb +33 -18
- data/lib/rbs/environment_loader.rb +6 -1
- data/lib/rbs/errors.rb +24 -0
- data/lib/rbs/locator.rb +2 -0
- data/lib/rbs/method_type.rb +2 -0
- data/lib/rbs/namespace.rb +1 -0
- data/lib/rbs/parser_aux.rb +40 -3
- data/lib/rbs/prototype/rb.rb +20 -12
- data/lib/rbs/prototype/rbi.rb +11 -6
- data/lib/rbs/prototype/runtime/value_object_generator.rb +7 -5
- data/lib/rbs/prototype/runtime.rb +7 -5
- data/lib/rbs/subtractor.rb +3 -3
- data/lib/rbs/test/hook.rb +47 -42
- data/lib/rbs/test/type_check.rb +7 -5
- data/lib/rbs/type_name.rb +14 -9
- data/lib/rbs/types.rb +63 -14
- data/lib/rbs/unit_test/spy.rb +4 -2
- data/lib/rbs/unit_test/type_assertions.rb +19 -13
- data/lib/rbs/unit_test/with_aliases.rb +3 -1
- data/lib/rbs/validator.rb +7 -1
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +10 -5
- data/lib/rbs.rb +1 -0
- data/lib/rdoc_plugin/parser.rb +2 -2
- data/rbs.gemspec +6 -2
- data/sig/ancestor_graph.rbs +5 -5
- data/sig/annotate/rdoc_source.rbs +2 -0
- data/sig/cli.rbs +2 -0
- data/sig/collection/config/lockfile_generator.rbs +9 -1
- data/sig/declarations.rbs +10 -3
- data/sig/definition.rbs +80 -12
- data/sig/definition_builder.rbs +18 -4
- data/sig/directives.rbs +17 -1
- data/sig/environment.rbs +3 -1
- data/sig/errors.rbs +19 -0
- data/sig/namespace.rbs +2 -3
- data/sig/parser.rbs +5 -1
- data/sig/prototype/rb.rbs +1 -1
- data/sig/resolver/constant_resolver.rbs +2 -2
- data/sig/resolver/context.rbs +1 -1
- data/sig/subtractor.rbs +1 -1
- data/sig/test/type_check.rbs +2 -2
- data/sig/type_alias_dependency.rbs +2 -2
- data/sig/type_alias_regularity.rbs +6 -6
- data/sig/type_param.rbs +4 -4
- data/sig/typename.rbs +8 -5
- data/sig/types.rbs +1 -1
- data/sig/unit_test/spy.rbs +2 -0
- data/sig/unit_test/type_assertions.rbs +2 -0
- data/sig/use_map.rbs +1 -1
- data/sig/validator.rbs +6 -2
- data/sig/vendorer.rbs +1 -1
- data/sig/writer.rbs +1 -1
- data/{ext/rbs_extension → src}/constants.c +35 -36
- data/src/ruby_objs.c +799 -0
- data/src/util/rbs_constant_pool.c +342 -0
- data/stdlib/base64/0/base64.rbs +0 -9
- data/stdlib/benchmark/0/benchmark.rbs +11 -2
- data/stdlib/bigdecimal/0/big_decimal.rbs +26 -182
- data/stdlib/cgi/0/core.rbs +60 -3
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/coverage/0/coverage.rbs +0 -3
- data/stdlib/csv/0/csv.rbs +18 -58
- data/stdlib/csv/0/manifest.yaml +1 -0
- data/stdlib/date/0/date.rbs +27 -42
- data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -6
- data/stdlib/digest/0/digest.rbs +25 -2
- data/stdlib/erb/0/erb.rbs +0 -1
- data/stdlib/etc/0/etc.rbs +51 -34
- data/stdlib/fileutils/0/fileutils.rbs +3 -44
- data/stdlib/io-console/0/io-console.rbs +69 -15
- data/stdlib/ipaddr/0/ipaddr.rbs +16 -4
- data/stdlib/json/0/json.rbs +107 -120
- data/stdlib/logger/0/log_device.rbs +1 -1
- data/stdlib/logger/0/logger.rbs +3 -18
- data/stdlib/minitest/0/kernel.rbs +2 -2
- data/stdlib/minitest/0/minitest/abstract_reporter.rbs +4 -1
- data/stdlib/minitest/0/minitest/assertion.rbs +1 -0
- data/stdlib/minitest/0/minitest/assertions.rbs +58 -13
- data/stdlib/minitest/0/minitest/backtrace_filter.rbs +7 -0
- data/stdlib/minitest/0/minitest/bench_spec.rbs +8 -8
- data/stdlib/minitest/0/minitest/benchmark.rbs +17 -16
- data/stdlib/minitest/0/minitest/compress.rbs +13 -0
- data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
- data/stdlib/minitest/0/minitest/mock.rbs +9 -5
- data/stdlib/minitest/0/minitest/parallel/executor.rbs +4 -0
- data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +0 -1
- data/stdlib/minitest/0/minitest/pride_io.rbs +8 -0
- data/stdlib/minitest/0/minitest/pride_lol.rbs +2 -0
- data/stdlib/minitest/0/minitest/progress_reporter.rbs +1 -1
- data/stdlib/minitest/0/minitest/reportable.rbs +2 -0
- data/stdlib/minitest/0/minitest/runnable.rbs +33 -1
- data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +1 -1
- data/stdlib/minitest/0/minitest/spec/dsl.rbs +10 -6
- data/stdlib/minitest/0/minitest/spec.rbs +1 -1
- data/stdlib/minitest/0/minitest/statistics_reporter.rbs +5 -0
- data/stdlib/minitest/0/minitest/summary_reporter.rbs +0 -7
- data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +1 -1
- data/stdlib/minitest/0/minitest/test.rbs +7 -14
- data/stdlib/minitest/0/minitest/unexpected_error.rbs +2 -0
- data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
- data/stdlib/minitest/0/minitest/unit.rbs +1 -2
- data/stdlib/minitest/0/minitest.rbs +41 -892
- data/stdlib/monitor/0/monitor.rbs +13 -4
- data/stdlib/net-http/0/net-http.rbs +42 -109
- data/stdlib/nkf/0/nkf.rbs +30 -0
- data/stdlib/objspace/0/objspace.rbs +1 -2
- data/stdlib/observable/0/observable.rbs +1 -1
- data/stdlib/open-uri/0/manifest.yaml +1 -0
- data/stdlib/open-uri/0/open-uri.rbs +52 -0
- data/stdlib/open3/0/open3.rbs +0 -8
- data/stdlib/openssl/0/manifest.yaml +1 -0
- data/stdlib/openssl/0/openssl.rbs +235 -143
- data/stdlib/optparse/0/optparse.rbs +58 -18
- data/stdlib/pathname/0/pathname.rbs +2 -8
- data/stdlib/pp/0/pp.rbs +3 -1
- data/stdlib/prettyprint/0/prettyprint.rbs +0 -4
- data/stdlib/pstore/0/pstore.rbs +0 -6
- data/stdlib/psych/0/core_ext.rbs +12 -0
- data/stdlib/psych/0/psych.rbs +15 -4
- data/stdlib/pty/0/pty.rbs +46 -4
- data/stdlib/rdoc/0/code_object.rbs +0 -4
- data/stdlib/rdoc/0/markup.rbs +10 -12
- data/stdlib/rdoc/0/rdoc.rbs +13 -8
- data/stdlib/resolv/0/resolv.rbs +21 -12
- data/stdlib/ripper/0/ripper.rbs +0 -2
- data/stdlib/securerandom/0/securerandom.rbs +7 -2
- data/stdlib/shellwords/0/shellwords.rbs +11 -12
- data/stdlib/singleton/0/singleton.rbs +0 -1
- data/stdlib/socket/0/addrinfo.rbs +1 -2
- data/stdlib/socket/0/basic_socket.rbs +0 -5
- data/stdlib/socket/0/socket.rbs +32 -27
- data/stdlib/socket/0/tcp_server.rbs +0 -3
- data/stdlib/socket/0/tcp_socket.rbs +36 -3
- data/stdlib/socket/0/udp_socket.rbs +0 -1
- data/stdlib/socket/0/unix_server.rbs +0 -3
- data/stdlib/socket/0/unix_socket.rbs +4 -2
- data/{core/string_io.rbs → stdlib/stringio/0/stringio.rbs} +1 -1
- data/stdlib/strscan/0/string_scanner.rbs +1265 -422
- data/stdlib/tempfile/0/tempfile.rbs +135 -28
- data/stdlib/time/0/time.rbs +48 -35
- data/stdlib/timeout/0/timeout.rbs +11 -8
- data/stdlib/tmpdir/0/tmpdir.rbs +10 -3
- data/stdlib/tsort/0/tsort.rbs +0 -4
- data/stdlib/uri/0/common.rbs +28 -30
- data/stdlib/uri/0/ftp.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +22 -18
- data/stdlib/uri/0/http.rbs +2 -2
- data/stdlib/uri/0/rfc2396_parser.rbs +3 -0
- data/stdlib/zlib/0/buf_error.rbs +1 -70
- data/stdlib/zlib/0/data_error.rbs +1 -70
- data/stdlib/zlib/0/deflate.rbs +8 -72
- data/stdlib/zlib/0/error.rbs +1 -70
- data/stdlib/zlib/0/gzip_file/crc_error.rbs +2 -105
- data/stdlib/zlib/0/gzip_file/error.rbs +2 -105
- data/stdlib/zlib/0/gzip_file/length_error.rbs +2 -105
- data/stdlib/zlib/0/gzip_file/no_footer.rbs +2 -105
- data/stdlib/zlib/0/gzip_file.rbs +1 -71
- data/stdlib/zlib/0/gzip_reader.rbs +3 -74
- data/stdlib/zlib/0/gzip_writer.rbs +1 -70
- data/stdlib/zlib/0/inflate.rbs +4 -71
- data/stdlib/zlib/0/mem_error.rbs +1 -70
- data/stdlib/zlib/0/need_dict.rbs +1 -70
- data/stdlib/zlib/0/stream_end.rbs +1 -70
- data/stdlib/zlib/0/stream_error.rbs +1 -70
- data/stdlib/zlib/0/version_error.rbs +1 -70
- data/stdlib/zlib/0/zlib.rbs +0 -2
- data/stdlib/zlib/0/zstream.rbs +4 -72
- metadata +17 -13
- data/ext/rbs_extension/ruby_objs.c +0 -602
- data/ext/rbs_extension/ruby_objs.h +0 -51
- 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
|
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
|
-
#
|
7
|
+
# Use TracePoint to gather information specifically for exceptions:
|
8
8
|
#
|
9
9
|
# trace = TracePoint.new(:raise) do |tp|
|
10
|
-
#
|
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
|
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
|
26
|
-
# change. Instead, it is recommended
|
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
|
-
# :
|
31
|
+
# : Execute an expression or statement on a new line.
|
32
|
+
#
|
33
33
|
# `:class`
|
34
|
-
# :
|
34
|
+
# : Start a class or module definition.
|
35
|
+
#
|
35
36
|
# `:end`
|
36
|
-
# :
|
37
|
+
# : Finish a class or module definition.
|
38
|
+
#
|
37
39
|
# `:call`
|
38
|
-
# :
|
40
|
+
# : Call a Ruby method.
|
41
|
+
#
|
39
42
|
# `:return`
|
40
|
-
# :
|
43
|
+
# : Return from a Ruby method.
|
44
|
+
#
|
41
45
|
# `:c_call`
|
42
|
-
# :
|
46
|
+
# : Call a C-language routine.
|
47
|
+
#
|
43
48
|
# `:c_return`
|
44
|
-
# :
|
49
|
+
# : Return from a C-language routine.
|
50
|
+
#
|
45
51
|
# `:raise`
|
46
|
-
# :
|
52
|
+
# : Raise an exception.
|
53
|
+
#
|
47
54
|
# `:rescue`
|
48
|
-
# :
|
55
|
+
# : Rescue an exception.
|
56
|
+
#
|
49
57
|
# `:b_call`
|
50
|
-
# :
|
58
|
+
# : Event hook at block entry.
|
59
|
+
#
|
51
60
|
# `:b_return`
|
52
|
-
# :
|
61
|
+
# : Event hook at block ending.
|
62
|
+
#
|
53
63
|
# `:a_call`
|
54
|
-
# :
|
64
|
+
# : Event hook at all calls (`call`, `b_call`, and `c_call`).
|
65
|
+
#
|
55
66
|
# `:a_return`
|
56
|
-
# :
|
67
|
+
# : Event hook at all returns (`return`, `b_return`, and `c_return`).
|
68
|
+
#
|
57
69
|
# `:thread_begin`
|
58
|
-
# :
|
70
|
+
# : Event hook at thread beginning.
|
71
|
+
#
|
59
72
|
# `:thread_end`
|
60
|
-
# :
|
73
|
+
# : Event hook at thread ending.
|
74
|
+
#
|
61
75
|
# `:fiber_switch`
|
62
|
-
# :
|
76
|
+
# : Event hook at fiber switch.
|
77
|
+
#
|
63
78
|
# `:script_compiled`
|
64
|
-
# :
|
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) { |
|
84
|
+
# - TracePoint.new(*events) { |tp| block } -> tp
|
70
85
|
# -->
|
71
86
|
# Returns a new TracePoint object, not enabled by default.
|
72
87
|
#
|
73
|
-
#
|
88
|
+
# To activate the TracePoint object, use TracePoint#enable:
|
74
89
|
#
|
75
90
|
# trace = TracePoint.new(:call) do |tp|
|
76
|
-
#
|
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
|
-
#
|
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
|
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
|
-
#
|
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
|
-
#
|
120
|
-
# are not called to avoid confusion
|
121
|
-
# reentrance
|
122
|
-
#
|
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
|
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__ #
|
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__ #
|
153
|
-
# next if (__LINE__..__LINE__+3).cover?(tp.lineno) #
|
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
|
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
|
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
|
184
|
-
#
|
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) { |
|
205
|
+
# - TracePoint.trace(*events) { |tp| block } -> obj
|
193
206
|
# -->
|
194
|
-
# A convenience method for TracePoint.new
|
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?
|
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
|
-
#
|
221
|
+
# Returns the generated binding object from the event.
|
209
222
|
#
|
210
|
-
# Note that for `:c_call` and `:c_return` events, the method
|
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
|
-
#
|
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
|
-
#
|
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
|
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
|
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
|
-
#
|
282
|
+
# Returns `true` if the trace was enabled. Returns `false` if the trace was
|
283
|
+
# disabled.
|
270
284
|
#
|
271
|
-
# trace.enabled?
|
272
|
-
# trace.disable
|
273
|
-
# trace.enabled?
|
274
|
-
# trace.disable
|
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
|
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
|
-
#
|
284
|
-
#
|
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)
|
301
|
-
# - trace.enable(target: nil, target_line: nil, target_thread: :default) { block }
|
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
|
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
|
315
|
-
# target and target_line are both nil, then target_thread will
|
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
|
-
# #
|
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
|
330
|
-
# tracing
|
331
|
-
#
|
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
|
-
# #
|
357
|
+
# # Prints #<TracePoint:line test.rb:4 in `m1'>
|
347
358
|
# m2
|
348
|
-
# #
|
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?
|
371
|
+
# - trace.enabled? -> true or false
|
361
372
|
# -->
|
362
|
-
#
|
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
|
-
#
|
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
|
389
|
+
# - trace.inspect -> string
|
379
390
|
# -->
|
380
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
413
|
-
# belongs to.
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
449
|
+
# Returns the trace object during the event.
|
439
450
|
#
|
440
|
-
#
|
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
|
-
#
|
452
|
-
# event. If loaded from a file, it
|
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
|
-
#
|
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
|
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
data/core/unbound_method.rbs
CHANGED
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
|
-
|
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_ ::=
|
409
|
-
|
|
410
|
-
|
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_
|
420
|
-
| _visibility_ _attribute-type_ _method-name_ `(` _ivar-name_ `) :` _type_
|
421
|
-
| _visibility_ _attribute-type_ _method-name_ `() :` _type_
|
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_
|
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'
|