typeprof 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +1 -2
- data/Gemfile.lock +1 -1
- data/README.md +6 -0
- data/lib/typeprof/analyzer.rb +67 -28
- data/lib/typeprof/arguments.rb +27 -19
- data/lib/typeprof/block.rb +5 -2
- data/lib/typeprof/builtin.rb +8 -2
- data/lib/typeprof/container-type.rb +104 -97
- data/lib/typeprof/import.rb +16 -8
- data/lib/typeprof/method.rb +70 -12
- data/lib/typeprof/type.rb +103 -88
- data/lib/typeprof/version.rb +1 -1
- data/smoke/arguments2.rb +1 -1
- data/smoke/block-kwarg.rb +1 -1
- data/smoke/block10.rb +1 -1
- data/smoke/hash-fetch.rb +3 -3
- data/smoke/hash-merge-bang.rb +11 -0
- data/smoke/hash1.rb +1 -1
- data/smoke/hash3.rb +1 -1
- data/smoke/hash4.rb +1 -1
- data/smoke/ivar2.rb +1 -1
- data/smoke/keyword4.rb +1 -1
- data/smoke/kwsplat1.rb +1 -1
- data/smoke/kwsplat2.rb +1 -1
- data/smoke/pattern-match1.rb +23 -0
- data/smoke/pattern-match2.rb +15 -0
- data/smoke/rbs-tyvar3.rb +11 -19
- data/smoke/rbs-tyvar3.rbs +4 -3
- data/smoke/rbs-tyvar4.rb +36 -0
- data/smoke/rbs-tyvar5.rb +12 -0
- data/smoke/rbs-tyvar5.rbs +8 -0
- data/smoke/uninitialize-var.rb +12 -0
- metadata +9 -2
data/lib/typeprof/version.rb
CHANGED
data/smoke/arguments2.rb
CHANGED
data/smoke/block-kwarg.rb
CHANGED
@@ -46,7 +46,7 @@ class Object
|
|
46
46
|
def f3 : { -> nil } -> nil
|
47
47
|
def log3 : (Integer | String) -> nil
|
48
48
|
def f4 : { -> nil } -> nil
|
49
|
-
def log4 : ({:
|
49
|
+
def log4 : ({k: Integer}) -> nil
|
50
50
|
def f5 : { -> nil } -> untyped
|
51
51
|
def f6 : { -> nil } -> untyped
|
52
52
|
end
|
data/smoke/block10.rb
CHANGED
data/smoke/hash-fetch.rb
CHANGED
@@ -21,7 +21,7 @@ baz(h)
|
|
21
21
|
__END__
|
22
22
|
# Classes
|
23
23
|
class Object
|
24
|
-
def foo : ({:
|
25
|
-
def bar : ({:
|
26
|
-
def baz : ({:
|
24
|
+
def foo : ({a: :A, b: :B}) -> (:A | :B)
|
25
|
+
def bar : ({a: :A, b: :B}) -> (:A | :B | :C)
|
26
|
+
def baz : ({a: :A, b: :B}) -> ([:A | :B | :C, (:a | :b)?])
|
27
27
|
end
|
data/smoke/hash1.rb
CHANGED
data/smoke/hash3.rb
CHANGED
data/smoke/hash4.rb
CHANGED
data/smoke/ivar2.rb
CHANGED
data/smoke/keyword4.rb
CHANGED
data/smoke/kwsplat1.rb
CHANGED
@@ -37,6 +37,6 @@ smoke/kwsplat1.rb:30: [error] undefined method: Object#any
|
|
37
37
|
class Object
|
38
38
|
def foo : (k: Integer) -> nil
|
39
39
|
def bar : (int: Integer, str: String) -> nil
|
40
|
-
def baz : (**{:
|
40
|
+
def baz : (**{int: Integer, str: String}) -> nil
|
41
41
|
def qux : (**{untyped=>untyped}) -> nil
|
42
42
|
end
|
data/smoke/kwsplat2.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
# RUBY_VERSION >= 3.0
|
2
|
+
|
3
|
+
def foo
|
4
|
+
case [:a, :b, :c]
|
5
|
+
in [a, b, :c]
|
6
|
+
# Due to very subtle detail of bytecode, the variables "a" and "b" could be nil
|
7
|
+
return a, b
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
foo
|
12
|
+
|
13
|
+
__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
|
+
# Classes
|
21
|
+
class Object
|
22
|
+
def foo : -> ([:a | untyped, :b | untyped])
|
23
|
+
end
|
data/smoke/rbs-tyvar3.rb
CHANGED
@@ -1,25 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
end
|
5
|
-
|
6
|
-
def set
|
7
|
-
@foo.set("42")
|
8
|
-
end
|
9
|
-
|
10
|
-
def get
|
11
|
-
@foo.get
|
12
|
-
end
|
1
|
+
def foo
|
2
|
+
cell = Cell.new(42)
|
3
|
+
cell.map {|s| (s + 1).to_s }
|
13
4
|
end
|
14
5
|
|
15
|
-
|
16
|
-
|
6
|
+
def bar
|
7
|
+
cell = Cell.new(42)
|
8
|
+
cell.map! {|s| (s + 1).to_s }
|
9
|
+
cell
|
10
|
+
end
|
17
11
|
|
18
12
|
__END__
|
19
13
|
# Classes
|
20
|
-
class
|
21
|
-
|
22
|
-
def
|
23
|
-
def set : -> void
|
24
|
-
def get : -> String
|
14
|
+
class Object
|
15
|
+
def foo : -> Cell[String]
|
16
|
+
def bar : -> (Cell[Integer | String])
|
25
17
|
end
|
data/smoke/rbs-tyvar3.rbs
CHANGED
data/smoke/rbs-tyvar4.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# This code is created by simplifying matrix.rb.
|
2
|
+
# The issue occurs when `Array.new` creates a cell-type container,
|
3
|
+
# so this test will be obsolete, but keep it just for case of regression.
|
4
|
+
#
|
5
|
+
# https://github.com/ruby/typeprof/issues/14
|
6
|
+
|
7
|
+
class Foo
|
8
|
+
def initialize(ivar)
|
9
|
+
@ivar = ivar
|
10
|
+
end
|
11
|
+
|
12
|
+
def foo(n)
|
13
|
+
@ivar.each_with_index { }
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
Foo.new([])
|
19
|
+
|
20
|
+
rows = Array.new(1) do |i|
|
21
|
+
Array.new(1) do |j|
|
22
|
+
"str"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
obj = Foo.new(rows)
|
26
|
+
|
27
|
+
obj.foo(:a)
|
28
|
+
obj.foo(:b)
|
29
|
+
|
30
|
+
__END__
|
31
|
+
# Classes
|
32
|
+
class Foo
|
33
|
+
@ivar : Array[Array[String]]
|
34
|
+
def initialize : (Array[Array[String]]) -> Array[Array[String]]
|
35
|
+
def foo : (:a | :b) -> nil
|
36
|
+
end
|
data/smoke/rbs-tyvar5.rb
ADDED
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.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yusuke Endoh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbs
|
@@ -179,6 +179,7 @@ files:
|
|
179
179
|
- smoke/gvar2.rb
|
180
180
|
- smoke/gvar2.rbs
|
181
181
|
- smoke/hash-fetch.rb
|
182
|
+
- smoke/hash-merge-bang.rb
|
182
183
|
- smoke/hash1.rb
|
183
184
|
- smoke/hash2.rb
|
184
185
|
- smoke/hash3.rb
|
@@ -230,6 +231,8 @@ files:
|
|
230
231
|
- smoke/parameterizedd-self.rb
|
231
232
|
- smoke/pathname1.rb
|
232
233
|
- smoke/pathname2.rb
|
234
|
+
- smoke/pattern-match1.rb
|
235
|
+
- smoke/pattern-match2.rb
|
233
236
|
- smoke/printf.rb
|
234
237
|
- smoke/proc.rb
|
235
238
|
- smoke/proc2.rb
|
@@ -258,6 +261,9 @@ files:
|
|
258
261
|
- smoke/rbs-tyvar2.rbs
|
259
262
|
- smoke/rbs-tyvar3.rb
|
260
263
|
- smoke/rbs-tyvar3.rbs
|
264
|
+
- smoke/rbs-tyvar4.rb
|
265
|
+
- smoke/rbs-tyvar5.rb
|
266
|
+
- smoke/rbs-tyvar5.rbs
|
261
267
|
- smoke/rbs-vars.rb
|
262
268
|
- smoke/rbs-vars.rbs
|
263
269
|
- smoke/redo1.rb
|
@@ -293,6 +299,7 @@ files:
|
|
293
299
|
- smoke/two-map.rb
|
294
300
|
- smoke/type_var.rb
|
295
301
|
- smoke/typed_method.rb
|
302
|
+
- smoke/uninitialize-var.rb
|
296
303
|
- smoke/union-recv.rb
|
297
304
|
- smoke/user-demo.rb
|
298
305
|
- smoke/wrong-extend.rb
|