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,710 @@
1
+ # Holds Integer values. You cannot add a singleton method to an Integer object,
2
+ # any attempt to do so will raise a TypeError.
3
+ #
4
+ class Integer < Numeric
5
+ # Returns the integer square root of the non-negative integer `n`, i.e. the
6
+ # largest non-negative integer less than or equal to the square root of `n`.
7
+ #
8
+ # Integer.sqrt(0) #=> 0
9
+ # Integer.sqrt(1) #=> 1
10
+ # Integer.sqrt(24) #=> 4
11
+ # Integer.sqrt(25) #=> 5
12
+ # Integer.sqrt(10**400) #=> 10**200
13
+ #
14
+ # Equivalent to `Math.sqrt(n).floor`, except that the result of the latter code
15
+ # may differ from the true value due to the limited precision of floating point
16
+ # arithmetic.
17
+ #
18
+ # Integer.sqrt(10**46) #=> 100000000000000000000000
19
+ # Math.sqrt(10**46).floor #=> 99999999999999991611392 (!)
20
+ #
21
+ # If `n` is not an Integer, it is converted to an Integer first. If `n` is
22
+ # negative, a Math::DomainError is raised.
23
+ #
24
+ def self.sqrt: (int n) -> Integer
25
+
26
+ public
27
+
28
+ # Returns `int` modulo `other`.
29
+ #
30
+ # See Numeric#divmod for more information.
31
+ #
32
+ def %: (Float) -> Float
33
+ | (Rational) -> Rational
34
+ | (Integer) -> Integer
35
+ | (Numeric) -> Numeric
36
+
37
+ # Bitwise AND.
38
+ #
39
+ def &: (Integer) -> Integer
40
+
41
+ # Performs multiplication: the class of the resulting object depends on the
42
+ # class of `numeric`.
43
+ #
44
+ def *: (Float) -> Float
45
+ | (Rational) -> Rational
46
+ | (Complex) -> Complex
47
+ | (Integer) -> Integer
48
+ | (Numeric) -> Numeric
49
+
50
+ # Raises `int` to the power of `numeric`, which may be negative or fractional.
51
+ # The result may be an Integer, a Float, a Rational, or a complex number.
52
+ #
53
+ # 2 ** 3 #=> 8
54
+ # 2 ** -1 #=> (1/2)
55
+ # 2 ** 0.5 #=> 1.4142135623730951
56
+ # (-1) ** 0.5 #=> (0.0+1.0i)
57
+ #
58
+ # 123456789 ** 2 #=> 15241578750190521
59
+ # 123456789 ** 1.2 #=> 5126464716.0993185
60
+ # 123456789 ** -2 #=> (1/15241578750190521)
61
+ #
62
+ def **: (Integer) -> Numeric
63
+ | (Float) -> Numeric
64
+ | (Rational) -> Numeric
65
+ | (Complex) -> Complex
66
+ | (Numeric) -> Numeric
67
+
68
+ # Performs addition: the class of the resulting object depends on the class of
69
+ # `numeric`.
70
+ #
71
+ def +: (Integer) -> Integer
72
+ | (Float) -> Float
73
+ | (Rational) -> Rational
74
+ | (Complex) -> Complex
75
+ | (Numeric) -> Numeric
76
+
77
+ def +@: () -> Integer
78
+
79
+ # Performs subtraction: the class of the resulting object depends on the class
80
+ # of `numeric`.
81
+ #
82
+ def -: (Integer) -> Integer
83
+ | (Float) -> Float
84
+ | (Rational) -> Rational
85
+ | (Complex) -> Complex
86
+ | (Numeric) -> Numeric
87
+
88
+ # Returns `int`, negated.
89
+ #
90
+ def -@: () -> Integer
91
+
92
+ # Performs division: the class of the resulting object depends on the class of
93
+ # `numeric`.
94
+ #
95
+ def /: (Integer) -> Integer
96
+ | (Float) -> Float
97
+ | (Rational) -> Rational
98
+ | (Complex) -> Complex
99
+ | (Numeric) -> Numeric
100
+
101
+ # Returns `true` if the value of `int` is less than that of `real`.
102
+ #
103
+ def <: (Numeric) -> bool
104
+
105
+ # Returns `int` shifted left `count` positions, or right if `count` is negative.
106
+ #
107
+ def <<: (int) -> Integer
108
+
109
+ # Returns `true` if the value of `int` is less than or equal to that of `real`.
110
+ #
111
+ def <=: (Numeric) -> bool
112
+
113
+ # Comparison---Returns -1, 0, or +1 depending on whether `int` is less than,
114
+ # equal to, or greater than `numeric`.
115
+ #
116
+ # This is the basis for the tests in the Comparable module.
117
+ #
118
+ # `nil` is returned if the two values are incomparable.
119
+ #
120
+ def <=>: (Numeric) -> Integer?
121
+
122
+ # Returns `true` if `int` equals `other` numerically. Contrast this with
123
+ # Integer#eql?, which requires `other` to be an Integer.
124
+ #
125
+ # 1 == 2 #=> false
126
+ # 1 == 1.0 #=> true
127
+ #
128
+ def ==: (untyped) -> bool
129
+
130
+ # Returns `true` if `int` equals `other` numerically. Contrast this with
131
+ # Integer#eql?, which requires `other` to be an Integer.
132
+ #
133
+ # 1 == 2 #=> false
134
+ # 1 == 1.0 #=> true
135
+ #
136
+ def ===: (untyped) -> bool
137
+
138
+ # Returns `true` if the value of `int` is greater than that of `real`.
139
+ #
140
+ def >: (Numeric) -> bool
141
+
142
+ # Returns `true` if the value of `int` is greater than or equal to that of
143
+ # `real`.
144
+ #
145
+ def >=: (Numeric) -> bool
146
+
147
+ # Returns `int` shifted right `count` positions, or left if `count` is negative.
148
+ #
149
+ def >>: (int) -> Integer
150
+
151
+ # Bit Reference---Returns the `n`th bit in the binary representation of `int`,
152
+ # where `int[0]` is the least significant bit.
153
+ #
154
+ # a = 0b11001100101010
155
+ # 30.downto(0) {|n| print a[n] }
156
+ # #=> 0000000000000000011001100101010
157
+ #
158
+ # a = 9**15
159
+ # 50.downto(0) {|n| print a[n] }
160
+ # #=> 000101110110100000111000011110010100111100010111001
161
+ #
162
+ # In principle, `n[i]` is equivalent to `(n >> i) & 1`. Thus, any negative index
163
+ # always returns zero:
164
+ #
165
+ # p 255[-1] #=> 0
166
+ #
167
+ # Range operations `n[i, len]` and `n[i..j]` are naturally extended.
168
+ #
169
+ # * `n[i, len]` equals to `(n >> i) & ((1 << len) - 1)`.
170
+ # * `n[i..j]` equals to `(n >> i) & ((1 << (j - i + 1)) - 1)`.
171
+ # * `n[i...j]` equals to `(n >> i) & ((1 << (j - i)) - 1)`.
172
+ # * `n[i..]` equals to `(n >> i)`.
173
+ # * `n[..j]` is zero if `n & ((1 << (j + 1)) - 1)` is zero. Otherwise, raises
174
+ # an ArgumentError.
175
+ # * `n[...j]` is zero if `n & ((1 << j) - 1)` is zero. Otherwise, raises an
176
+ # ArgumentError.
177
+ #
178
+ #
179
+ # Note that range operation may exhaust memory. For example, `-1[0,
180
+ # 1000000000000]` will raise NoMemoryError.
181
+ #
182
+ def []: (int) -> Integer
183
+ | (int i, int len) -> Integer
184
+ | (Range[int]) -> Integer
185
+
186
+ # Bitwise EXCLUSIVE OR.
187
+ #
188
+ def ^: (Integer) -> Integer
189
+
190
+ # Returns the absolute value of `int`.
191
+ #
192
+ # (-12345).abs #=> 12345
193
+ # -12345.abs #=> 12345
194
+ # 12345.abs #=> 12345
195
+ #
196
+ # Integer#magnitude is an alias for Integer#abs.
197
+ #
198
+ def abs: () -> Integer
199
+
200
+ def abs2: () -> Integer
201
+
202
+ # Returns `true` if all bits of `int & mask` are 1.
203
+ #
204
+ def allbits?: (int mask) -> bool
205
+
206
+ def angle: () -> (Integer | Float)
207
+
208
+ # Returns `true` if any bits of `int & mask` are 1.
209
+ #
210
+ def anybits?: (int mask) -> bool
211
+
212
+ alias arg angle
213
+
214
+ # Returns the number of bits of the value of `int`.
215
+ #
216
+ # "Number of bits" means the bit position of the highest bit which is different
217
+ # from the sign bit (where the least significant bit has bit position 1). If
218
+ # there is no such bit (zero or minus one), zero is returned.
219
+ #
220
+ # I.e. this method returns *ceil(log2(int < 0 ? -int : int+1))*.
221
+ #
222
+ # (-2**1000-1).bit_length #=> 1001
223
+ # (-2**1000).bit_length #=> 1000
224
+ # (-2**1000+1).bit_length #=> 1000
225
+ # (-2**12-1).bit_length #=> 13
226
+ # (-2**12).bit_length #=> 12
227
+ # (-2**12+1).bit_length #=> 12
228
+ # -0x101.bit_length #=> 9
229
+ # -0x100.bit_length #=> 8
230
+ # -0xff.bit_length #=> 8
231
+ # -2.bit_length #=> 1
232
+ # -1.bit_length #=> 0
233
+ # 0.bit_length #=> 0
234
+ # 1.bit_length #=> 1
235
+ # 0xff.bit_length #=> 8
236
+ # 0x100.bit_length #=> 9
237
+ # (2**12-1).bit_length #=> 12
238
+ # (2**12).bit_length #=> 13
239
+ # (2**12+1).bit_length #=> 13
240
+ # (2**1000-1).bit_length #=> 1000
241
+ # (2**1000).bit_length #=> 1001
242
+ # (2**1000+1).bit_length #=> 1001
243
+ #
244
+ # This method can be used to detect overflow in Array#pack as follows:
245
+ #
246
+ # if n.bit_length < 32
247
+ # [n].pack("l") # no overflow
248
+ # else
249
+ # raise "overflow"
250
+ # end
251
+ #
252
+ def bit_length: () -> Integer
253
+
254
+ # Returns the smallest number greater than or equal to `int` with a precision of
255
+ # `ndigits` decimal digits (default: 0).
256
+ #
257
+ # When the precision is negative, the returned value is an integer with at least
258
+ # `ndigits.abs` trailing zeros.
259
+ #
260
+ # Returns `self` when `ndigits` is zero or positive.
261
+ #
262
+ # 1.ceil #=> 1
263
+ # 1.ceil(2) #=> 1
264
+ # 18.ceil(-1) #=> 20
265
+ # (-18).ceil(-1) #=> -10
266
+ #
267
+ def ceil: () -> Integer
268
+ | (int digits) -> (Integer | Float)
269
+
270
+ # Returns a string containing the character represented by the `int`'s value
271
+ # according to `encoding`.
272
+ #
273
+ # 65.chr #=> "A"
274
+ # 230.chr #=> "\xE6"
275
+ # 255.chr(Encoding::UTF_8) #=> "\u00FF"
276
+ #
277
+ def chr: (?Encoding | string) -> String
278
+
279
+ def clone: (?freeze: bool) -> self
280
+
281
+ # Returns an array with both a `numeric` and a `big` represented as Bignum
282
+ # objects.
283
+ #
284
+ # This is achieved by converting `numeric` to a Bignum.
285
+ #
286
+ # A TypeError is raised if the `numeric` is not a Fixnum or Bignum type.
287
+ #
288
+ # (0x3FFFFFFFFFFFFFFF+1).coerce(42) #=> [42, 4611686018427387904]
289
+ #
290
+ def coerce: (Numeric) -> [Numeric, Numeric]
291
+
292
+ def conj: () -> Integer
293
+
294
+ def conjugate: () -> Integer
295
+
296
+ # Returns 1.
297
+ #
298
+ def denominator: () -> Integer
299
+
300
+ # Returns the digits of `int`'s place-value representation with radix `base`
301
+ # (default: 10). The digits are returned as an array with the least significant
302
+ # digit as the first array element.
303
+ #
304
+ # `base` must be greater than or equal to 2.
305
+ #
306
+ # 12345.digits #=> [5, 4, 3, 2, 1]
307
+ # 12345.digits(7) #=> [4, 6, 6, 0, 5]
308
+ # 12345.digits(100) #=> [45, 23, 1]
309
+ #
310
+ # -12345.digits(7) #=> Math::DomainError
311
+ #
312
+ def digits: (?int base) -> ::Array[Integer]
313
+
314
+ # Performs integer division: returns the integer result of dividing `int` by
315
+ # `numeric`.
316
+ #
317
+ def div: (Numeric) -> Integer
318
+
319
+ # See Numeric#divmod.
320
+ #
321
+ def divmod: (Integer) -> [Integer, Integer]
322
+ | (Float) -> [Float, Float]
323
+ | (Numeric) -> [Numeric, Numeric]
324
+
325
+ # Iterates the given block, passing in decreasing values from `int` down to and
326
+ # including `limit`.
327
+ #
328
+ # If no block is given, an Enumerator is returned instead.
329
+ #
330
+ # 5.downto(1) { |n| print n, ".. " }
331
+ # puts "Liftoff!"
332
+ # #=> "5.. 4.. 3.. 2.. 1.. Liftoff!"
333
+ #
334
+ def downto: (Integer limit) { (Integer) -> void } -> Integer
335
+ | (Integer limit) -> ::Enumerator[Integer, self]
336
+
337
+ def dup: () -> self
338
+
339
+ def eql?: (untyped) -> bool
340
+
341
+ # Returns `true` if `int` is an even number.
342
+ #
343
+ def even?: () -> bool
344
+
345
+ # Returns the floating point result of dividing `int` by `numeric`.
346
+ #
347
+ # 654321.fdiv(13731) #=> 47.652829364212366
348
+ # 654321.fdiv(13731.24) #=> 47.65199646936475
349
+ # -654321.fdiv(13731) #=> -47.652829364212366
350
+ #
351
+ def fdiv: (Numeric) -> Float
352
+
353
+ def finite?: () -> bool
354
+
355
+ # Returns the largest number less than or equal to `int` with a precision of
356
+ # `ndigits` decimal digits (default: 0).
357
+ #
358
+ # When the precision is negative, the returned value is an integer with at least
359
+ # `ndigits.abs` trailing zeros.
360
+ #
361
+ # Returns `self` when `ndigits` is zero or positive.
362
+ #
363
+ # 1.floor #=> 1
364
+ # 1.floor(2) #=> 1
365
+ # 18.floor(-1) #=> 10
366
+ # (-18).floor(-1) #=> -20
367
+ #
368
+ def floor: () -> Integer
369
+ | (int digits) -> (Integer | Float)
370
+
371
+ # Returns the greatest common divisor of the two integers. The result is always
372
+ # positive. 0.gcd(x) and x.gcd(0) return x.abs.
373
+ #
374
+ # 36.gcd(60) #=> 12
375
+ # 2.gcd(2) #=> 2
376
+ # 3.gcd(-7) #=> 1
377
+ # ((1<<31)-1).gcd((1<<61)-1) #=> 1
378
+ #
379
+ def gcd: (Integer) -> Integer
380
+
381
+ # Returns an array with the greatest common divisor and the least common
382
+ # multiple of the two integers, [gcd, lcm].
383
+ #
384
+ # 36.gcdlcm(60) #=> [12, 180]
385
+ # 2.gcdlcm(2) #=> [2, 2]
386
+ # 3.gcdlcm(-7) #=> [1, 21]
387
+ # ((1<<31)-1).gcdlcm((1<<61)-1) #=> [1, 4951760154835678088235319297]
388
+ #
389
+ def gcdlcm: (Integer) -> [ Integer, Integer ]
390
+
391
+ def i: () -> Complex
392
+
393
+ def imag: () -> Integer
394
+
395
+ def imaginary: () -> Integer
396
+
397
+ def infinite?: () -> Integer?
398
+
399
+ alias inspect to_s
400
+
401
+ # Since `int` is already an Integer, this always returns `true`.
402
+ #
403
+ def integer?: () -> true
404
+
405
+ # Returns the least common multiple of the two integers. The result is always
406
+ # positive. 0.lcm(x) and x.lcm(0) return zero.
407
+ #
408
+ # 36.lcm(60) #=> 180
409
+ # 2.lcm(2) #=> 2
410
+ # 3.lcm(-7) #=> 21
411
+ # ((1<<31)-1).lcm((1<<61)-1) #=> 4951760154835678088235319297
412
+ #
413
+ def lcm: (Integer) -> Integer
414
+
415
+ # Returns the absolute value of `int`.
416
+ #
417
+ # (-12345).abs #=> 12345
418
+ # -12345.abs #=> 12345
419
+ # 12345.abs #=> 12345
420
+ #
421
+ # Integer#magnitude is an alias for Integer#abs.
422
+ #
423
+ def magnitude: () -> Integer
424
+
425
+ # Returns `int` modulo `other`.
426
+ #
427
+ # See Numeric#divmod for more information.
428
+ #
429
+ alias modulo `%`
430
+
431
+ def negative?: () -> bool
432
+
433
+ # Returns the successor of `int`, i.e. the Integer equal to `int+1`.
434
+ #
435
+ # 1.next #=> 2
436
+ # (-1).next #=> 0
437
+ # 1.succ #=> 2
438
+ # (-1).succ #=> 0
439
+ #
440
+ def next: () -> Integer
441
+
442
+ # Returns `true` if no bits of `int & mask` are 1.
443
+ #
444
+ def nobits?: (int mask) -> bool
445
+
446
+ def nonzero?: () -> self?
447
+
448
+ # Returns self.
449
+ #
450
+ def numerator: () -> Integer
451
+
452
+ # Returns `true` if `int` is an odd number.
453
+ #
454
+ def odd?: () -> bool
455
+
456
+ # Returns the `int` itself.
457
+ #
458
+ # 97.ord #=> 97
459
+ #
460
+ # This method is intended for compatibility to character literals in Ruby 1.9.
461
+ #
462
+ # For example, `?a.ord` returns 97 both in 1.8 and 1.9.
463
+ #
464
+ def ord: () -> Integer
465
+
466
+ alias phase angle
467
+
468
+ def polar: () -> [ Integer, Integer | Float ]
469
+
470
+ def positive?: () -> bool
471
+
472
+ # Returns (modular) exponentiation as:
473
+ #
474
+ # a.pow(b) #=> same as a**b
475
+ # a.pow(b, m) #=> same as (a**b) % m, but avoids huge temporary values
476
+ #
477
+ def pow: (Integer other, ?Integer modulo) -> Integer
478
+ | (Numeric numeric) -> Numeric
479
+
480
+ # Returns the predecessor of `int`, i.e. the Integer equal to `int-1`.
481
+ #
482
+ # 1.pred #=> 0
483
+ # (-1).pred #=> -2
484
+ #
485
+ def pred: () -> Integer
486
+
487
+ def quo: (Integer) -> Rational
488
+ | (Float) -> Float
489
+ | (Rational) -> Rational
490
+ | (Complex) -> Complex
491
+ | (Numeric) -> Numeric
492
+
493
+ # Returns the value as a rational. The optional argument `eps` is always
494
+ # ignored.
495
+ #
496
+ def rationalize: (?Numeric eps) -> Rational
497
+
498
+ def real: () -> self
499
+
500
+ def real?: () -> true
501
+
502
+ def rect: () -> [ Integer, Numeric ]
503
+
504
+ alias rectangular rect
505
+
506
+ # Returns the remainder after dividing `int` by `numeric`.
507
+ #
508
+ # `x.remainder(y)` means `x-y*(x/y).truncate`.
509
+ #
510
+ # 5.remainder(3) #=> 2
511
+ # -5.remainder(3) #=> -2
512
+ # 5.remainder(-3) #=> 2
513
+ # -5.remainder(-3) #=> -2
514
+ # 5.remainder(1.5) #=> 0.5
515
+ #
516
+ # See Numeric#divmod.
517
+ #
518
+ def remainder: (Integer) -> Integer
519
+ | (Float) -> Float
520
+ | (Rational) -> Rational
521
+ | (Numeric) -> Numeric
522
+
523
+ # Returns `int` rounded to the nearest value with a precision of `ndigits`
524
+ # decimal digits (default: 0).
525
+ #
526
+ # When the precision is negative, the returned value is an integer with at least
527
+ # `ndigits.abs` trailing zeros.
528
+ #
529
+ # Returns `self` when `ndigits` is zero or positive.
530
+ #
531
+ # 1.round #=> 1
532
+ # 1.round(2) #=> 1
533
+ # 15.round(-1) #=> 20
534
+ # (-15).round(-1) #=> -20
535
+ #
536
+ # The optional `half` keyword argument is available similar to Float#round.
537
+ #
538
+ # 25.round(-1, half: :up) #=> 30
539
+ # 25.round(-1, half: :down) #=> 20
540
+ # 25.round(-1, half: :even) #=> 20
541
+ # 35.round(-1, half: :up) #=> 40
542
+ # 35.round(-1, half: :down) #=> 30
543
+ # 35.round(-1, half: :even) #=> 40
544
+ # (-25).round(-1, half: :up) #=> -30
545
+ # (-25).round(-1, half: :down) #=> -20
546
+ # (-25).round(-1, half: :even) #=> -20
547
+ #
548
+ def round: (?half: :up | :down | :even) -> Integer
549
+ | (int digits, ?half: :up | :down | :even) -> (Integer | Float)
550
+
551
+ # Returns the number of bytes in the machine representation of `int` (machine
552
+ # dependent).
553
+ #
554
+ # 1.size #=> 8
555
+ # -1.size #=> 8
556
+ # 2147483647.size #=> 8
557
+ # (256**10 - 1).size #=> 10
558
+ # (256**20 - 1).size #=> 20
559
+ # (256**40 - 1).size #=> 40
560
+ #
561
+ def size: () -> Integer
562
+
563
+ def step: () { (Integer) -> void } -> void
564
+ | (Numeric limit, ?Integer step) { (Integer) -> void } -> void
565
+ | (Numeric limit, ?Numeric step) { (Numeric) -> void } -> void
566
+ | (to: Numeric, ?by: Integer) { (Integer) -> void } -> void
567
+ | (?to: Numeric, by: Numeric) { (Numeric) -> void } -> void
568
+ | () -> Enumerator[Integer, bot]
569
+ | (Numeric limit, ?Integer step) -> Enumerator[Integer, void]
570
+ | (Numeric limit, ?Numeric step) -> Enumerator[Numeric, void]
571
+ | (to: Numeric, ?by: Integer) -> Enumerator[Integer, void]
572
+ | (?to: Numeric, by: Numeric) -> Enumerator[Numeric, void]
573
+
574
+ # Returns the successor of `int`, i.e. the Integer equal to `int+1`.
575
+ #
576
+ # 1.next #=> 2
577
+ # (-1).next #=> 0
578
+ # 1.succ #=> 2
579
+ # (-1).succ #=> 0
580
+ #
581
+ def succ: () -> Integer
582
+
583
+ # Iterates the given block `int` times, passing in values from zero to `int -
584
+ # 1`.
585
+ #
586
+ # If no block is given, an Enumerator is returned instead.
587
+ #
588
+ # 5.times {|i| print i, " " } #=> 0 1 2 3 4
589
+ #
590
+ def times: () { (Integer) -> void } -> self
591
+ | () -> ::Enumerator[Integer, self]
592
+
593
+ def to_c: () -> Complex
594
+
595
+ # Converts `int` to a Float. If `int` doesn't fit in a Float, the result is
596
+ # infinity.
597
+ #
598
+ def to_f: () -> Float
599
+
600
+ # Since `int` is already an Integer, returns `self`.
601
+ #
602
+ # #to_int is an alias for #to_i.
603
+ #
604
+ def to_i: () -> Integer
605
+
606
+ # Since `int` is already an Integer, returns `self`.
607
+ #
608
+ # #to_int is an alias for #to_i.
609
+ #
610
+ alias to_int to_i
611
+
612
+ # Returns the value as a rational.
613
+ #
614
+ # 1.to_r #=> (1/1)
615
+ # (1<<64).to_r #=> (18446744073709551616/1)
616
+ #
617
+ def to_r: () -> Rational
618
+
619
+ # Returns a string containing the place-value representation of `int` with radix
620
+ # `base` (between 2 and 36).
621
+ #
622
+ # 12345.to_s #=> "12345"
623
+ # 12345.to_s(2) #=> "11000000111001"
624
+ # 12345.to_s(8) #=> "30071"
625
+ # 12345.to_s(10) #=> "12345"
626
+ # 12345.to_s(16) #=> "3039"
627
+ # 12345.to_s(36) #=> "9ix"
628
+ # 78546939656932.to_s(36) #=> "rubyrules"
629
+ #
630
+ def to_s: () -> String
631
+ | (2) -> String
632
+ | (3) -> String
633
+ | (4) -> String
634
+ | (5) -> String
635
+ | (6) -> String
636
+ | (7) -> String
637
+ | (8) -> String
638
+ | (9) -> String
639
+ | (10) -> String
640
+ | (11) -> String
641
+ | (12) -> String
642
+ | (13) -> String
643
+ | (14) -> String
644
+ | (15) -> String
645
+ | (16) -> String
646
+ | (17) -> String
647
+ | (18) -> String
648
+ | (19) -> String
649
+ | (20) -> String
650
+ | (21) -> String
651
+ | (22) -> String
652
+ | (23) -> String
653
+ | (24) -> String
654
+ | (25) -> String
655
+ | (26) -> String
656
+ | (27) -> String
657
+ | (28) -> String
658
+ | (29) -> String
659
+ | (30) -> String
660
+ | (31) -> String
661
+ | (32) -> String
662
+ | (33) -> String
663
+ | (34) -> String
664
+ | (35) -> String
665
+ | (36) -> String
666
+ | (int base) -> String
667
+
668
+ # Returns `int` truncated (toward zero) to a precision of `ndigits` decimal
669
+ # digits (default: 0).
670
+ #
671
+ # When the precision is negative, the returned value is an integer with at least
672
+ # `ndigits.abs` trailing zeros.
673
+ #
674
+ # Returns `self` when `ndigits` is zero or positive.
675
+ #
676
+ # 1.truncate #=> 1
677
+ # 1.truncate(2) #=> 1
678
+ # 18.truncate(-1) #=> 10
679
+ # (-18).truncate(-1) #=> -10
680
+ #
681
+ def truncate: () -> Integer
682
+ | (int ndigits) -> Integer
683
+
684
+ # Iterates the given block, passing in integer values from `int` up to and
685
+ # including `limit`.
686
+ #
687
+ # If no block is given, an Enumerator is returned instead.
688
+ #
689
+ # 5.upto(10) {|i| print i, " " } #=> 5 6 7 8 9 10
690
+ #
691
+ def upto: (Integer limit) { (Integer) -> void } -> Integer
692
+ | (Integer limit) -> ::Enumerator[Integer, self]
693
+
694
+ def zero?: () -> bool
695
+
696
+ # Bitwise OR.
697
+ #
698
+ def |: (Integer) -> Integer
699
+
700
+ # One's complement: returns a number where each bit is flipped.
701
+ #
702
+ # Inverts the bits in an Integer. As integers are conceptually of infinite
703
+ # length, the result acts as if it had an infinite number of one bits to the
704
+ # left. In hex representations, this is displayed as two periods to the left of
705
+ # the digits.
706
+ #
707
+ # sprintf("%X", ~0x1122334455) #=> "..FEEDDCCBBAA"
708
+ #
709
+ def ~: () -> Integer
710
+ end