typeprof 0.14.1 → 0.15.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +5 -5
  3. data/lib/typeprof/analyzer.rb +154 -85
  4. data/lib/typeprof/builtin.rb +22 -12
  5. data/lib/typeprof/cli.rb +1 -0
  6. data/lib/typeprof/config.rb +2 -1
  7. data/lib/typeprof/container-type.rb +7 -1
  8. data/lib/typeprof/export.rb +9 -5
  9. data/lib/typeprof/import.rb +60 -21
  10. data/lib/typeprof/iseq.rb +303 -201
  11. data/lib/typeprof/method.rb +2 -2
  12. data/lib/typeprof/type.rb +97 -47
  13. data/lib/typeprof/version.rb +1 -1
  14. data/smoke/alias2.rb +1 -1
  15. data/smoke/array15.rb +1 -1
  16. data/smoke/array3.rb +1 -1
  17. data/smoke/array6.rb +2 -2
  18. data/smoke/array8.rb +1 -1
  19. data/smoke/attr-module.rb +1 -4
  20. data/smoke/attr-vis.rb +1 -1
  21. data/smoke/attr.rb +1 -1
  22. data/smoke/block-args2.rb +3 -3
  23. data/smoke/block-args3.rb +4 -4
  24. data/smoke/break2.rb +1 -1
  25. data/smoke/gvar2.rb +0 -3
  26. data/smoke/hash-bot.rb +1 -1
  27. data/smoke/hash4.rb +1 -1
  28. data/smoke/huge_union.rb +86 -0
  29. data/smoke/identifier_keywords.rb +17 -0
  30. data/smoke/initialize.rb +1 -1
  31. data/smoke/ivar2.rb +1 -1
  32. data/smoke/ivar3.rb +1 -1
  33. data/smoke/kwrest.rb +2 -2
  34. data/smoke/kwrest.rbs +1 -1
  35. data/smoke/method_missing.rb +1 -1
  36. data/smoke/next2.rb +1 -1
  37. data/smoke/noname.rb +9 -0
  38. data/smoke/or_raise.rb +18 -0
  39. data/smoke/parameterizedd-self.rb +2 -2
  40. data/smoke/pattern-match1.rb +1 -6
  41. data/smoke/proc6.rb +13 -0
  42. data/smoke/proc7.rb +32 -0
  43. data/smoke/rbs-tyvar4.rb +1 -1
  44. data/smoke/rbs-vars.rb +0 -3
  45. data/smoke/require1.rb +13 -0
  46. data/smoke/require2.rb +13 -0
  47. data/smoke/struct5.rb +1 -1
  48. data/smoke/struct6.rb +1 -1
  49. data/smoke/struct7.rb +1 -1
  50. data/smoke/super3.rb +1 -1
  51. data/smoke/symbol-proc-attr.rb +1 -1
  52. data/smoke/symbol-proc-attr2.rb +1 -1
  53. data/testbed/ao.rb +1 -1
  54. data/typeprof.gemspec +1 -1
  55. metadata +12 -4
@@ -0,0 +1,17 @@
1
+ def type(type)
2
+ end
3
+
4
+ def out(*out)
5
+ end
6
+
7
+ def untyped(untyped:)
8
+ end
9
+
10
+ __END__
11
+ # Classes
12
+ class Object
13
+ private
14
+ def type: (untyped `type`) -> nil
15
+ def out: (*untyped `out`) -> nil
16
+ def untyped: (untyped: untyped) -> nil
17
+ end
data/smoke/initialize.rb CHANGED
@@ -24,5 +24,5 @@ class A
24
24
  @str: String
25
25
  @val: (Integer | String)?
26
26
 
27
- def initialize: ((Integer | String)? x) -> ((Integer | String)?)
27
+ def initialize: ((Integer | String)? x) -> void
28
28
  end
data/smoke/ivar2.rb CHANGED
@@ -23,7 +23,7 @@ Foo.new.set
23
23
  __END__
24
24
  # Classes
25
25
  class Foo
26
- def initialize: -> Hash[bot, bot]
26
+ def initialize: -> void
27
27
  def set: -> :sym
28
28
  attr_reader array: Array[:sym | Integer | String]
29
29
  attr_reader hash: {a: Integer, b: String, c: :sym}
data/smoke/ivar3.rb CHANGED
@@ -13,5 +13,5 @@ smoke/ivar3.rb:3: [warning] inconsistent assignment to RBS-declared variable
13
13
  class Foo
14
14
  @bar: String
15
15
 
16
- def initialize: -> String
16
+ def initialize: -> void
17
17
  end
data/smoke/kwrest.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  class Foo
2
2
  def foo(**r)
3
- @r = r[42]
3
+ @r = r["foo".to_sym][42]
4
4
  end
5
5
  end
6
6
 
@@ -9,5 +9,5 @@ __END__
9
9
  class Foo
10
10
  @r: Integer
11
11
 
12
- # def foo: (**Hash[Integer, Integer]) -> void
12
+ # def foo: (**Integer) -> void
13
13
  end
data/smoke/kwrest.rbs CHANGED
@@ -1,3 +1,3 @@
1
1
  class Foo
2
- def foo: (**Hash[Integer, Integer]) -> void
2
+ def foo: (**Integer) -> void
3
3
  end
@@ -24,6 +24,6 @@ end
24
24
  class C
25
25
  @target: D
26
26
 
27
- def initialize: (D x) -> D
27
+ def initialize: (D x) -> void
28
28
  def method_missing: (:foo m, *:X | :Y | :Z args) -> nil
29
29
  end
data/smoke/next2.rb CHANGED
@@ -13,5 +13,5 @@ __END__
13
13
  # Classes
14
14
  class Object
15
15
  private
16
- def foo: { -> (Integer | String) } -> (Integer | String)
16
+ def foo: { -> Integer } -> Integer
17
17
  end
data/smoke/noname.rb ADDED
@@ -0,0 +1,9 @@
1
+ def foo(*)
2
+ end
3
+
4
+ __END__
5
+ # Classes
6
+ class Object
7
+ private
8
+ def foo: (*untyped noname_2) -> nil
9
+ end
data/smoke/or_raise.rb ADDED
@@ -0,0 +1,18 @@
1
+ def foo
2
+ if rand < 0.5
3
+ 1
4
+ end
5
+ end
6
+
7
+ def bar
8
+ x = foo or raise("nil")
9
+ x.times { }
10
+ end
11
+
12
+ __END__
13
+ # Classes
14
+ class Object
15
+ private
16
+ def foo: -> Integer?
17
+ def bar: -> Integer
18
+ end
@@ -13,8 +13,8 @@ bar([])
13
13
  __END__
14
14
  # Classes
15
15
  class Object
16
- def foo: -> Array[bot]
16
+ def foo: -> Array[untyped]
17
17
 
18
18
  private
19
- def bar: (Array[bot] ary) -> Array[bot]
19
+ def bar: (Array[untyped] ary) -> Array[untyped]
20
20
  end
@@ -1,4 +1,5 @@
1
1
  # RUBY_VERSION >= 3.0
2
+ # NO_SHOW_ERRORS
2
3
 
3
4
  def foo
4
5
  case [:a, :b, :c]
@@ -11,12 +12,6 @@ end
11
12
  foo
12
13
 
13
14
  __END__
14
- # Errors
15
- smoke/pattern-match1.rb:5: [error] undefined method: nil#length
16
- smoke/pattern-match1.rb:5: [error] undefined method: nil#[]
17
- smoke/pattern-match1.rb:5: [error] undefined method: nil#[]
18
- smoke/pattern-match1.rb:5: [error] undefined method: nil#[]
19
-
20
15
  # Classes
21
16
  class Object
22
17
  private
data/smoke/proc6.rb ADDED
@@ -0,0 +1,13 @@
1
+ # a test for a recursive proc that receives (or returns) itself
2
+ def foo
3
+ f = -> x { x }
4
+ f[f]
5
+ f
6
+ end
7
+
8
+ __END__
9
+ # Classes
10
+ class Object
11
+ private
12
+ def foo: -> ^(untyped) -> untyped
13
+ end
data/smoke/proc7.rb ADDED
@@ -0,0 +1,32 @@
1
+ class Foo
2
+ def id(&blk)
3
+ blk
4
+ end
5
+
6
+ def check(v)
7
+ rand < 0.5 ? v : [v]
8
+ end
9
+
10
+ def foo
11
+ check(id {}).call # cause "undefined method: [^-> nil?]#call"
12
+ end
13
+
14
+ def foo1
15
+ id { }
16
+ end
17
+ end
18
+
19
+ __END__
20
+ # Errors
21
+ smoke/proc7.rb:11: [error] undefined method: nil#call
22
+ smoke/proc7.rb:11: [error] undefined method: [(^(unknown) -> bot | untyped)?]#call
23
+ smoke/proc7.rb:11: [error] undefined method: nil#call
24
+ smoke/proc7.rb:11: [error] undefined method: [(^-> nil | untyped)?]#call
25
+
26
+ # Classes
27
+ class Foo
28
+ def id: ?{ -> nil } -> ^-> nil?
29
+ def check: ((^-> nil | untyped)? v) -> (([(^-> nil | untyped)?] | ^-> nil | untyped)?)
30
+ def foo: -> untyped?
31
+ def foo1: -> ^-> nil?
32
+ end
data/smoke/rbs-tyvar4.rb CHANGED
@@ -32,6 +32,6 @@ __END__
32
32
  class Foo
33
33
  @ivar: Array[Array[String]]
34
34
 
35
- def initialize: (Array[Array[String]] ivar) -> Array[Array[String]]
35
+ def initialize: (Array[Array[String]] ivar) -> void
36
36
  def foo: (:a | :b n) -> nil
37
37
  end
data/smoke/rbs-vars.rb CHANGED
@@ -21,9 +21,6 @@ class Foo
21
21
  end
22
22
 
23
23
  __END__
24
- # Global variables
25
- #$gvar: :gvar_example
26
-
27
24
  # Classes
28
25
  class Object
29
26
  private
data/smoke/require1.rb ADDED
@@ -0,0 +1,13 @@
1
+ require_relative "require2"
2
+
3
+ class Foo
4
+ def foo
5
+ end
6
+ end
7
+
8
+ __END__
9
+ # Classes
10
+ class Foo
11
+ def bar: -> nil
12
+ def foo: -> nil
13
+ end
data/smoke/require2.rb ADDED
@@ -0,0 +1,13 @@
1
+ require_relative "require1"
2
+
3
+ class Foo
4
+ def bar
5
+ end
6
+ end
7
+
8
+ __END__
9
+ # Classes
10
+ class Foo
11
+ def foo: -> nil
12
+ def bar: -> nil
13
+ end
data/smoke/struct5.rb CHANGED
@@ -12,5 +12,5 @@ __END__
12
12
  # Classes
13
13
  class Foo < Struct[untyped]
14
14
  attr_accessor foo(): String
15
- def initialize: (Integer foo) -> Foo
15
+ def initialize: (Integer foo) -> void
16
16
  end
data/smoke/struct6.rb CHANGED
@@ -11,5 +11,5 @@ class AnonymousStruct_generated_1 < Struct[untyped]
11
11
  end
12
12
 
13
13
  class Foo < AnonymousStruct_generated_1
14
- def initialize: (untyped foo) -> Foo
14
+ def initialize: (untyped foo) -> void
15
15
  end
data/smoke/struct7.rb CHANGED
@@ -13,5 +13,5 @@ end
13
13
  __END__
14
14
  # Classes
15
15
  class Foo < Struct[untyped]
16
- def initialize: -> Foo
16
+ def initialize: -> void
17
17
  end
data/smoke/super3.rb CHANGED
@@ -16,5 +16,5 @@ class Foo
16
16
  @a: Integer
17
17
 
18
18
  def self.new: (Integer a) -> Foo
19
- def initialize: (Integer a) -> Integer
19
+ def initialize: (Integer a) -> void
20
20
  end
@@ -18,5 +18,5 @@ end
18
18
 
19
19
  class Foo
20
20
  attr_reader foo: Integer | untyped
21
- def initialize: (Integer | untyped foo) -> (Integer | untyped)
21
+ def initialize: (Integer | untyped foo) -> void
22
22
  end
@@ -11,5 +11,5 @@ __END__
11
11
  # Classes
12
12
  class Foo
13
13
  attr_reader foo: [Integer]
14
- def initialize: -> [Integer]
14
+ def initialize: -> void
15
15
  end
data/testbed/ao.rb CHANGED
@@ -291,7 +291,7 @@ end
291
291
 
292
292
  top
293
293
 
294
- if _dummy = false
294
+ if $0 == __FILE__
295
295
  v = Vec.new(0.0, 0.0, 0.0)
296
296
  v.vadd(v)
297
297
  end
data/typeprof.gemspec CHANGED
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
- spec.add_runtime_dependency "rbs", ">= 1.2.0"
33
+ spec.add_runtime_dependency "rbs", ">= 1.3.1"
34
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typeprof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1
4
+ version: 0.15.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke Endoh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-18 00:00:00.000000000 Z
11
+ date: 2021-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbs
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.0
19
+ version: 1.3.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.0
26
+ version: 1.3.1
27
27
  description: |
28
28
  TypeProf performs a type analysis of non-annotated Ruby code.
29
29
 
@@ -216,6 +216,8 @@ files:
216
216
  - smoke/hash3.rb
217
217
  - smoke/hash4.rb
218
218
  - smoke/hash5.rb
219
+ - smoke/huge_union.rb
220
+ - smoke/identifier_keywords.rb
219
221
  - smoke/included.rb
220
222
  - smoke/inheritance.rb
221
223
  - smoke/inheritance2.rb
@@ -267,6 +269,7 @@ files:
267
269
  - smoke/multiple-superclass.rb
268
270
  - smoke/next1.rb
269
271
  - smoke/next2.rb
272
+ - smoke/noname.rb
270
273
  - smoke/object-send1.rb
271
274
  - smoke/object-send2.rb
272
275
  - smoke/object-send3.rb
@@ -274,6 +277,7 @@ files:
274
277
  - smoke/optional1.rb
275
278
  - smoke/optional2.rb
276
279
  - smoke/optional3.rb
280
+ - smoke/or_raise.rb
277
281
  - smoke/parameterizedd-self.rb
278
282
  - smoke/parameterizedd-self2.rb
279
283
  - smoke/pathname1.rb
@@ -290,6 +294,8 @@ files:
290
294
  - smoke/proc3.rb
291
295
  - smoke/proc4.rb
292
296
  - smoke/proc5.rb
297
+ - smoke/proc6.rb
298
+ - smoke/proc7.rb
293
299
  - smoke/public.rb
294
300
  - smoke/range.rb
295
301
  - smoke/rbs-alias.rb
@@ -332,6 +338,8 @@ files:
332
338
  - smoke/redo1.rb
333
339
  - smoke/redo2.rb
334
340
  - smoke/req-keyword.rb
341
+ - smoke/require1.rb
342
+ - smoke/require2.rb
335
343
  - smoke/rescue1.rb
336
344
  - smoke/rescue2.rb
337
345
  - smoke/rescue3.rb