steep 0.14.0 → 0.16.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +0 -3
  3. data/CHANGELOG.md +25 -0
  4. data/Rakefile +0 -13
  5. data/bin/setup +0 -2
  6. data/bin/smoke_runner.rb +0 -1
  7. data/exe/steep +0 -1
  8. data/lib/steep.rb +18 -2
  9. data/lib/steep/annotation_parser.rb +4 -4
  10. data/lib/steep/ast/buffer.rb +11 -7
  11. data/lib/steep/ast/builtin.rb +8 -0
  12. data/lib/steep/ast/types/factory.rb +55 -55
  13. data/lib/steep/cli.rb +16 -1
  14. data/lib/steep/drivers/annotations.rb +1 -1
  15. data/lib/steep/drivers/check.rb +20 -4
  16. data/lib/steep/drivers/langserver.rb +13 -457
  17. data/lib/steep/drivers/utils/driver_helper.rb +1 -1
  18. data/lib/steep/drivers/vendor.rb +2 -2
  19. data/lib/steep/drivers/watch.rb +97 -85
  20. data/lib/steep/drivers/worker.rb +51 -0
  21. data/lib/steep/project.rb +9 -5
  22. data/lib/steep/project/completion_provider.rb +9 -13
  23. data/lib/steep/project/dsl.rb +14 -0
  24. data/lib/steep/project/file.rb +43 -46
  25. data/lib/steep/project/hover_content.rb +17 -8
  26. data/lib/steep/project/options.rb +25 -3
  27. data/lib/steep/project/target.rb +40 -24
  28. data/lib/steep/server/base_worker.rb +56 -0
  29. data/lib/steep/server/code_worker.rb +151 -0
  30. data/lib/steep/server/interaction_worker.rb +281 -0
  31. data/lib/steep/server/master.rb +196 -0
  32. data/lib/steep/server/signature_worker.rb +148 -0
  33. data/lib/steep/server/utils.rb +36 -0
  34. data/lib/steep/server/worker_process.rb +62 -0
  35. data/lib/steep/signature/errors.rb +1 -1
  36. data/lib/steep/signature/validator.rb +13 -13
  37. data/lib/steep/source.rb +1 -1
  38. data/lib/steep/type_construction.rb +996 -726
  39. data/lib/steep/type_inference/constant_env.rb +3 -11
  40. data/lib/steep/type_inference/context.rb +8 -3
  41. data/lib/steep/type_inference/context_array.rb +111 -0
  42. data/lib/steep/type_inference/local_variable_type_env.rb +226 -0
  43. data/lib/steep/type_inference/logic.rb +130 -0
  44. data/lib/steep/type_inference/type_env.rb +5 -69
  45. data/lib/steep/typing.rb +79 -22
  46. data/lib/steep/version.rb +1 -1
  47. data/smoke/alias/Steepfile +1 -0
  48. data/smoke/and/Steepfile +1 -0
  49. data/smoke/array/Steepfile +1 -0
  50. data/smoke/array/b.rb +0 -2
  51. data/smoke/block/Steepfile +1 -0
  52. data/smoke/case/Steepfile +1 -0
  53. data/smoke/class/Steepfile +1 -0
  54. data/smoke/const/Steepfile +1 -0
  55. data/smoke/dstr/Steepfile +1 -0
  56. data/smoke/ensure/Steepfile +1 -0
  57. data/smoke/enumerator/Steepfile +1 -0
  58. data/smoke/extension/Steepfile +1 -0
  59. data/smoke/extension/c.rb +1 -0
  60. data/smoke/hash/Steepfile +1 -0
  61. data/smoke/hello/Steepfile +1 -0
  62. data/smoke/if/Steepfile +1 -0
  63. data/smoke/if/a.rb +1 -1
  64. data/smoke/implements/Steepfile +1 -0
  65. data/smoke/initialize/Steepfile +1 -0
  66. data/smoke/integer/Steepfile +1 -0
  67. data/smoke/interface/Steepfile +1 -0
  68. data/smoke/kwbegin/Steepfile +1 -0
  69. data/smoke/lambda/Steepfile +1 -0
  70. data/smoke/literal/Steepfile +1 -0
  71. data/smoke/map/Steepfile +1 -0
  72. data/smoke/method/Steepfile +1 -0
  73. data/smoke/module/Steepfile +1 -0
  74. data/smoke/regexp/Steepfile +1 -0
  75. data/smoke/regression/Steepfile +1 -0
  76. data/smoke/rescue/Steepfile +1 -0
  77. data/smoke/rescue/a.rb +1 -1
  78. data/smoke/self/Steepfile +1 -0
  79. data/smoke/skip/Steepfile +1 -0
  80. data/smoke/stdout/Steepfile +1 -0
  81. data/smoke/super/Steepfile +1 -0
  82. data/smoke/type_case/Steepfile +1 -0
  83. data/smoke/yield/Steepfile +1 -0
  84. data/steep.gemspec +7 -8
  85. metadata +26 -141
  86. data/exe/rbs +0 -3
  87. data/exe/ruby-signature +0 -3
  88. data/vendor/ruby-signature/.github/workflows/ruby.yml +0 -27
  89. data/vendor/ruby-signature/.gitignore +0 -12
  90. data/vendor/ruby-signature/.rubocop.yml +0 -15
  91. data/vendor/ruby-signature/BSDL +0 -22
  92. data/vendor/ruby-signature/COPYING +0 -56
  93. data/vendor/ruby-signature/Gemfile +0 -6
  94. data/vendor/ruby-signature/README.md +0 -93
  95. data/vendor/ruby-signature/Rakefile +0 -67
  96. data/vendor/ruby-signature/bin/annotate-with-rdoc +0 -156
  97. data/vendor/ruby-signature/bin/console +0 -14
  98. data/vendor/ruby-signature/bin/query-rdoc +0 -103
  99. data/vendor/ruby-signature/bin/setup +0 -10
  100. data/vendor/ruby-signature/bin/sort +0 -88
  101. data/vendor/ruby-signature/bin/test_runner.rb +0 -17
  102. data/vendor/ruby-signature/docs/CONTRIBUTING.md +0 -97
  103. data/vendor/ruby-signature/docs/sigs.md +0 -148
  104. data/vendor/ruby-signature/docs/stdlib.md +0 -152
  105. data/vendor/ruby-signature/docs/syntax.md +0 -528
  106. data/vendor/ruby-signature/exe/rbs +0 -3
  107. data/vendor/ruby-signature/exe/ruby-signature +0 -7
  108. data/vendor/ruby-signature/lib/ruby/signature.rb +0 -64
  109. data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +0 -29
  110. data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +0 -29
  111. data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +0 -391
  112. data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +0 -364
  113. data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +0 -52
  114. data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +0 -54
  115. data/vendor/ruby-signature/lib/ruby/signature/cli.rb +0 -555
  116. data/vendor/ruby-signature/lib/ruby/signature/constant.rb +0 -28
  117. data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +0 -152
  118. data/vendor/ruby-signature/lib/ruby/signature/definition.rb +0 -172
  119. data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +0 -921
  120. data/vendor/ruby-signature/lib/ruby/signature/environment.rb +0 -283
  121. data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +0 -138
  122. data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +0 -126
  123. data/vendor/ruby-signature/lib/ruby/signature/errors.rb +0 -189
  124. data/vendor/ruby-signature/lib/ruby/signature/location.rb +0 -104
  125. data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +0 -125
  126. data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +0 -93
  127. data/vendor/ruby-signature/lib/ruby/signature/parser.y +0 -1344
  128. data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +0 -444
  129. data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +0 -579
  130. data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +0 -383
  131. data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +0 -48
  132. data/vendor/ruby-signature/lib/ruby/signature/test.rb +0 -28
  133. data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +0 -63
  134. data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +0 -290
  135. data/vendor/ruby-signature/lib/ruby/signature/test/setup.rb +0 -58
  136. data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +0 -327
  137. data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +0 -185
  138. data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +0 -256
  139. data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +0 -72
  140. data/vendor/ruby-signature/lib/ruby/signature/types.rb +0 -932
  141. data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +0 -140
  142. data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +0 -49
  143. data/vendor/ruby-signature/lib/ruby/signature/version.rb +0 -5
  144. data/vendor/ruby-signature/lib/ruby/signature/writer.rb +0 -271
  145. data/vendor/ruby-signature/ruby-signature.gemspec +0 -45
  146. data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +0 -3
  147. data/vendor/ruby-signature/stdlib/base64/base64.rbs +0 -15
  148. data/vendor/ruby-signature/stdlib/builtin/array.rbs +0 -1997
  149. data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +0 -280
  150. data/vendor/ruby-signature/stdlib/builtin/binding.rbs +0 -177
  151. data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +0 -35
  152. data/vendor/ruby-signature/stdlib/builtin/class.rbs +0 -145
  153. data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +0 -116
  154. data/vendor/ruby-signature/stdlib/builtin/complex.rbs +0 -400
  155. data/vendor/ruby-signature/stdlib/builtin/constants.rbs +0 -37
  156. data/vendor/ruby-signature/stdlib/builtin/data.rbs +0 -5
  157. data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +0 -2
  158. data/vendor/ruby-signature/stdlib/builtin/dir.rbs +0 -419
  159. data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +0 -606
  160. data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +0 -404
  161. data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +0 -260
  162. data/vendor/ruby-signature/stdlib/builtin/errno.rbs +0 -781
  163. data/vendor/ruby-signature/stdlib/builtin/errors.rbs +0 -582
  164. data/vendor/ruby-signature/stdlib/builtin/exception.rbs +0 -193
  165. data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +0 -40
  166. data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +0 -68
  167. data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +0 -12
  168. data/vendor/ruby-signature/stdlib/builtin/file.rbs +0 -476
  169. data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +0 -59
  170. data/vendor/ruby-signature/stdlib/builtin/float.rbs +0 -696
  171. data/vendor/ruby-signature/stdlib/builtin/gc.rbs +0 -121
  172. data/vendor/ruby-signature/stdlib/builtin/hash.rbs +0 -1029
  173. data/vendor/ruby-signature/stdlib/builtin/integer.rbs +0 -710
  174. data/vendor/ruby-signature/stdlib/builtin/io.rbs +0 -683
  175. data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +0 -574
  176. data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +0 -135
  177. data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +0 -271
  178. data/vendor/ruby-signature/stdlib/builtin/math.rbs +0 -66
  179. data/vendor/ruby-signature/stdlib/builtin/method.rbs +0 -182
  180. data/vendor/ruby-signature/stdlib/builtin/module.rbs +0 -248
  181. data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +0 -82
  182. data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +0 -409
  183. data/vendor/ruby-signature/stdlib/builtin/object.rbs +0 -824
  184. data/vendor/ruby-signature/stdlib/builtin/proc.rbs +0 -426
  185. data/vendor/ruby-signature/stdlib/builtin/process.rbs +0 -354
  186. data/vendor/ruby-signature/stdlib/builtin/random.rbs +0 -93
  187. data/vendor/ruby-signature/stdlib/builtin/range.rbs +0 -226
  188. data/vendor/ruby-signature/stdlib/builtin/rational.rbs +0 -424
  189. data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +0 -10
  190. data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +0 -1083
  191. data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +0 -14
  192. data/vendor/ruby-signature/stdlib/builtin/signal.rbs +0 -55
  193. data/vendor/ruby-signature/stdlib/builtin/string.rbs +0 -1894
  194. data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +0 -13
  195. data/vendor/ruby-signature/stdlib/builtin/struct.rbs +0 -40
  196. data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +0 -230
  197. data/vendor/ruby-signature/stdlib/builtin/thread.rbs +0 -1112
  198. data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +0 -23
  199. data/vendor/ruby-signature/stdlib/builtin/time.rbs +0 -739
  200. data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +0 -91
  201. data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +0 -46
  202. data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +0 -159
  203. data/vendor/ruby-signature/stdlib/builtin/warning.rbs +0 -17
  204. data/vendor/ruby-signature/stdlib/erb/erb.rbs +0 -18
  205. data/vendor/ruby-signature/stdlib/find/find.rbs +0 -44
  206. data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +0 -21
  207. data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +0 -23
  208. data/vendor/ruby-signature/stdlib/prime/prime.rbs +0 -188
  209. data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +0 -9
  210. data/vendor/ruby-signature/stdlib/set/set.rbs +0 -77
  211. data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +0 -53
@@ -1,135 +0,0 @@
1
- # The marshaling library converts collections of Ruby objects into a byte
2
- # stream, allowing them to be stored outside the currently active script.
3
- # This data may subsequently be read and the original objects
4
- # reconstituted.
5
- #
6
- # Marshaled data has major and minor version numbers stored along with the
7
- # object information. In normal use, marshaling can only load data written
8
- # with the same major version number and an equal or lower minor version
9
- # number. If Ruby’s “verbose” flag is set (normally using -d, -v, -w, or
10
- # –verbose) the major and minor numbers must match exactly.
11
- # [Marshal](Marshal) versioning is independent of
12
- # Ruby’s version numbers. You can extract the version by reading the
13
- # first two bytes of marshaled data.
14
- #
15
- # ```ruby
16
- # str = Marshal.dump("thing")
17
- # RUBY_VERSION #=> "1.9.0"
18
- # str[0].ord #=> 4
19
- # str[1].ord #=> 8
20
- # ```
21
- #
22
- # Some objects cannot be dumped: if the objects to be dumped include
23
- # bindings, procedure or method objects, instances of class
24
- # [IO](https://ruby-doc.org/core-2.6.3/IO.html), or singleton objects, a
25
- # [TypeError](https://ruby-doc.org/core-2.6.3/TypeError.html) will be
26
- # raised.
27
- #
28
- # If your class has special serialization needs (for example, if you want
29
- # to serialize in some specific format), or if it contains objects that
30
- # would otherwise not be serializable, you can implement your own
31
- # serialization strategy.
32
- #
33
- # There are two methods of doing this, your object can define either
34
- # marshal\_dump and marshal\_load or \_dump and \_load. marshal\_dump will
35
- # take precedence over \_dump if both are defined. marshal\_dump may
36
- # result in smaller [Marshal](Marshal) strings.
37
- #
38
- #
39
- # By design, [::load](Marshal#method-c-load) can
40
- # deserialize almost any class loaded into the Ruby process. In many cases
41
- # this can lead to remote code execution if the
42
- # [Marshal](Marshal) data is loaded from an untrusted
43
- # source.
44
- #
45
- # As a result, [::load](Marshal#method-c-load) is not
46
- # suitable as a general purpose serialization format and you should never
47
- # unmarshal user supplied input or other untrusted data.
48
- #
49
- # If you need to deserialize untrusted data, use JSON or another
50
- # serialization format that is only able to load simple, ‘primitive’ types
51
- # such as [String](https://ruby-doc.org/core-2.6.3/String.html),
52
- # [Array](https://ruby-doc.org/core-2.6.3/Array.html),
53
- # [Hash](https://ruby-doc.org/core-2.6.3/Hash.html), etc. Never allow
54
- # user input to specify arbitrary types to deserialize into.
55
- #
56
- #
57
- # When dumping an object the method marshal\_dump will be called.
58
- # marshal\_dump must return a result containing the information necessary
59
- # for marshal\_load to reconstitute the object. The result can be any
60
- # object.
61
- #
62
- # When loading an object dumped using marshal\_dump the object is first
63
- # allocated then marshal\_load is called with the result from
64
- # marshal\_dump. marshal\_load must recreate the object from the
65
- # information in the result.
66
- #
67
- # Example:
68
- #
69
- # ```ruby
70
- # class MyObj
71
- # def initialize name, version, data
72
- # @name = name
73
- # @version = version
74
- # @data = data
75
- # end
76
- #
77
- # def marshal_dump
78
- # [@name, @version]
79
- # end
80
- #
81
- # def marshal_load array
82
- # @name, @version = array
83
- # end
84
- # end
85
- # ```
86
- #
87
- #
88
- # Use \_dump and \_load when you need to allocate the object you’re
89
- # restoring yourself.
90
- #
91
- # When dumping an object the instance method \_dump is called with an
92
- # [Integer](https://ruby-doc.org/core-2.6.3/Integer.html) which indicates
93
- # the maximum depth of objects to dump (a value of -1 implies that you
94
- # should disable depth checking). \_dump must return a
95
- # [String](https://ruby-doc.org/core-2.6.3/String.html) containing the
96
- # information necessary to reconstitute the object.
97
- #
98
- # The class method \_load should take a
99
- # [String](https://ruby-doc.org/core-2.6.3/String.html) and use it to
100
- # return an object of the same class.
101
- #
102
- # Example:
103
- #
104
- # ```ruby
105
- # class MyObj
106
- # def initialize name, version, data
107
- # @name = name
108
- # @version = version
109
- # @data = data
110
- # end
111
- #
112
- # def _dump level
113
- # [@name, @version].join ':'
114
- # end
115
- #
116
- # def self._load args
117
- # new(*args.split(':'))
118
- # end
119
- # end
120
- # ```
121
- #
122
- # Since [::dump](Marshal#method-c-dump) outputs a
123
- # string you can have \_dump return a
124
- # [Marshal](Marshal) string which is Marshal.loaded in
125
- # \_load for complex objects.
126
- module Marshal
127
- def self.dump: (Object arg0, ?IO arg1, ?Integer arg2) -> Object
128
- | (Object arg0, ?Integer arg1) -> Object
129
-
130
- def self.load: (String arg0, ?Proc arg1) -> Object
131
- end
132
-
133
- Marshal::MAJOR_VERSION: Integer
134
-
135
- Marshal::MINOR_VERSION: Integer
@@ -1,271 +0,0 @@
1
- # MatchData encapsulates the result of matching a Regexp against string. It is
2
- # returned by Regexp#match and String#match, and also stored in a global
3
- # variable returned by Regexp.last_match.
4
- #
5
- # Usage:
6
- #
7
- # url = 'https://docs.ruby-lang.org/en/2.5.0/MatchData.html'
8
- # m = url.match(/(\d\.?)+/) # => #<MatchData "2.5.0" 1:"0">
9
- # m.string # => "https://docs.ruby-lang.org/en/2.5.0/MatchData.html"
10
- # m.regexp # => /(\d\.?)+/
11
- # # entire matched substring:
12
- # m[0] # => "2.5.0"
13
- #
14
- # # Working with unnamed captures
15
- # m = url.match(%r{([^/]+)/([^/]+)\.html$})
16
- # m.captures # => ["2.5.0", "MatchData"]
17
- # m[1] # => "2.5.0"
18
- # m.values_at(1, 2) # => ["2.5.0", "MatchData"]
19
- #
20
- # # Working with named captures
21
- # m = url.match(%r{(?<version>[^/]+)/(?<module>[^/]+)\.html$})
22
- # m.captures # => ["2.5.0", "MatchData"]
23
- # m.named_captures # => {"version"=>"2.5.0", "module"=>"MatchData"}
24
- # m[:version] # => "2.5.0"
25
- # m.values_at(:version, :module)
26
- # # => ["2.5.0", "MatchData"]
27
- # # Numerical indexes are working, too
28
- # m[1] # => "2.5.0"
29
- # m.values_at(1, 2) # => ["2.5.0", "MatchData"]
30
- #
31
- # ## Global variables equivalence
32
- #
33
- # Parts of last MatchData (returned by Regexp.last_match) are also aliased as
34
- # global variables:
35
- #
36
- # * `$~` is Regexp.last_match;
37
- # * `$&` is [Regexp.last_match](0);
38
- # * `$1`, `$2`, and so on are [Regexp.last_match](i) (captures by number);
39
- # * `$`` is Regexp.last_match`.pre_match`;
40
- # * `$'` is Regexp.last_match`.post_match`;
41
- # * `$+` is [Regexp.last_match](-1) (the last capture).
42
- #
43
- #
44
- # See also "Special global variables" section in Regexp documentation.
45
- #
46
- class MatchData
47
- public
48
-
49
- # Equality---Two matchdata are equal if their target strings, patterns, and
50
- # matched positions are identical.
51
- #
52
- def ==: (untyped other) -> bool
53
-
54
- # Match Reference -- MatchData acts as an array, and may be accessed using the
55
- # normal array indexing techniques. `mtch[0]` is equivalent to the special
56
- # variable `$&`, and returns the entire matched string. `mtch[1]`, `mtch[2]`,
57
- # and so on return the values of the matched backreferences (portions of the
58
- # pattern between parentheses).
59
- #
60
- # m = /(.)(.)(\d+)(\d)/.match("THX1138.")
61
- # m #=> #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
62
- # m[0] #=> "HX1138"
63
- # m[1, 2] #=> ["H", "X"]
64
- # m[1..3] #=> ["H", "X", "113"]
65
- # m[-3, 2] #=> ["X", "113"]
66
- #
67
- # m = /(?<foo>a+)b/.match("ccaaab")
68
- # m #=> #<MatchData "aaab" foo:"aaa">
69
- # m["foo"] #=> "aaa"
70
- # m[:foo] #=> "aaa"
71
- #
72
- def []: (Integer idx) -> String?
73
- | (Integer start, Integer length) -> ::Array[String?]
74
- | (::Range[Integer] range) -> ::Array[String?]
75
- | (String | Symbol name) -> String?
76
-
77
- # Returns the offset of the start of the *n*th element of the match array in the
78
- # string. *n* can be a string or symbol to reference a named capture.
79
- #
80
- # m = /(.)(.)(\d+)(\d)/.match("THX1138.")
81
- # m.begin(0) #=> 1
82
- # m.begin(2) #=> 2
83
- #
84
- # m = /(?<foo>.)(.)(?<bar>.)/.match("hoge")
85
- # p m.begin(:foo) #=> 0
86
- # p m.begin(:bar) #=> 2
87
- #
88
- def begin: (Integer | String | Symbol n_or_name) -> Integer?
89
-
90
- # Returns the array of captures; equivalent to `mtch.to_a[1..-1]`.
91
- #
92
- # f1,f2,f3,f4 = /(.)(.)(\d+)(\d)/.match("THX1138.").captures
93
- # f1 #=> "H"
94
- # f2 #=> "X"
95
- # f3 #=> "113"
96
- # f4 #=> "8"
97
- #
98
- def captures: () -> ::Array[String?]
99
-
100
- # Returns the offset of the character immediately following the end of the *n*th
101
- # element of the match array in the string. *n* can be a string or symbol to
102
- # reference a named capture.
103
- #
104
- # m = /(.)(.)(\d+)(\d)/.match("THX1138.")
105
- # m.end(0) #=> 7
106
- # m.end(2) #=> 3
107
- #
108
- # m = /(?<foo>.)(.)(?<bar>.)/.match("hoge")
109
- # p m.end(:foo) #=> 1
110
- # p m.end(:bar) #=> 3
111
- #
112
- def `end`: (Integer | String | Symbol n_or_name) -> Integer?
113
-
114
- # Equality---Two matchdata are equal if their target strings, patterns, and
115
- # matched positions are identical.
116
- #
117
- def eql?: (untyped other) -> bool
118
-
119
- # Produce a hash based on the target string, regexp and matched positions of
120
- # this matchdata.
121
- #
122
- # See also Object#hash.
123
- #
124
- def hash: () -> Integer
125
-
126
- # Returns a printable version of *mtch*.
127
- #
128
- # puts /.$/.match("foo").inspect
129
- # #=> #<MatchData "o">
130
- #
131
- # puts /(.)(.)(.)/.match("foo").inspect
132
- # #=> #<MatchData "foo" 1:"f" 2:"o" 3:"o">
133
- #
134
- # puts /(.)(.)?(.)/.match("fo").inspect
135
- # #=> #<MatchData "fo" 1:"f" 2:nil 3:"o">
136
- #
137
- # puts /(?<foo>.)(?<bar>.)(?<baz>.)/.match("hoge").inspect
138
- # #=> #<MatchData "hog" foo:"h" bar:"o" baz:"g">
139
- #
140
- def inspect: () -> String
141
-
142
- # Returns the number of elements in the match array.
143
- #
144
- # m = /(.)(.)(\d+)(\d)/.match("THX1138.")
145
- # m.length #=> 5
146
- # m.size #=> 5
147
- #
148
- def length: () -> Integer
149
-
150
- # Returns a Hash using named capture.
151
- #
152
- # A key of the hash is a name of the named captures. A value of the hash is a
153
- # string of last successful capture of corresponding group.
154
- #
155
- # m = /(?<a>.)(?<b>.)/.match("01")
156
- # m.named_captures #=> {"a" => "0", "b" => "1"}
157
- #
158
- # m = /(?<a>.)(?<b>.)?/.match("0")
159
- # m.named_captures #=> {"a" => "0", "b" => nil}
160
- #
161
- # m = /(?<a>.)(?<a>.)/.match("01")
162
- # m.named_captures #=> {"a" => "1"}
163
- #
164
- # m = /(?<a>x)|(?<a>y)/.match("x")
165
- # m.named_captures #=> {"a" => "x"}
166
- #
167
- def named_captures: () -> ::Hash[String, String?]
168
-
169
- # Returns a list of names of captures as an array of strings. It is same as
170
- # mtch.regexp.names.
171
- #
172
- # /(?<foo>.)(?<bar>.)(?<baz>.)/.match("hoge").names
173
- # #=> ["foo", "bar", "baz"]
174
- #
175
- # m = /(?<x>.)(?<y>.)?/.match("a") #=> #<MatchData "a" x:"a" y:nil>
176
- # m.names #=> ["x", "y"]
177
- #
178
- def names: () -> ::Array[String]
179
-
180
- # Returns a two-element array containing the beginning and ending offsets of the
181
- # *n*th match. *n* can be a string or symbol to reference a named capture.
182
- #
183
- # m = /(.)(.)(\d+)(\d)/.match("THX1138.")
184
- # m.offset(0) #=> [1, 7]
185
- # m.offset(4) #=> [6, 7]
186
- #
187
- # m = /(?<foo>.)(.)(?<bar>.)/.match("hoge")
188
- # p m.offset(:foo) #=> [0, 1]
189
- # p m.offset(:bar) #=> [2, 3]
190
- #
191
- def offset: (Integer | Symbol | String n_or_name) -> ([ Integer, Integer ] | [ nil, nil ])
192
-
193
- # Returns the portion of the original string after the current match. Equivalent
194
- # to the special variable `$'`.
195
- #
196
- # m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
197
- # m.post_match #=> ": The Movie"
198
- #
199
- def post_match: () -> String
200
-
201
- # Returns the portion of the original string before the current match.
202
- # Equivalent to the special variable `$``.
203
- #
204
- # m = /(.)(.)(\d+)(\d)/.match("THX1138.")
205
- # m.pre_match #=> "T"
206
- #
207
- def pre_match: () -> String
208
-
209
- # Returns the regexp.
210
- #
211
- # m = /a.*b/.match("abc")
212
- # m.regexp #=> /a.*b/
213
- #
214
- def regexp: () -> Regexp
215
-
216
- # Returns the number of elements in the match array.
217
- #
218
- # m = /(.)(.)(\d+)(\d)/.match("THX1138.")
219
- # m.length #=> 5
220
- # m.size #=> 5
221
- #
222
- def size: () -> Integer
223
-
224
- # Returns a frozen copy of the string passed in to `match`.
225
- #
226
- # m = /(.)(.)(\d+)(\d)/.match("THX1138.")
227
- # m.string #=> "THX1138."
228
- #
229
- def string: () -> String
230
-
231
- # Returns the array of matches.
232
- #
233
- # m = /(.)(.)(\d+)(\d)/.match("THX1138.")
234
- # m.to_a #=> ["HX1138", "H", "X", "113", "8"]
235
- #
236
- # Because `to_a` is called when expanding `*`*variable*, there's a useful
237
- # assignment shortcut for extracting matched fields. This is slightly slower
238
- # than accessing the fields directly (as an intermediate array is generated).
239
- #
240
- # all,f1,f2,f3 = * /(.)(.)(\d+)(\d)/.match("THX1138.")
241
- # all #=> "HX1138"
242
- # f1 #=> "H"
243
- # f2 #=> "X"
244
- # f3 #=> "113"
245
- #
246
- def to_a: () -> ::Array[String?]
247
-
248
- # Returns the entire matched string.
249
- #
250
- # m = /(.)(.)(\d+)(\d)/.match("THX1138.")
251
- # m.to_s #=> "HX1138"
252
- #
253
- def to_s: () -> String
254
-
255
- # Uses each *index* to access the matching values, returning an array of the
256
- # corresponding matches.
257
- #
258
- # m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
259
- # m.to_a #=> ["HX1138", "H", "X", "113", "8"]
260
- # m.values_at(0, 2, -2) #=> ["HX1138", "X", "113"]
261
- #
262
- # m = /(?<a>\d+) *(?<op>[+\-*\/]) *(?<b>\d+)/.match("1 + 2")
263
- # m.to_a #=> ["1 + 2", "1", "+", "2"]
264
- # m.values_at(:a, :b, :op) #=> ["1", "2", "+"]
265
- #
266
- def values_at: (*Integer | Symbol | String n_or_name) -> ::Array[String?]
267
-
268
- private
269
-
270
- def initialize_copy: (self object) -> void
271
- end
@@ -1,66 +0,0 @@
1
- # The [Math](Math) module contains module functions
2
- # for basic trigonometric and transcendental functions. See class
3
- # [Float](https://ruby-doc.org/core-2.6.3/Float.html) for a list of
4
- # constants that define Ruby's floating point accuracy.
5
- #
6
- # Domains and codomains are given only for real (not complex) numbers.
7
- module Math
8
- def self.acos: (Integer | Float | Rational | BigDecimal x) -> Float
9
-
10
- def self.acosh: (Integer | Float | Rational | BigDecimal x) -> Float
11
-
12
- def self.asin: (Integer | Float | Rational | BigDecimal x) -> Float
13
-
14
- def self.asinh: (Integer | Float | Rational | BigDecimal x) -> Float
15
-
16
- def self.atan: (Integer | Float | Rational | BigDecimal x) -> Float
17
-
18
- def self.atan2: (Integer | Float | Rational | BigDecimal y, Integer | Float | Rational | BigDecimal x) -> Float
19
-
20
- def self.atanh: (Integer | Float | Rational | BigDecimal x) -> Float
21
-
22
- def self.cbrt: (Integer | Float | Rational | BigDecimal x) -> Float
23
-
24
- def self.cos: (Integer | Float | Rational | BigDecimal x) -> Float
25
-
26
- def self.cosh: (Integer | Float | Rational | BigDecimal x) -> Float
27
-
28
- def self.erf: (Integer | Float | Rational | BigDecimal x) -> Float
29
-
30
- def self.erfc: (Integer | Float | Rational | BigDecimal x) -> Float
31
-
32
- def self.exp: (Integer | Float | Rational | BigDecimal x) -> Float
33
-
34
- def self.frexp: (Integer | Float | Rational | BigDecimal x) -> [ Integer | Float | Rational | BigDecimal, Integer | Float | Rational | BigDecimal ]
35
-
36
- def self.gamma: (Integer | Float | Rational | BigDecimal x) -> Float
37
-
38
- def self.hypot: (Integer | Float | Rational | BigDecimal x, Integer | Float | Rational | BigDecimal y) -> Float
39
-
40
- def self.ldexp: (Integer | Float | Rational | BigDecimal fraction, Integer | Float | Rational | BigDecimal exponent) -> Float
41
-
42
- def self.lgamma: (Integer | Float | Rational | BigDecimal x) -> (Integer | Float)
43
-
44
- def self.log: (Integer | Float | Rational | BigDecimal x, ?Integer | Float | Rational | BigDecimal base) -> Float
45
-
46
- def self.log10: (Integer | Float | Rational | BigDecimal x) -> Float
47
-
48
- def self.log2: (Integer | Float | Rational | BigDecimal x) -> Float
49
-
50
- def self.sin: (Integer | Float | Rational | BigDecimal x) -> Float
51
-
52
- def self.sinh: (Integer | Float | Rational | BigDecimal x) -> Float
53
-
54
- def self.sqrt: (Integer | Float | Rational | BigDecimal x) -> Float
55
-
56
- def self.tan: (Integer | Float | Rational | BigDecimal x) -> Float
57
-
58
- def self.tanh: (Integer | Float | Rational | BigDecimal x) -> Float
59
- end
60
-
61
- Math::E: Float
62
-
63
- Math::PI: Float
64
-
65
- class Math::DomainError < StandardError
66
- end