steep 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (299) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +27 -0
  3. data/.gitmodules +3 -0
  4. data/CHANGELOG.md +5 -0
  5. data/README.md +48 -90
  6. data/Rakefile +10 -6
  7. data/Steepfile +1 -0
  8. data/bin/setup +1 -0
  9. data/bin/smoke_runner.rb +9 -14
  10. data/exe/rbs +3 -0
  11. data/exe/ruby-signature +3 -0
  12. data/exe/steep +1 -0
  13. data/lib/steep.rb +32 -26
  14. data/lib/steep/annotation_parser.rb +167 -0
  15. data/lib/steep/ast/annotation/collection.rb +7 -7
  16. data/lib/steep/ast/types.rb +60 -0
  17. data/lib/steep/ast/types/any.rb +1 -1
  18. data/lib/steep/ast/types/factory.rb +535 -0
  19. data/lib/steep/ast/types/name.rb +3 -3
  20. data/lib/steep/ast/types/var.rb +1 -1
  21. data/lib/steep/cli.rb +56 -240
  22. data/lib/steep/drivers/annotations.rb +36 -19
  23. data/lib/steep/drivers/check.rb +55 -91
  24. data/lib/steep/drivers/init.rb +54 -0
  25. data/lib/steep/drivers/langserver.rb +241 -150
  26. data/lib/steep/drivers/print_project.rb +56 -0
  27. data/lib/steep/drivers/signature_error_printer.rb +25 -0
  28. data/lib/steep/drivers/trace_printer.rb +25 -0
  29. data/lib/steep/drivers/utils/driver_helper.rb +26 -0
  30. data/lib/steep/drivers/validate.rb +18 -38
  31. data/lib/steep/drivers/vendor.rb +46 -0
  32. data/lib/steep/drivers/watch.rb +78 -140
  33. data/lib/steep/errors.rb +22 -13
  34. data/lib/steep/interface/interface.rb +91 -0
  35. data/lib/steep/interface/method.rb +0 -4
  36. data/lib/steep/interface/method_type.rb +362 -2
  37. data/lib/steep/interface/substitution.rb +22 -0
  38. data/lib/steep/project.rb +25 -233
  39. data/lib/steep/project/dsl.rb +132 -0
  40. data/lib/steep/project/file.rb +93 -76
  41. data/lib/steep/project/file_loader.rb +63 -0
  42. data/lib/steep/project/options.rb +7 -0
  43. data/lib/steep/project/target.rb +190 -0
  44. data/lib/steep/signature/errors.rb +25 -77
  45. data/lib/steep/signature/validator.rb +122 -0
  46. data/lib/steep/source.rb +12 -7
  47. data/lib/steep/subtyping/check.rb +357 -633
  48. data/lib/steep/subtyping/constraints.rb +2 -2
  49. data/lib/steep/subtyping/trace.rb +23 -0
  50. data/lib/steep/type_construction.rb +509 -455
  51. data/lib/steep/type_inference/constant_env.rb +16 -24
  52. data/lib/steep/type_inference/type_env.rb +26 -18
  53. data/lib/steep/version.rb +1 -1
  54. data/sample/Steepfile +6 -0
  55. data/sample/lib/conference.rb +12 -0
  56. data/sample/sig/conference.rbs +6 -0
  57. data/smoke/alias/Steepfile +4 -0
  58. data/smoke/alias/a.rb +2 -2
  59. data/smoke/alias/{a.rbi → a.rbs} +1 -1
  60. data/smoke/and/Steepfile +4 -0
  61. data/smoke/array/Steepfile +4 -0
  62. data/smoke/array/a.rb +2 -2
  63. data/smoke/array/b.rb +4 -4
  64. data/smoke/array/c.rb +2 -2
  65. data/smoke/block/Steepfile +5 -0
  66. data/smoke/block/{a.rbi → a.rbs} +1 -1
  67. data/smoke/block/{c.rbi → c.rbs} +0 -0
  68. data/smoke/block/d.rb +6 -6
  69. data/smoke/case/Steepfile +4 -0
  70. data/smoke/case/a.rb +4 -3
  71. data/smoke/class/Steepfile +4 -0
  72. data/smoke/class/a.rb +1 -4
  73. data/smoke/class/a.rbs +24 -0
  74. data/smoke/class/h.rb +6 -2
  75. data/smoke/class/{h.rbi → h.rbs} +1 -2
  76. data/smoke/class/i.rb +1 -2
  77. data/smoke/class/i.rbs +9 -0
  78. data/smoke/const/Steepfile +4 -0
  79. data/smoke/dstr/Steepfile +4 -0
  80. data/smoke/ensure/Steepfile +4 -0
  81. data/smoke/ensure/a.rb +1 -1
  82. data/smoke/enumerator/Steepfile +4 -0
  83. data/smoke/enumerator/a.rb +7 -7
  84. data/smoke/enumerator/b.rb +6 -6
  85. data/smoke/extension/Steepfile +4 -0
  86. data/smoke/extension/{a.rbi → a.rbs} +2 -2
  87. data/smoke/extension/{e.rbi → e.rbs} +2 -2
  88. data/smoke/hash/Steepfile +4 -0
  89. data/smoke/hash/{a.rbi → a.rbs} +0 -0
  90. data/smoke/hash/b.rb +2 -2
  91. data/smoke/hash/c.rb +1 -1
  92. data/smoke/hash/e.rbs +3 -0
  93. data/smoke/hash/f.rb +1 -1
  94. data/smoke/hello/Steepfile +4 -0
  95. data/smoke/hello/hello.rbs +7 -0
  96. data/smoke/if/Steepfile +4 -0
  97. data/smoke/implements/Steepfile +4 -0
  98. data/smoke/implements/a.rbs +6 -0
  99. data/smoke/initialize/Steepfile +4 -0
  100. data/smoke/initialize/a.rbs +3 -0
  101. data/smoke/integer/Steepfile +4 -0
  102. data/smoke/integer/a.rb +5 -3
  103. data/smoke/interface/Steepfile +4 -0
  104. data/smoke/interface/{a.rbi → a.rbs} +0 -0
  105. data/smoke/kwbegin/Steepfile +4 -0
  106. data/smoke/lambda/Steepfile +4 -0
  107. data/smoke/lambda/a.rb +9 -2
  108. data/smoke/literal/Steepfile +4 -0
  109. data/smoke/literal/{literal_methods.rbi → literal_methods.rbs} +0 -0
  110. data/smoke/map/Steepfile +4 -0
  111. data/smoke/map/a.rb +1 -1
  112. data/smoke/method/Steepfile +4 -0
  113. data/smoke/method/{a.rbi → a.rbs} +0 -0
  114. data/smoke/method/b.rb +1 -4
  115. data/smoke/method/d.rb +1 -0
  116. data/smoke/method/d.rbs +3 -0
  117. data/smoke/module/Steepfile +4 -0
  118. data/smoke/module/a.rb +1 -1
  119. data/smoke/module/a.rbs +16 -0
  120. data/smoke/module/c.rb +1 -1
  121. data/smoke/regexp/Steepfile +4 -0
  122. data/smoke/regexp/a.rb +2 -2
  123. data/smoke/regexp/b.rb +16 -16
  124. data/smoke/regression/Steepfile +5 -0
  125. data/smoke/regression/array.rb +2 -2
  126. data/smoke/regression/hash.rb +2 -2
  127. data/smoke/regression/poly_new.rb +2 -0
  128. data/smoke/regression/poly_new.rbs +4 -0
  129. data/smoke/regression/set_divide.rb +2 -2
  130. data/smoke/rescue/Steepfile +4 -0
  131. data/smoke/rescue/a.rb +1 -1
  132. data/smoke/self/Steepfile +4 -0
  133. data/smoke/self/a.rbs +4 -0
  134. data/smoke/skip/Steepfile +4 -0
  135. data/smoke/stdout/Steepfile +4 -0
  136. data/smoke/stdout/{a.rbi → a.rbs} +1 -1
  137. data/smoke/super/Steepfile +4 -0
  138. data/smoke/super/a.rbs +10 -0
  139. data/smoke/type_case/Steepfile +4 -0
  140. data/smoke/type_case/a.rb +1 -1
  141. data/smoke/yield/Steepfile +4 -0
  142. data/smoke/yield/a.rb +2 -2
  143. data/steep.gemspec +14 -7
  144. data/vendor/ruby-signature/.github/workflows/ruby.yml +27 -0
  145. data/vendor/ruby-signature/.gitignore +12 -0
  146. data/vendor/ruby-signature/.rubocop.yml +15 -0
  147. data/vendor/ruby-signature/BSDL +22 -0
  148. data/vendor/ruby-signature/COPYING +56 -0
  149. data/vendor/ruby-signature/Gemfile +6 -0
  150. data/vendor/ruby-signature/README.md +93 -0
  151. data/vendor/ruby-signature/Rakefile +66 -0
  152. data/vendor/ruby-signature/bin/annotate-with-rdoc +156 -0
  153. data/vendor/ruby-signature/bin/console +14 -0
  154. data/vendor/ruby-signature/bin/query-rdoc +103 -0
  155. data/vendor/ruby-signature/bin/setup +10 -0
  156. data/vendor/ruby-signature/bin/sort +88 -0
  157. data/vendor/ruby-signature/bin/test_runner.rb +17 -0
  158. data/vendor/ruby-signature/docs/CONTRIBUTING.md +97 -0
  159. data/vendor/ruby-signature/docs/sigs.md +148 -0
  160. data/vendor/ruby-signature/docs/stdlib.md +152 -0
  161. data/vendor/ruby-signature/docs/syntax.md +528 -0
  162. data/vendor/ruby-signature/exe/rbs +3 -0
  163. data/vendor/ruby-signature/exe/ruby-signature +7 -0
  164. data/vendor/ruby-signature/lib/ruby/signature.rb +64 -0
  165. data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +29 -0
  166. data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +29 -0
  167. data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +391 -0
  168. data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +364 -0
  169. data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +52 -0
  170. data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +54 -0
  171. data/vendor/ruby-signature/lib/ruby/signature/cli.rb +534 -0
  172. data/vendor/ruby-signature/lib/ruby/signature/constant.rb +28 -0
  173. data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +152 -0
  174. data/vendor/ruby-signature/lib/ruby/signature/definition.rb +172 -0
  175. data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +921 -0
  176. data/vendor/ruby-signature/lib/ruby/signature/environment.rb +283 -0
  177. data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +138 -0
  178. data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +126 -0
  179. data/vendor/ruby-signature/lib/ruby/signature/errors.rb +189 -0
  180. data/vendor/ruby-signature/lib/ruby/signature/location.rb +104 -0
  181. data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +125 -0
  182. data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +93 -0
  183. data/vendor/ruby-signature/lib/ruby/signature/parser.y +1343 -0
  184. data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +441 -0
  185. data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +579 -0
  186. data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +383 -0
  187. data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +48 -0
  188. data/vendor/ruby-signature/lib/ruby/signature/test.rb +28 -0
  189. data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +63 -0
  190. data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +290 -0
  191. data/vendor/ruby-signature/lib/ruby/signature/test/setup.rb +58 -0
  192. data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +324 -0
  193. data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +185 -0
  194. data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +256 -0
  195. data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +72 -0
  196. data/vendor/ruby-signature/lib/ruby/signature/types.rb +932 -0
  197. data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +140 -0
  198. data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +49 -0
  199. data/vendor/ruby-signature/lib/ruby/signature/version.rb +5 -0
  200. data/vendor/ruby-signature/lib/ruby/signature/writer.rb +271 -0
  201. data/vendor/ruby-signature/ruby-signature.gemspec +45 -0
  202. data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +3 -0
  203. data/vendor/ruby-signature/stdlib/base64/base64.rbs +15 -0
  204. data/vendor/ruby-signature/stdlib/builtin/array.rbs +1997 -0
  205. data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +280 -0
  206. data/vendor/ruby-signature/stdlib/builtin/binding.rbs +177 -0
  207. data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +35 -0
  208. data/vendor/ruby-signature/stdlib/builtin/class.rbs +145 -0
  209. data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +116 -0
  210. data/vendor/ruby-signature/stdlib/builtin/complex.rbs +400 -0
  211. data/vendor/ruby-signature/stdlib/builtin/constants.rbs +37 -0
  212. data/vendor/ruby-signature/stdlib/builtin/data.rbs +5 -0
  213. data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +2 -0
  214. data/vendor/ruby-signature/stdlib/builtin/dir.rbs +419 -0
  215. data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +606 -0
  216. data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +404 -0
  217. data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +260 -0
  218. data/vendor/ruby-signature/stdlib/builtin/errno.rbs +781 -0
  219. data/vendor/ruby-signature/stdlib/builtin/errors.rbs +582 -0
  220. data/vendor/ruby-signature/stdlib/builtin/exception.rbs +193 -0
  221. data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +40 -0
  222. data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +68 -0
  223. data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +12 -0
  224. data/vendor/ruby-signature/stdlib/builtin/file.rbs +476 -0
  225. data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +59 -0
  226. data/vendor/ruby-signature/stdlib/builtin/float.rbs +696 -0
  227. data/vendor/ruby-signature/stdlib/builtin/gc.rbs +121 -0
  228. data/vendor/ruby-signature/stdlib/builtin/hash.rbs +1029 -0
  229. data/vendor/ruby-signature/stdlib/builtin/integer.rbs +710 -0
  230. data/vendor/ruby-signature/stdlib/builtin/io.rbs +683 -0
  231. data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +574 -0
  232. data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +135 -0
  233. data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +141 -0
  234. data/vendor/ruby-signature/stdlib/builtin/math.rbs +66 -0
  235. data/vendor/ruby-signature/stdlib/builtin/method.rbs +182 -0
  236. data/vendor/ruby-signature/stdlib/builtin/module.rbs +248 -0
  237. data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +82 -0
  238. data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +409 -0
  239. data/vendor/ruby-signature/stdlib/builtin/object.rbs +824 -0
  240. data/vendor/ruby-signature/stdlib/builtin/proc.rbs +426 -0
  241. data/vendor/ruby-signature/stdlib/builtin/process.rbs +354 -0
  242. data/vendor/ruby-signature/stdlib/builtin/random.rbs +93 -0
  243. data/vendor/ruby-signature/stdlib/builtin/range.rbs +226 -0
  244. data/vendor/ruby-signature/stdlib/builtin/rational.rbs +424 -0
  245. data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +10 -0
  246. data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +131 -0
  247. data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +14 -0
  248. data/vendor/ruby-signature/stdlib/builtin/signal.rbs +55 -0
  249. data/vendor/ruby-signature/stdlib/builtin/string.rbs +770 -0
  250. data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +13 -0
  251. data/vendor/ruby-signature/stdlib/builtin/struct.rbs +40 -0
  252. data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +230 -0
  253. data/vendor/ruby-signature/stdlib/builtin/thread.rbs +1112 -0
  254. data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +23 -0
  255. data/vendor/ruby-signature/stdlib/builtin/time.rbs +739 -0
  256. data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +91 -0
  257. data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +46 -0
  258. data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +159 -0
  259. data/vendor/ruby-signature/stdlib/builtin/warning.rbs +17 -0
  260. data/vendor/ruby-signature/stdlib/erb/erb.rbs +18 -0
  261. data/vendor/ruby-signature/stdlib/find/find.rbs +44 -0
  262. data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +21 -0
  263. data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +23 -0
  264. data/vendor/ruby-signature/stdlib/prime/prime.rbs +188 -0
  265. data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +9 -0
  266. data/vendor/ruby-signature/stdlib/set/set.rbs +77 -0
  267. data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +53 -0
  268. metadata +244 -54
  269. data/.travis.yml +0 -7
  270. data/lib/steep/ast/signature/alias.rb +0 -19
  271. data/lib/steep/ast/signature/class.rb +0 -33
  272. data/lib/steep/ast/signature/const.rb +0 -17
  273. data/lib/steep/ast/signature/env.rb +0 -138
  274. data/lib/steep/ast/signature/extension.rb +0 -21
  275. data/lib/steep/ast/signature/gvar.rb +0 -17
  276. data/lib/steep/ast/signature/interface.rb +0 -31
  277. data/lib/steep/ast/signature/members.rb +0 -115
  278. data/lib/steep/ast/signature/module.rb +0 -21
  279. data/lib/steep/drivers/print_interface.rb +0 -94
  280. data/lib/steep/drivers/scaffold.rb +0 -321
  281. data/lib/steep/drivers/utils/each_signature.rb +0 -31
  282. data/lib/steep/interface/abstract.rb +0 -68
  283. data/lib/steep/interface/builder.rb +0 -637
  284. data/lib/steep/interface/instantiated.rb +0 -163
  285. data/lib/steep/interface/ivar_chain.rb +0 -26
  286. data/lib/steep/parser.y +0 -1278
  287. data/lib/steep/project/listener.rb +0 -53
  288. data/smoke/class/a.rbi +0 -24
  289. data/smoke/class/d.rb +0 -9
  290. data/smoke/class/e.rb +0 -12
  291. data/smoke/class/i.rbi +0 -9
  292. data/smoke/hash/e.rbi +0 -3
  293. data/smoke/hello/hello.rbi +0 -7
  294. data/smoke/implements/a.rbi +0 -6
  295. data/smoke/initialize/a.rbi +0 -3
  296. data/smoke/module/a.rbi +0 -16
  297. data/smoke/self/a.rbi +0 -4
  298. data/smoke/super/a.rbi +0 -10
  299. data/stdlib/builtin.rbi +0 -787
@@ -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