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,5 @@
1
+ target :test do
2
+ check "*.rb"
3
+ signature "*.rbs"
4
+ library "set"
5
+ end
@@ -1,7 +1,7 @@
1
1
  class Foo
2
- # @type method foo: (Array<String>) -> void
2
+ # @type method foo: (Array[String]) -> void
3
3
  def array(x)
4
- # @type ivar @y: Array<String>>
4
+ # @type ivar @y: Array[String]
5
5
  @y = x
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  class Foo
2
- # @type method foo: (Hash<String, any>) -> void
2
+ # @type method foo: (Hash[String, untyped]) -> void
3
3
  def foo(x)
4
- # @type ivar @y: Hash<String, any>
4
+ # @type ivar @y: Hash[String, untyped]
5
5
  @y = x
6
6
  end
7
7
  end
@@ -0,0 +1,2 @@
1
+ # @type var a: PolyNew[String]
2
+ a = PolyNew.new(a: "")
@@ -0,0 +1,4 @@
1
+ class PolyNew[A]
2
+ def initialize: (a: A) -> void
3
+ def foo: () -> A
4
+ end
@@ -1,5 +1,5 @@
1
- d = Set.new([1,2,3], &:to_s)
2
- # !expects NoMethodError: type=::Set<::String>, method=ffffffff
1
+ d = Set["1","2","3"]
2
+ # !expects NoMethodError: type=::Set[::String], method=ffffffff
3
3
  d.ffffffff
4
4
 
5
5
  d.divide do |x, y|
@@ -0,0 +1,4 @@
1
+ target :test do
2
+ check "*.rb"
3
+ signature "*.rbs"
4
+ end
data/smoke/rescue/a.rb CHANGED
@@ -34,7 +34,7 @@ d = begin
34
34
 
35
35
  # @type var e: Integer
36
36
 
37
- # !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=(::Array<::Integer> | ::Integer | ::String | ::Symbol)
37
+ # !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=(::Array[::Integer] | ::Integer | ::String | ::Symbol)
38
38
  e = begin
39
39
  'foo'
40
40
  rescue RuntimeError
@@ -0,0 +1,4 @@
1
+ target :test do
2
+ check "*.rb"
3
+ signature "*.rbs"
4
+ end
data/smoke/self/a.rbs ADDED
@@ -0,0 +1,4 @@
1
+ class A
2
+ def foo: -> untyped
3
+ def bar: -> untyped
4
+ end
@@ -0,0 +1,4 @@
1
+ target :test do
2
+ check "*.rb"
3
+ signature "*.rbs"
4
+ end
@@ -0,0 +1,4 @@
1
+ target :test do
2
+ check "*.rb"
3
+ signature "*.rbs"
4
+ end
@@ -1,5 +1,5 @@
1
1
  interface _Puts
2
- def puts: (*any) -> void
2
+ def puts: (*untyped) -> void
3
3
  end
4
4
 
5
5
  class A
@@ -0,0 +1,4 @@
1
+ target :test do
2
+ check "*.rb"
3
+ signature "*.rbs"
4
+ end
data/smoke/super/a.rbs ADDED
@@ -0,0 +1,10 @@
1
+ class A
2
+ def foo: (untyped) -> Integer
3
+ include M
4
+
5
+ def baz: () -> untyped
6
+ end
7
+
8
+ module M
9
+ def foo: (untyped) -> Object
10
+ end
@@ -0,0 +1,4 @@
1
+ target :test do
2
+ check "*.rb"
3
+ signature "*.rbs"
4
+ end
data/smoke/type_case/a.rb CHANGED
@@ -8,7 +8,7 @@ when Integer, String
8
8
  x.foobar()
9
9
  end
10
10
 
11
- case x == 1
11
+ case x == (_ = 1)
12
12
  when Integer
13
13
  # !expects NoMethodError: type=(::Integer | ::String | ::Symbol), method=foobar
14
14
  x.foobar
@@ -0,0 +1,4 @@
1
+ target :test do
2
+ check "*.rb"
3
+ signature "*.rbs"
4
+ end
data/smoke/yield/a.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class A
2
- # @type method foo: () { (Integer) -> Integer } -> any
2
+ # @type method foo: () { (Integer) -> Integer } -> untyped
3
3
  def foo()
4
4
  # @type var x: String
5
5
 
@@ -10,7 +10,7 @@ class A
10
10
  yield(x)
11
11
  end
12
12
 
13
- # @type method bar: () -> any
13
+ # @type method bar: () -> untyped
14
14
  def bar()
15
15
  # !expects UnexpectedYield
16
16
  yield 4
data/steep.gemspec CHANGED
@@ -14,26 +14,33 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = "https://github.com/soutaro/steep"
15
15
  spec.license = 'MIT'
16
16
 
17
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ spec.files = `git ls-files -z`.split("\x0").reject {|f|
18
18
  f.match(%r{^(test|spec|features)/})
19
- end
20
- spec.files << "lib/steep/parser.rb"
19
+ } + Dir.chdir("vendor/ruby-signature") {
20
+ `git ls-files -z`.split("\x0")
21
+ .reject {|f| f.match(%r{^(test|spec|features)/}) }
22
+ .map {|f| File.join("vendor/ruby-signature", f) }
23
+ }
24
+ spec.files << "vendor/ruby-signature/lib/ruby/signature/parser.rb"
25
+
21
26
  spec.bindir = "exe"
22
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
28
  spec.require_paths = ["lib"]
24
29
 
25
- spec.required_ruby_version = '>= 2.5.0'
30
+ spec.required_ruby_version = '>= 2.6.0'
26
31
 
27
32
  spec.add_development_dependency "bundler", ">= 1.13"
28
- spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "rake", "~> 13.0"
29
34
  spec.add_development_dependency "minitest", "~> 5.0"
30
35
  spec.add_development_dependency "racc", "~> 1.4"
36
+ spec.add_development_dependency "minitest-reporters", "~> 1.3.6"
37
+ spec.add_development_dependency "minitest-hooks", "~> 1.5.0"
31
38
 
32
- spec.add_runtime_dependency "parser", "~> 2.4"
39
+ spec.add_runtime_dependency "parser", "~> 2.7.0"
33
40
  spec.add_runtime_dependency "ast_utils", "~> 0.3.0"
34
41
  spec.add_runtime_dependency "activesupport", ">= 5.1"
35
42
  spec.add_runtime_dependency "rainbow", ">= 2.2.2", "< 4.0"
36
43
  spec.add_runtime_dependency "listen", "~> 3.1"
37
44
  spec.add_runtime_dependency "pry", "~> 0.12.2"
38
- spec.add_runtime_dependency "language_server-protocol", "~> 3.14.0"
45
+ spec.add_runtime_dependency "language_server-protocol", "~> 3.14.0.1"
39
46
  end
@@ -0,0 +1,27 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request: {}
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: "ubuntu-latest"
12
+ strategy:
13
+ matrix:
14
+ container_tag:
15
+ - master-nightly-bionic
16
+ - 2.6.5-bionic
17
+ - 2.7.0-bionic
18
+ container:
19
+ image: rubylang/ruby:${{ matrix.container_tag }}
20
+ steps:
21
+ - uses: actions/checkout@v1
22
+ - name: Run test
23
+ run: |
24
+ ruby -v
25
+ gem install bundler
26
+ bundle install --jobs 4 --retry 3
27
+ bundle exec rake
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /pkg/
6
+ /spec/reports/
7
+ /tmp/
8
+ /Gemfile.lock
9
+ /.ruby-version
10
+ /lib/ruby/signature/parser.rb
11
+ /lib/ruby/signature/parser.output
12
+ /vendor/sigs
@@ -0,0 +1,15 @@
1
+ require: rubocop-rubycw
2
+ AllCops:
3
+ TargetRubyVersion: 2.7
4
+ DisabledByDefault: true
5
+ Exclude:
6
+ - 'vendor/bundle/**/*'
7
+ Rubycw/Rubycw:
8
+ Enabled: true
9
+ Exclude:
10
+ - 'test/**/*_test.rb'
11
+
12
+ Lint/DuplicateMethods:
13
+ Enabled: true
14
+ Include:
15
+ - 'test/**/*_test.rb'
@@ -0,0 +1,22 @@
1
+ Copyright (C) 2019 Soutaro Matsumoto. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions
5
+ are met:
6
+ 1. Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ 2. Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
+ SUCH DAMAGE.
@@ -0,0 +1,56 @@
1
+ ruby-signature is copyrighted free software by Soutaro Matsumoto <matsumoto@soutaro.com>.
2
+ You can redistribute it and/or modify it under either the terms of the
3
+ 2-clause BSDL (see the file BSDL), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a. place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b. use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c. give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
+
23
+ d. make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
27
+
28
+ a. distribute the binaries and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b. accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c. give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d. make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under these terms.
43
+
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ruby-signature.gemspec
4
+ gemspec
5
+
6
+ gem "ruby-signature-amber", path: "test/assets/test-gem"
@@ -0,0 +1,93 @@
1
+ # Ruby::Signature
2
+
3
+ Ruby::Signature provides syntax and semantics definition for the `Ruby Signature` language, `.rbs` files.
4
+ It consists of a parser, the syntax, and class definition interpreter, the semantics.
5
+
6
+ ## Build
7
+
8
+ We haven't published a gem yet.
9
+ You need to install the dependencies, and build its parser with `bin/setup`.
10
+
11
+ ```
12
+ $ bin/setup
13
+ $ bundle exec exe/ruby-signature
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```
19
+ $ ruby-signature list
20
+ $ ruby-signature ancestors ::Object
21
+ $ ruby-signature methods ::Object
22
+ $ ruby-signature method ::Object tap
23
+ ```
24
+
25
+ ### ruby-signature [--class|--module|interface] list
26
+
27
+ ```
28
+ $ ruby-signature list
29
+ ```
30
+
31
+ This command lists all of the classes/modules/interfaces defined in `.rbs` files.
32
+
33
+ ### ruby-signature ancestors [--singleton|--instance] CLASS
34
+
35
+ ```
36
+ $ ruby-signature ancestors Array # ([].class.ancestors)
37
+ $ ruby-signature ancestors --singleton Array # (Array.class.ancestors)
38
+ ```
39
+
40
+ This command prints the _ancestors_ of the class.
41
+ The name of the command is borrowed from `Class#ancestors`, but the semantics is a bit different.
42
+ The `ancestors` command is more precise (I believe).
43
+
44
+ ### ruby-signature methods [--singleton|--instance] CLASS
45
+
46
+ ```
47
+ $ ruby-signature methods ::Integer # 1.methods
48
+ $ ruby-signature methods --singleton ::Object # Object.methods
49
+ ```
50
+
51
+ This command prints all methods provided for the class.
52
+
53
+ ### ruby-signature method [--singleton|--instance] CLASS METHOD
54
+
55
+ ```
56
+ $ ruby-signature method ::Integer '+' # 1+2
57
+ $ ruby-signature method --singleton ::Object tap # Object.tap { ... }
58
+ ```
59
+
60
+ This command prints type and properties of the method.
61
+
62
+ ### Options
63
+
64
+ It accepts two global options, `-r` and `-I`.
65
+
66
+ `-r` is for libraries. You can specify the names of libraries.
67
+
68
+ ```
69
+ $ ruby-signature -r set list
70
+ ```
71
+
72
+ `-I` is for application signatures. You can specify the name of directory.
73
+
74
+ ```
75
+ $ ruby-signature -I sig list
76
+ ```
77
+
78
+ ## Guides
79
+
80
+ - [Standard library signature contribution guide](docs/CONTRIBUTING.md)
81
+ - [Writing signatures guide](docs/sigs.md)
82
+ - [Stdlib signatures guide](docs/stdlib.md)
83
+ - [Syntax](docs/syntax.md)
84
+
85
+ ## Development
86
+
87
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
88
+
89
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
90
+
91
+ ## Contributing
92
+
93
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/ruby-signature.
@@ -0,0 +1,66 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"].reject do |path|
8
+ path =~ %r{test/stdlib/}
9
+ end
10
+ end
11
+
12
+ task :default => [:test, :stdlib_test, :rubocop, :validate]
13
+
14
+ task :validate do
15
+ sh "rbs validate"
16
+ end
17
+
18
+ task :stdlib_test do
19
+ FileList["test/stdlib/*_test.rb"].each do |test|
20
+ sh "ruby bin/test_runner.rb #{test}"
21
+ end
22
+ end
23
+
24
+ task :rubocop do
25
+ sh "rubocop --parallel"
26
+ end
27
+
28
+ rule ".rb" => ".y" do |t|
29
+ sh "racc -v -o #{t.name} #{t.source}"
30
+ end
31
+
32
+ task :parser => "lib/ruby/signature/parser.rb"
33
+ task :test => :parser
34
+ task :stdlib_test => :parser
35
+ task :build => :parser
36
+
37
+ namespace :generate do
38
+ task :stdlib_test, [:class] do |_task, args|
39
+ klass = args.fetch(:class) do
40
+ raise "Class name is necessary. e.g. rake 'generate:stdlib_test[String]'"
41
+ end
42
+
43
+ path = Pathname("test/stdlib/#{klass}_test.rb")
44
+ raise "#{path} already exists!" if path.exist?
45
+
46
+ path.write <<~RUBY
47
+ require_relative "test_helper"
48
+
49
+ class #{klass}Test < StdlibTest
50
+ target #{klass}
51
+ # library "pathname", "set", "securerandom" # Declare library signatures to load
52
+ using hook.refinement
53
+
54
+ # def test_method_name
55
+ # # Call the method
56
+ # method_name(arg)
57
+ # method_name(arg, arg2)
58
+ # end
59
+ end
60
+ RUBY
61
+
62
+ puts "Created: #{path}"
63
+ end
64
+ end
65
+
66
+ CLEAN.include("lib/ruby/signature/parser.rb")