steep 0.13.0 → 0.16.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +0 -3
  3. data/CHANGELOG.md +28 -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 +33 -1
  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 +124 -89
  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/init.rb +5 -5
  17. data/lib/steep/drivers/langserver.rb +13 -287
  18. data/lib/steep/drivers/utils/driver_helper.rb +1 -1
  19. data/lib/steep/drivers/vendor.rb +2 -2
  20. data/lib/steep/drivers/watch.rb +97 -85
  21. data/lib/steep/drivers/worker.rb +51 -0
  22. data/lib/steep/project.rb +9 -5
  23. data/lib/steep/project/completion_provider.rb +298 -0
  24. data/lib/steep/project/dsl.rb +14 -0
  25. data/lib/steep/project/file.rb +54 -47
  26. data/lib/steep/project/hover_content.rb +17 -8
  27. data/lib/steep/project/options.rb +25 -3
  28. data/lib/steep/project/target.rb +40 -24
  29. data/lib/steep/server/base_worker.rb +56 -0
  30. data/lib/steep/server/code_worker.rb +151 -0
  31. data/lib/steep/server/interaction_worker.rb +281 -0
  32. data/lib/steep/server/master.rb +196 -0
  33. data/lib/steep/server/signature_worker.rb +148 -0
  34. data/lib/steep/server/utils.rb +36 -0
  35. data/lib/steep/server/worker_process.rb +62 -0
  36. data/lib/steep/signature/errors.rb +1 -1
  37. data/lib/steep/signature/validator.rb +13 -13
  38. data/lib/steep/source.rb +1 -1
  39. data/lib/steep/type_construction.rb +1004 -727
  40. data/lib/steep/type_inference/constant_env.rb +3 -11
  41. data/lib/steep/type_inference/context.rb +8 -3
  42. data/lib/steep/type_inference/context_array.rb +111 -0
  43. data/lib/steep/type_inference/local_variable_type_env.rb +226 -0
  44. data/lib/steep/type_inference/logic.rb +130 -0
  45. data/lib/steep/type_inference/type_env.rb +5 -69
  46. data/lib/steep/typing.rb +91 -23
  47. data/lib/steep/version.rb +1 -1
  48. data/smoke/alias/Steepfile +1 -0
  49. data/smoke/alias/a.rb +1 -1
  50. data/smoke/and/Steepfile +1 -0
  51. data/smoke/array/Steepfile +1 -0
  52. data/smoke/array/b.rb +0 -2
  53. data/smoke/block/Steepfile +1 -0
  54. data/smoke/case/Steepfile +1 -0
  55. data/smoke/class/Steepfile +1 -0
  56. data/smoke/const/Steepfile +1 -0
  57. data/smoke/dstr/Steepfile +1 -0
  58. data/smoke/ensure/Steepfile +1 -0
  59. data/smoke/enumerator/Steepfile +1 -0
  60. data/smoke/extension/Steepfile +1 -0
  61. data/smoke/extension/c.rb +1 -0
  62. data/smoke/hash/Steepfile +1 -0
  63. data/smoke/hello/Steepfile +1 -0
  64. data/smoke/if/Steepfile +1 -0
  65. data/smoke/if/a.rb +1 -1
  66. data/smoke/implements/Steepfile +1 -0
  67. data/smoke/initialize/Steepfile +1 -0
  68. data/smoke/integer/Steepfile +1 -0
  69. data/smoke/interface/Steepfile +1 -0
  70. data/smoke/kwbegin/Steepfile +1 -0
  71. data/smoke/lambda/Steepfile +1 -0
  72. data/smoke/literal/Steepfile +1 -0
  73. data/smoke/map/Steepfile +1 -0
  74. data/smoke/method/Steepfile +1 -0
  75. data/smoke/module/Steepfile +1 -0
  76. data/smoke/regexp/Steepfile +1 -0
  77. data/smoke/regexp/b.rb +4 -4
  78. data/smoke/regression/Steepfile +1 -0
  79. data/smoke/rescue/Steepfile +1 -0
  80. data/smoke/rescue/a.rb +1 -1
  81. data/smoke/self/Steepfile +1 -0
  82. data/smoke/skip/Steepfile +1 -0
  83. data/smoke/stdout/Steepfile +1 -0
  84. data/smoke/super/Steepfile +1 -0
  85. data/smoke/type_case/Steepfile +1 -0
  86. data/smoke/yield/Steepfile +1 -0
  87. data/steep.gemspec +8 -8
  88. metadata +38 -138
  89. data/exe/rbs +0 -3
  90. data/exe/ruby-signature +0 -3
  91. data/vendor/ruby-signature/.github/workflows/ruby.yml +0 -27
  92. data/vendor/ruby-signature/.gitignore +0 -12
  93. data/vendor/ruby-signature/.rubocop.yml +0 -15
  94. data/vendor/ruby-signature/BSDL +0 -22
  95. data/vendor/ruby-signature/COPYING +0 -56
  96. data/vendor/ruby-signature/Gemfile +0 -6
  97. data/vendor/ruby-signature/README.md +0 -93
  98. data/vendor/ruby-signature/Rakefile +0 -66
  99. data/vendor/ruby-signature/bin/annotate-with-rdoc +0 -156
  100. data/vendor/ruby-signature/bin/console +0 -14
  101. data/vendor/ruby-signature/bin/query-rdoc +0 -103
  102. data/vendor/ruby-signature/bin/setup +0 -10
  103. data/vendor/ruby-signature/bin/sort +0 -88
  104. data/vendor/ruby-signature/bin/test_runner.rb +0 -17
  105. data/vendor/ruby-signature/docs/CONTRIBUTING.md +0 -97
  106. data/vendor/ruby-signature/docs/sigs.md +0 -148
  107. data/vendor/ruby-signature/docs/stdlib.md +0 -152
  108. data/vendor/ruby-signature/docs/syntax.md +0 -528
  109. data/vendor/ruby-signature/exe/rbs +0 -3
  110. data/vendor/ruby-signature/exe/ruby-signature +0 -7
  111. data/vendor/ruby-signature/lib/ruby/signature.rb +0 -64
  112. data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +0 -29
  113. data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +0 -29
  114. data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +0 -391
  115. data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +0 -364
  116. data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +0 -52
  117. data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +0 -54
  118. data/vendor/ruby-signature/lib/ruby/signature/cli.rb +0 -534
  119. data/vendor/ruby-signature/lib/ruby/signature/constant.rb +0 -28
  120. data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +0 -152
  121. data/vendor/ruby-signature/lib/ruby/signature/definition.rb +0 -172
  122. data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +0 -921
  123. data/vendor/ruby-signature/lib/ruby/signature/environment.rb +0 -283
  124. data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +0 -138
  125. data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +0 -126
  126. data/vendor/ruby-signature/lib/ruby/signature/errors.rb +0 -189
  127. data/vendor/ruby-signature/lib/ruby/signature/location.rb +0 -104
  128. data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +0 -125
  129. data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +0 -93
  130. data/vendor/ruby-signature/lib/ruby/signature/parser.y +0 -1343
  131. data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +0 -441
  132. data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +0 -579
  133. data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +0 -383
  134. data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +0 -48
  135. data/vendor/ruby-signature/lib/ruby/signature/test.rb +0 -28
  136. data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +0 -63
  137. data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +0 -290
  138. data/vendor/ruby-signature/lib/ruby/signature/test/setup.rb +0 -58
  139. data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +0 -324
  140. data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +0 -185
  141. data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +0 -256
  142. data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +0 -72
  143. data/vendor/ruby-signature/lib/ruby/signature/types.rb +0 -932
  144. data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +0 -140
  145. data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +0 -49
  146. data/vendor/ruby-signature/lib/ruby/signature/version.rb +0 -5
  147. data/vendor/ruby-signature/lib/ruby/signature/writer.rb +0 -271
  148. data/vendor/ruby-signature/ruby-signature.gemspec +0 -45
  149. data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +0 -3
  150. data/vendor/ruby-signature/stdlib/base64/base64.rbs +0 -15
  151. data/vendor/ruby-signature/stdlib/builtin/array.rbs +0 -1997
  152. data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +0 -280
  153. data/vendor/ruby-signature/stdlib/builtin/binding.rbs +0 -177
  154. data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +0 -35
  155. data/vendor/ruby-signature/stdlib/builtin/class.rbs +0 -145
  156. data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +0 -116
  157. data/vendor/ruby-signature/stdlib/builtin/complex.rbs +0 -400
  158. data/vendor/ruby-signature/stdlib/builtin/constants.rbs +0 -37
  159. data/vendor/ruby-signature/stdlib/builtin/data.rbs +0 -5
  160. data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +0 -2
  161. data/vendor/ruby-signature/stdlib/builtin/dir.rbs +0 -419
  162. data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +0 -606
  163. data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +0 -404
  164. data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +0 -260
  165. data/vendor/ruby-signature/stdlib/builtin/errno.rbs +0 -781
  166. data/vendor/ruby-signature/stdlib/builtin/errors.rbs +0 -582
  167. data/vendor/ruby-signature/stdlib/builtin/exception.rbs +0 -193
  168. data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +0 -40
  169. data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +0 -68
  170. data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +0 -12
  171. data/vendor/ruby-signature/stdlib/builtin/file.rbs +0 -476
  172. data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +0 -59
  173. data/vendor/ruby-signature/stdlib/builtin/float.rbs +0 -696
  174. data/vendor/ruby-signature/stdlib/builtin/gc.rbs +0 -121
  175. data/vendor/ruby-signature/stdlib/builtin/hash.rbs +0 -1029
  176. data/vendor/ruby-signature/stdlib/builtin/integer.rbs +0 -710
  177. data/vendor/ruby-signature/stdlib/builtin/io.rbs +0 -683
  178. data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +0 -574
  179. data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +0 -135
  180. data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +0 -141
  181. data/vendor/ruby-signature/stdlib/builtin/math.rbs +0 -66
  182. data/vendor/ruby-signature/stdlib/builtin/method.rbs +0 -182
  183. data/vendor/ruby-signature/stdlib/builtin/module.rbs +0 -248
  184. data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +0 -82
  185. data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +0 -409
  186. data/vendor/ruby-signature/stdlib/builtin/object.rbs +0 -824
  187. data/vendor/ruby-signature/stdlib/builtin/proc.rbs +0 -426
  188. data/vendor/ruby-signature/stdlib/builtin/process.rbs +0 -354
  189. data/vendor/ruby-signature/stdlib/builtin/random.rbs +0 -93
  190. data/vendor/ruby-signature/stdlib/builtin/range.rbs +0 -226
  191. data/vendor/ruby-signature/stdlib/builtin/rational.rbs +0 -424
  192. data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +0 -10
  193. data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +0 -131
  194. data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +0 -14
  195. data/vendor/ruby-signature/stdlib/builtin/signal.rbs +0 -55
  196. data/vendor/ruby-signature/stdlib/builtin/string.rbs +0 -770
  197. data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +0 -13
  198. data/vendor/ruby-signature/stdlib/builtin/struct.rbs +0 -40
  199. data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +0 -230
  200. data/vendor/ruby-signature/stdlib/builtin/thread.rbs +0 -1112
  201. data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +0 -23
  202. data/vendor/ruby-signature/stdlib/builtin/time.rbs +0 -739
  203. data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +0 -91
  204. data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +0 -46
  205. data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +0 -159
  206. data/vendor/ruby-signature/stdlib/builtin/warning.rbs +0 -17
  207. data/vendor/ruby-signature/stdlib/erb/erb.rbs +0 -18
  208. data/vendor/ruby-signature/stdlib/find/find.rbs +0 -44
  209. data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +0 -21
  210. data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +0 -23
  211. data/vendor/ruby-signature/stdlib/prime/prime.rbs +0 -188
  212. data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +0 -9
  213. data/vendor/ruby-signature/stdlib/set/set.rbs +0 -77
  214. data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +0 -53
@@ -1,582 +0,0 @@
1
- # Raised when the arguments are wrong and there isn't a more specific Exception
2
- # class.
3
- #
4
- # Ex: passing the wrong number of arguments
5
- #
6
- # [1, 2, 3].first(4, 5)
7
- #
8
- # *raises the exception:*
9
- #
10
- # ArgumentError: wrong number of arguments (given 2, expected 1)
11
- #
12
- # Ex: passing an argument that is not acceptable:
13
- #
14
- # [1, 2, 3].first(-4)
15
- #
16
- # *raises the exception:*
17
- #
18
- # ArgumentError: negative array size
19
- #
20
- class ArgumentError < StandardError
21
- end
22
-
23
- # The exception class which will be raised when pushing into a closed Queue.
24
- # See Queue#close and SizedQueue#close.
25
- #
26
- class ClosedQueueError < StopIteration
27
- end
28
-
29
- # EncodingError is the base class for encoding errors.
30
- #
31
- class EncodingError < StandardError
32
- end
33
-
34
- # Raised by some IO operations when reaching the end of file. Many IO methods
35
- # exist in two forms,
36
- #
37
- # one that returns `nil` when the end of file is reached, the other raises
38
- # `EOFError`.
39
- #
40
- # `EOFError` is a subclass of `IOError`.
41
- #
42
- # file = File.open("/etc/hosts")
43
- # file.read
44
- # file.gets #=> nil
45
- # file.readline #=> EOFError: end of file reached
46
- #
47
- class EOFError < IOError
48
- end
49
-
50
- # Raised when attempting to convert special float values (in particular
51
- # `Infinity` or `NaN`) to numerical classes which don't support them.
52
- #
53
- # Float::INFINITY.to_r #=> FloatDomainError: Infinity
54
- #
55
- class FloatDomainError < RangeError
56
- end
57
-
58
- # Raised when there is an attempt to modify a frozen object.
59
- #
60
- # [1, 2, 3].freeze << 4
61
- #
62
- # *raises the exception:*
63
- #
64
- # FrozenError: can't modify frozen Array
65
- #
66
- class FrozenError[T] < RuntimeError
67
- # Construct a new FrozenError exception. If given the *receiver* parameter may
68
- # subsequently be examined using the FrozenError#receiver method.
69
- #
70
- # a = [].freeze
71
- # raise FrozenError.new("can't modify frozen array", receiver: a)
72
- #
73
- def initialize: (?string? msg, ?receiver: T?) -> void
74
-
75
- # Return the receiver associated with this FrozenError exception.
76
- #
77
- def receiver: () -> T?
78
- end
79
-
80
- # Raised when the given index is invalid.
81
- #
82
- # a = [:foo, :bar]
83
- # a.fetch(0) #=> :foo
84
- # a[4] #=> nil
85
- # a.fetch(4) #=> IndexError: index 4 outside of array bounds: -2...2
86
- #
87
- class IndexError < StandardError
88
- end
89
-
90
- # Raised when the interrupt signal is received, typically because the user has
91
- # pressed Control-C (on most posix platforms). As such, it is a subclass of
92
- # `SignalException`.
93
- #
94
- # begin
95
- # puts "Press ctrl-C when you get bored"
96
- # loop {}
97
- # rescue Interrupt => e
98
- # puts "Note: You will typically use Signal.trap instead."
99
- # end
100
- #
101
- # *produces:*
102
- #
103
- # Press ctrl-C when you get bored
104
- #
105
- # *then waits until it is interrupted with Control-C and then prints:*
106
- #
107
- # Note: You will typically use Signal.trap instead.
108
- #
109
- class Interrupt < SignalException
110
- def initialize: (?string) -> void
111
- end
112
-
113
- # Raised when an IO operation fails.
114
- #
115
- # File.open("/etc/hosts") {|f| f << "example"}
116
- # #=> IOError: not opened for writing
117
- #
118
- # File.open("/etc/hosts") {|f| f.close; f.read }
119
- # #=> IOError: closed stream
120
- #
121
- # Note that some IO failures raise `SystemCallError`s and these are not
122
- # subclasses of IOError:
123
- #
124
- # File.open("does/not/exist")
125
- # #=> Errno::ENOENT: No such file or directory - does/not/exist
126
- #
127
- class IOError < StandardError
128
- end
129
-
130
- # Raised when the specified key is not found. It is a subclass of IndexError.
131
- #
132
- # h = {"foo" => :bar}
133
- # h.fetch("foo") #=> :bar
134
- # h.fetch("baz") #=> KeyError: key not found: "baz"
135
- #
136
- class KeyError[K, R] < IndexError
137
- # Construct a new `KeyError` exception with the given message, receiver and key.
138
- #
139
- def initialize: (?string msg, ?receiver: R?, ?key: K?) -> void
140
-
141
- # Return the key caused this KeyError exception.
142
- #
143
- def key: () -> K?
144
-
145
- # Return the receiver associated with this KeyError exception.
146
- #
147
- def receiver: () -> R?
148
- end
149
-
150
- # Raised when a file required (a Ruby script, extension library, ...) fails to
151
- # load.
152
- #
153
- # require 'this/file/does/not/exist'
154
- #
155
- # *raises the exception:*
156
- #
157
- # LoadError: no such file to load -- this/file/does/not/exist
158
- #
159
- class LoadError < ScriptError
160
- # the path failed to load
161
- #
162
- #
163
- def path: () -> String?
164
- end
165
-
166
- # Raised when Ruby can't yield as requested.
167
- #
168
- # A typical scenario is attempting to yield when no block is given:
169
- #
170
- # def call_block
171
- # yield 42
172
- # end
173
- # call_block
174
- #
175
- # *raises the exception:*
176
- #
177
- # LocalJumpError: no block given (yield)
178
- #
179
- # A more subtle example:
180
- #
181
- # def get_me_a_return
182
- # Proc.new { return 42 }
183
- # end
184
- # get_me_a_return.call
185
- #
186
- # *raises the exception:*
187
- #
188
- # LocalJumpError: unexpected return
189
- #
190
- class LocalJumpError < StandardError
191
- # Returns the exit value associated with this `LocalJumpError`.
192
- #
193
- def exit_value: () -> untyped
194
-
195
- # The reason this block was terminated: :break, :redo, :retry, :next, :return,
196
- # or :noreason.
197
- #
198
- def reason: () -> Symbol
199
- end
200
-
201
- # Raised when a given name is invalid or undefined.
202
- #
203
- # puts foo
204
- #
205
- # *raises the exception:*
206
- #
207
- # NameError: undefined local variable or method `foo' for main:Object
208
- #
209
- # Since constant names must start with a capital:
210
- #
211
- # Integer.const_set :answer, 42
212
- #
213
- # *raises the exception:*
214
- #
215
- # NameError: wrong constant name answer
216
- #
217
- class NameError[T] < StandardError
218
- # Construct a new NameError exception. If given the *name* parameter may
219
- # subsequently be examined using the NameError#name method. *receiver* parameter
220
- # allows to pass object in context of which the error happened. Example:
221
- #
222
- # [1, 2, 3].method(:rject) # NameError with name "rject" and receiver: Array
223
- # [1, 2, 3].singleton_method(:rject) # NameError with name "rject" and receiver: [1, 2, 3]
224
- #
225
- def initialize: (?string msg, ?String? name, ?receiver: T?) -> void
226
-
227
- public
228
-
229
- # Return a list of the local variable names defined where this NameError
230
- # exception was raised.
231
- #
232
- # Internal use only.
233
- #
234
- def local_variables: () -> ::Array[Symbol]
235
-
236
- # Return the name associated with this NameError exception.
237
- #
238
- def name: () -> String?
239
-
240
- # Return the receiver associated with this NameError exception.
241
- #
242
- def receiver: () -> T?
243
- end
244
-
245
- # Raised when memory allocation fails.
246
- #
247
- class NoMemoryError < Exception
248
- end
249
-
250
- # Raised when a method is called on a receiver which doesn't have it defined and
251
- # also fails to respond with `method_missing`.
252
- #
253
- # "hello".to_ary
254
- #
255
- # *raises the exception:*
256
- #
257
- # NoMethodError: undefined method `to_ary' for "hello":String
258
- #
259
- class NoMethodError[T] < NameError[T]
260
- # Construct a NoMethodError exception for a method of the given name called with
261
- # the given arguments. The name may be accessed using the `#name` method on the
262
- # resulting object, and the arguments using the `#args` method.
263
- #
264
- # If *private* argument were passed, it designates method was attempted to call
265
- # in private context, and can be accessed with `#private_call?` method.
266
- #
267
- # *receiver* argument stores an object whose method was called.
268
- #
269
- def initialize: (?string? msg, ?String? name, ?Array[untyped] args, ?bool `private`, ?receiver: T?) -> void
270
-
271
- public
272
-
273
- # Return the arguments passed in as the third parameter to the constructor.
274
- #
275
- def args: () -> Array[untyped]
276
-
277
- # Return true if the caused method was called as private.
278
- #
279
- def private_call?: () -> bool
280
- end
281
-
282
- # Raised when a feature is not implemented on the current platform. For example,
283
- # methods depending on the `fsync` or `fork` system calls may raise this
284
- # exception if the underlying operating system or Ruby runtime does not support
285
- # them.
286
- #
287
- # Note that if `fork` raises a `NotImplementedError`, then `respond_to?(:fork)`
288
- # returns `false`.
289
- #
290
- class NotImplementedError < ScriptError
291
- end
292
-
293
- # Raised when a given numerical value is out of range.
294
- #
295
- # [1, 2, 3].drop(1 << 100)
296
- #
297
- # *raises the exception:*
298
- #
299
- # RangeError: bignum too big to convert into `long'
300
- #
301
- class RangeError < StandardError
302
- end
303
-
304
- # Raised when given an invalid regexp expression.
305
- #
306
- # Regexp.new("?")
307
- #
308
- # *raises the exception:*
309
- #
310
- # RegexpError: target of repeat operator is not specified: /?/
311
- #
312
- class RegexpError < StandardError
313
- end
314
-
315
- # A generic error class raised when an invalid operation is attempted.
316
- # Kernel#raise will raise a RuntimeError if no Exception class is specified.
317
- #
318
- # raise "ouch"
319
- #
320
- # *raises the exception:*
321
- #
322
- # RuntimeError: ouch
323
- #
324
- class RuntimeError < StandardError
325
- end
326
-
327
- # ScriptError is the superclass for errors raised when a script can not be
328
- # executed because of a `LoadError`, `NotImplementedError` or a `SyntaxError`.
329
- # Note these type of `ScriptErrors` are not `StandardError` and will not be
330
- # rescued unless it is specified explicitly (or its ancestor `Exception`).
331
- #
332
- class ScriptError < Exception
333
- end
334
-
335
- # No longer used by internal code.
336
- #
337
- class SecurityError < Exception
338
- end
339
-
340
- # Raised when a signal is received.
341
- #
342
- # begin
343
- # Process.kill('HUP',Process.pid)
344
- # sleep # wait for receiver to handle signal sent by Process.kill
345
- # rescue SignalException => e
346
- # puts "received Exception #{e}"
347
- # end
348
- #
349
- # *produces:*
350
- #
351
- # received Exception SIGHUP
352
- #
353
- class SignalException < Exception
354
- # Construct a new SignalException object. `sig_name` should be a known signal
355
- # name.
356
- #
357
- def initialize: (?string sig_name) -> void
358
- | (int sig_number, ?string sig_name) -> void
359
-
360
- public
361
-
362
- def signm: () -> String
363
-
364
- # Returns a signal number.
365
- #
366
- def signo: () -> Integer
367
- end
368
-
369
- # The most standard error types are subclasses of StandardError. A rescue clause
370
- # without an explicit Exception class will rescue all StandardErrors (and only
371
- # those).
372
- #
373
- # def foo
374
- # raise "Oups"
375
- # end
376
- # foo rescue "Hello" #=> "Hello"
377
- #
378
- # On the other hand:
379
- #
380
- # require 'does/not/exist' rescue "Hi"
381
- #
382
- # *raises the exception:*
383
- #
384
- # LoadError: no such file to load -- does/not/exist
385
- #
386
- class StandardError < Exception
387
- end
388
-
389
- # Raised to stop the iteration, in particular by Enumerator#next. It is rescued
390
- # by Kernel#loop.
391
- #
392
- # loop do
393
- # puts "Hello"
394
- # raise StopIteration
395
- # puts "World"
396
- # end
397
- # puts "Done!"
398
- #
399
- # *produces:*
400
- #
401
- # Hello
402
- # Done!
403
- #
404
- class StopIteration < IndexError
405
- # Returns the return value of the iterator.
406
- #
407
- # o = Object.new
408
- # def o.each
409
- # yield 1
410
- # yield 2
411
- # yield 3
412
- # 100
413
- # end
414
- #
415
- # e = o.to_enum
416
- #
417
- # puts e.next #=> 1
418
- # puts e.next #=> 2
419
- # puts e.next #=> 3
420
- #
421
- # begin
422
- # e.next
423
- # rescue StopIteration => ex
424
- # puts ex.result #=> 100
425
- # end
426
- #
427
- def result: () -> untyped
428
- end
429
-
430
- # Raised when encountering Ruby code with an invalid syntax.
431
- #
432
- # eval("1+1=2")
433
- #
434
- # *raises the exception:*
435
- #
436
- # SyntaxError: (eval):1: syntax error, unexpected '=', expecting $end
437
- #
438
- class SyntaxError < ScriptError
439
- # Construct a SyntaxError exception.
440
- #
441
- def initialize: (?string msg) -> void
442
- end
443
-
444
- # SystemCallError is the base class for all low-level platform-dependent errors.
445
- #
446
- # The errors available on the current platform are subclasses of SystemCallError
447
- # and are defined in the Errno module.
448
- #
449
- # File.open("does/not/exist")
450
- #
451
- # *raises the exception:*
452
- #
453
- # Errno::ENOENT: No such file or directory - does/not/exist
454
- #
455
- class SystemCallError < StandardError
456
- # If *errno* corresponds to a known system error code, constructs the
457
- # appropriate Errno class for that error, otherwise constructs a generic
458
- # SystemCallError object. The error number is subsequently available via the
459
- # #errno method.
460
- #
461
- def initialize: (string msg, Integer errno) -> SystemCallError
462
-
463
- # Return `true` if the receiver is a generic `SystemCallError`, or if the error
464
- # numbers `self` and *other* are the same.
465
- #
466
- def self.===: (untyped other) -> bool
467
-
468
- public
469
-
470
- # Return this SystemCallError's error number.
471
- #
472
- def errno: () -> Integer
473
- end
474
-
475
- # Raised by `exit` to initiate the termination of the script.
476
- #
477
- class SystemExit < Exception
478
- # Create a new `SystemExit` exception with the given status and message. Status
479
- # is true, false, or an integer. If status is not given, true is used.
480
- #
481
- def initialize: () -> void
482
- | (string msg) -> void
483
- | (true | false | int status, ?string msg) -> void
484
-
485
- public
486
-
487
- # Return the status value associated with this system exit.
488
- #
489
- def status: () -> Integer
490
-
491
- # Returns `true` if exiting successful, `false` if not.
492
- #
493
- def success?: () -> bool
494
- end
495
-
496
- # Raised in case of a stack overflow.
497
- #
498
- # def me_myself_and_i
499
- # me_myself_and_i
500
- # end
501
- # me_myself_and_i
502
- #
503
- # *raises the exception:*
504
- #
505
- # SystemStackError: stack level too deep
506
- #
507
- class SystemStackError < Exception
508
- end
509
-
510
- # Raised when an invalid operation is attempted on a thread.
511
- #
512
- # For example, when no other thread has been started:
513
- #
514
- # Thread.stop
515
- #
516
- # This will raises the following exception:
517
- #
518
- # ThreadError: stopping only thread
519
- # note: use sleep to stop forever
520
- #
521
- class ThreadError < StandardError
522
- end
523
-
524
- # Raised when encountering an object that is not of the expected type.
525
- #
526
- # [1, 2, 3].first("two")
527
- #
528
- # *raises the exception:*
529
- #
530
- # TypeError: no implicit conversion of String into Integer
531
- #
532
- class TypeError < StandardError
533
- end
534
-
535
- # Raised when `throw` is called with a *tag* which does not have corresponding
536
- # `catch` block.
537
- #
538
- # throw "foo", "bar"
539
- #
540
- # *raises the exception:*
541
- #
542
- # UncaughtThrowError: uncaught throw "foo"
543
- #
544
- class UncaughtThrowError < ArgumentError
545
- # Raised when `throw` is called with a *tag* which does not have corresponding
546
- # `catch` block.
547
- #
548
- # throw "foo", "bar"
549
- #
550
- # *raises the exception:*
551
- #
552
- # UncaughtThrowError: uncaught throw "foo"
553
- #
554
- def initialize: (untyped tag, untyped value) -> void
555
-
556
- public
557
-
558
- # Return the tag object which was called for.
559
- #
560
- def tag: () -> untyped
561
-
562
- # Returns formatted message with the inspected tag.
563
- #
564
- def to_s: () -> String
565
-
566
- # Return the return value which was called for.
567
- #
568
- def value: () -> untyped
569
- end
570
-
571
- # Raised when attempting to divide an integer by 0.
572
- #
573
- # 42 / 0 #=> ZeroDivisionError: divided by 0
574
- #
575
- # Note that only division by an exact 0 will raise the exception:
576
- #
577
- # 42 / 0.0 #=> Float::INFINITY
578
- # 42 / -0.0 #=> -Float::INFINITY
579
- # 0 / 0.0 #=> NaN
580
- #
581
- class ZeroDivisionError < StandardError
582
- end