rbs 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ruby.yml +28 -0
  3. data/.gitignore +12 -0
  4. data/.rubocop.yml +15 -0
  5. data/BSDL +22 -0
  6. data/CHANGELOG.md +9 -0
  7. data/COPYING +56 -0
  8. data/Gemfile +6 -0
  9. data/README.md +93 -0
  10. data/Rakefile +142 -0
  11. data/bin/annotate-with-rdoc +157 -0
  12. data/bin/console +14 -0
  13. data/bin/query-rdoc +103 -0
  14. data/bin/setup +10 -0
  15. data/bin/sort +89 -0
  16. data/bin/test_runner.rb +16 -0
  17. data/docs/CONTRIBUTING.md +97 -0
  18. data/docs/sigs.md +148 -0
  19. data/docs/stdlib.md +152 -0
  20. data/docs/syntax.md +528 -0
  21. data/exe/rbs +7 -0
  22. data/lib/rbs.rb +64 -0
  23. data/lib/rbs/ast/annotation.rb +27 -0
  24. data/lib/rbs/ast/comment.rb +27 -0
  25. data/lib/rbs/ast/declarations.rb +395 -0
  26. data/lib/rbs/ast/members.rb +362 -0
  27. data/lib/rbs/buffer.rb +50 -0
  28. data/lib/rbs/builtin_names.rb +55 -0
  29. data/lib/rbs/cli.rb +558 -0
  30. data/lib/rbs/constant.rb +26 -0
  31. data/lib/rbs/constant_table.rb +150 -0
  32. data/lib/rbs/definition.rb +170 -0
  33. data/lib/rbs/definition_builder.rb +919 -0
  34. data/lib/rbs/environment.rb +281 -0
  35. data/lib/rbs/environment_loader.rb +136 -0
  36. data/lib/rbs/environment_walker.rb +124 -0
  37. data/lib/rbs/errors.rb +187 -0
  38. data/lib/rbs/location.rb +102 -0
  39. data/lib/rbs/method_type.rb +123 -0
  40. data/lib/rbs/namespace.rb +91 -0
  41. data/lib/rbs/parser.y +1344 -0
  42. data/lib/rbs/prototype/rb.rb +553 -0
  43. data/lib/rbs/prototype/rbi.rb +587 -0
  44. data/lib/rbs/prototype/runtime.rb +381 -0
  45. data/lib/rbs/substitution.rb +46 -0
  46. data/lib/rbs/test.rb +26 -0
  47. data/lib/rbs/test/errors.rb +61 -0
  48. data/lib/rbs/test/hook.rb +294 -0
  49. data/lib/rbs/test/setup.rb +58 -0
  50. data/lib/rbs/test/spy.rb +325 -0
  51. data/lib/rbs/test/test_helper.rb +183 -0
  52. data/lib/rbs/test/type_check.rb +254 -0
  53. data/lib/rbs/type_name.rb +70 -0
  54. data/lib/rbs/types.rb +936 -0
  55. data/lib/rbs/variance_calculator.rb +138 -0
  56. data/lib/rbs/vendorer.rb +47 -0
  57. data/lib/rbs/version.rb +3 -0
  58. data/lib/rbs/writer.rb +269 -0
  59. data/lib/ruby/signature.rb +7 -0
  60. data/rbs.gemspec +46 -0
  61. data/stdlib/abbrev/abbrev.rbs +60 -0
  62. data/stdlib/base64/base64.rbs +71 -0
  63. data/stdlib/benchmark/benchmark.rbs +372 -0
  64. data/stdlib/builtin/array.rbs +1997 -0
  65. data/stdlib/builtin/basic_object.rbs +280 -0
  66. data/stdlib/builtin/binding.rbs +177 -0
  67. data/stdlib/builtin/builtin.rbs +45 -0
  68. data/stdlib/builtin/class.rbs +145 -0
  69. data/stdlib/builtin/comparable.rbs +116 -0
  70. data/stdlib/builtin/complex.rbs +400 -0
  71. data/stdlib/builtin/constants.rbs +37 -0
  72. data/stdlib/builtin/data.rbs +5 -0
  73. data/stdlib/builtin/deprecated.rbs +2 -0
  74. data/stdlib/builtin/dir.rbs +413 -0
  75. data/stdlib/builtin/encoding.rbs +607 -0
  76. data/stdlib/builtin/enumerable.rbs +404 -0
  77. data/stdlib/builtin/enumerator.rbs +260 -0
  78. data/stdlib/builtin/errno.rbs +781 -0
  79. data/stdlib/builtin/errors.rbs +582 -0
  80. data/stdlib/builtin/exception.rbs +194 -0
  81. data/stdlib/builtin/false_class.rbs +40 -0
  82. data/stdlib/builtin/fiber.rbs +68 -0
  83. data/stdlib/builtin/fiber_error.rbs +12 -0
  84. data/stdlib/builtin/file.rbs +1076 -0
  85. data/stdlib/builtin/file_test.rbs +59 -0
  86. data/stdlib/builtin/float.rbs +696 -0
  87. data/stdlib/builtin/gc.rbs +243 -0
  88. data/stdlib/builtin/hash.rbs +1029 -0
  89. data/stdlib/builtin/integer.rbs +707 -0
  90. data/stdlib/builtin/io.rbs +683 -0
  91. data/stdlib/builtin/kernel.rbs +576 -0
  92. data/stdlib/builtin/marshal.rbs +161 -0
  93. data/stdlib/builtin/match_data.rbs +271 -0
  94. data/stdlib/builtin/math.rbs +369 -0
  95. data/stdlib/builtin/method.rbs +185 -0
  96. data/stdlib/builtin/module.rbs +1104 -0
  97. data/stdlib/builtin/nil_class.rbs +82 -0
  98. data/stdlib/builtin/numeric.rbs +409 -0
  99. data/stdlib/builtin/object.rbs +824 -0
  100. data/stdlib/builtin/proc.rbs +429 -0
  101. data/stdlib/builtin/process.rbs +1227 -0
  102. data/stdlib/builtin/random.rbs +267 -0
  103. data/stdlib/builtin/range.rbs +226 -0
  104. data/stdlib/builtin/rational.rbs +424 -0
  105. data/stdlib/builtin/rb_config.rbs +57 -0
  106. data/stdlib/builtin/regexp.rbs +1083 -0
  107. data/stdlib/builtin/ruby_vm.rbs +14 -0
  108. data/stdlib/builtin/signal.rbs +55 -0
  109. data/stdlib/builtin/string.rbs +1901 -0
  110. data/stdlib/builtin/string_io.rbs +284 -0
  111. data/stdlib/builtin/struct.rbs +40 -0
  112. data/stdlib/builtin/symbol.rbs +228 -0
  113. data/stdlib/builtin/thread.rbs +1108 -0
  114. data/stdlib/builtin/thread_group.rbs +23 -0
  115. data/stdlib/builtin/time.rbs +1047 -0
  116. data/stdlib/builtin/trace_point.rbs +290 -0
  117. data/stdlib/builtin/true_class.rbs +46 -0
  118. data/stdlib/builtin/unbound_method.rbs +153 -0
  119. data/stdlib/builtin/warning.rbs +17 -0
  120. data/stdlib/coverage/coverage.rbs +62 -0
  121. data/stdlib/csv/csv.rbs +773 -0
  122. data/stdlib/erb/erb.rbs +392 -0
  123. data/stdlib/find/find.rbs +40 -0
  124. data/stdlib/ipaddr/ipaddr.rbs +247 -0
  125. data/stdlib/json/json.rbs +335 -0
  126. data/stdlib/pathname/pathname.rbs +1093 -0
  127. data/stdlib/prime/integer-extension.rbs +23 -0
  128. data/stdlib/prime/prime.rbs +188 -0
  129. data/stdlib/securerandom/securerandom.rbs +9 -0
  130. data/stdlib/set/set.rbs +301 -0
  131. data/stdlib/tmpdir/tmpdir.rbs +53 -0
  132. metadata +292 -0
@@ -0,0 +1,582 @@
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