steep 0.1.0.pre2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +1 -1
- data/README.md +146 -33
- data/bin/smoke_runner.rb +43 -10
- data/lib/steep/ast/annotation/collection.rb +93 -0
- data/lib/steep/ast/annotation.rb +131 -0
- data/lib/steep/ast/buffer.rb +47 -0
- data/lib/steep/ast/location.rb +82 -0
- data/lib/steep/ast/method_type.rb +116 -0
- data/lib/steep/ast/signature/class.rb +33 -0
- data/lib/steep/ast/signature/const.rb +17 -0
- data/lib/steep/ast/signature/env.rb +123 -0
- data/lib/steep/ast/signature/extension.rb +21 -0
- data/lib/steep/ast/signature/gvar.rb +17 -0
- data/lib/steep/ast/signature/interface.rb +31 -0
- data/lib/steep/ast/signature/members.rb +71 -0
- data/lib/steep/ast/signature/module.rb +21 -0
- data/lib/steep/ast/type_params.rb +13 -0
- data/lib/steep/ast/types/any.rb +39 -0
- data/lib/steep/ast/types/bot.rb +39 -0
- data/lib/steep/ast/types/class.rb +35 -0
- data/lib/steep/ast/types/helper.rb +21 -0
- data/lib/steep/ast/types/instance.rb +39 -0
- data/lib/steep/ast/types/intersection.rb +74 -0
- data/lib/steep/ast/types/name.rb +124 -0
- data/lib/steep/ast/types/self.rb +39 -0
- data/lib/steep/ast/types/top.rb +39 -0
- data/lib/steep/ast/types/union.rb +74 -0
- data/lib/steep/ast/types/var.rb +57 -0
- data/lib/steep/ast/types/void.rb +35 -0
- data/lib/steep/cli.rb +28 -1
- data/lib/steep/drivers/annotations.rb +32 -0
- data/lib/steep/drivers/check.rb +53 -77
- data/lib/steep/drivers/scaffold.rb +303 -0
- data/lib/steep/drivers/utils/each_signature.rb +66 -0
- data/lib/steep/drivers/utils/validator.rb +115 -0
- data/lib/steep/drivers/validate.rb +39 -0
- data/lib/steep/errors.rb +291 -19
- data/lib/steep/interface/abstract.rb +44 -0
- data/lib/steep/interface/builder.rb +470 -0
- data/lib/steep/interface/instantiated.rb +126 -0
- data/lib/steep/interface/ivar_chain.rb +26 -0
- data/lib/steep/interface/method.rb +60 -0
- data/lib/steep/{interface.rb → interface/method_type.rb} +111 -100
- data/lib/steep/interface/substitution.rb +65 -0
- data/lib/steep/module_name.rb +116 -0
- data/lib/steep/parser.rb +1314 -814
- data/lib/steep/parser.y +536 -175
- data/lib/steep/source.rb +220 -25
- data/lib/steep/subtyping/check.rb +673 -0
- data/lib/steep/subtyping/constraints.rb +275 -0
- data/lib/steep/subtyping/relation.rb +41 -0
- data/lib/steep/subtyping/result.rb +126 -0
- data/lib/steep/subtyping/trace.rb +48 -0
- data/lib/steep/subtyping/variable_occurrence.rb +49 -0
- data/lib/steep/subtyping/variable_variance.rb +69 -0
- data/lib/steep/type_construction.rb +1630 -524
- data/lib/steep/type_inference/block_params.rb +100 -0
- data/lib/steep/type_inference/constant_env.rb +55 -0
- data/lib/steep/type_inference/send_args.rb +222 -0
- data/lib/steep/type_inference/type_env.rb +226 -0
- data/lib/steep/type_name.rb +27 -7
- data/lib/steep/typing.rb +4 -0
- data/lib/steep/version.rb +1 -1
- data/lib/steep.rb +71 -16
- data/smoke/and/a.rb +4 -2
- data/smoke/array/a.rb +4 -5
- data/smoke/array/b.rb +4 -4
- data/smoke/block/a.rb +2 -2
- data/smoke/block/a.rbi +2 -0
- data/smoke/block/b.rb +15 -0
- data/smoke/case/a.rb +3 -3
- data/smoke/class/a.rb +3 -3
- data/smoke/class/b.rb +0 -2
- data/smoke/class/d.rb +2 -2
- data/smoke/class/e.rb +1 -1
- data/smoke/class/f.rb +2 -2
- data/smoke/class/g.rb +8 -0
- data/smoke/const/a.rb +3 -3
- data/smoke/dstr/a.rb +1 -1
- data/smoke/ensure/a.rb +22 -0
- data/smoke/enumerator/a.rb +6 -6
- data/smoke/enumerator/b.rb +22 -0
- data/smoke/extension/a.rb +2 -2
- data/smoke/extension/b.rb +3 -3
- data/smoke/extension/c.rb +1 -1
- data/smoke/hello/hello.rb +2 -2
- data/smoke/if/a.rb +4 -2
- data/smoke/kwbegin/a.rb +8 -0
- data/smoke/literal/a.rb +5 -5
- data/smoke/method/a.rb +5 -5
- data/smoke/method/a.rbi +4 -0
- data/smoke/method/b.rb +29 -0
- data/smoke/module/a.rb +3 -3
- data/smoke/module/a.rbi +9 -0
- data/smoke/module/b.rb +2 -2
- data/smoke/module/c.rb +1 -1
- data/smoke/module/d.rb +5 -0
- data/smoke/module/e.rb +13 -0
- data/smoke/module/f.rb +13 -0
- data/smoke/rescue/a.rb +62 -0
- data/smoke/super/a.rb +2 -2
- data/smoke/type_case/a.rb +35 -0
- data/smoke/yield/a.rb +2 -2
- data/stdlib/builtin.rbi +463 -24
- data/steep.gemspec +3 -2
- metadata +91 -29
- data/lib/steep/annotation.rb +0 -223
- data/lib/steep/signature/class.rb +0 -450
- data/lib/steep/signature/extension.rb +0 -51
- data/lib/steep/signature/interface.rb +0 -49
- data/lib/steep/types/any.rb +0 -31
- data/lib/steep/types/class.rb +0 -27
- data/lib/steep/types/instance.rb +0 -27
- data/lib/steep/types/merge.rb +0 -32
- data/lib/steep/types/name.rb +0 -57
- data/lib/steep/types/union.rb +0 -42
- data/lib/steep/types/var.rb +0 -38
- data/lib/steep/types.rb +0 -4
data/lib/steep.rb
CHANGED
@@ -1,33 +1,88 @@
|
|
1
1
|
require "steep/version"
|
2
2
|
|
3
3
|
require "pathname"
|
4
|
-
require "parser/current"
|
5
4
|
require "ast_utils"
|
5
|
+
require "active_support/core_ext/object/try"
|
6
|
+
require "logger"
|
7
|
+
require "active_support/tagged_logging"
|
8
|
+
require "rainbow"
|
9
|
+
|
10
|
+
require "steep/module_name"
|
11
|
+
require "steep/ast/location"
|
12
|
+
require "steep/ast/types/helper"
|
13
|
+
require "steep/ast/types/any"
|
14
|
+
require "steep/ast/types/instance"
|
15
|
+
require "steep/ast/types/class"
|
16
|
+
require "steep/ast/types/union"
|
17
|
+
require "steep/ast/types/var"
|
18
|
+
require "steep/ast/types/name"
|
19
|
+
require "steep/ast/types/self"
|
20
|
+
require "steep/ast/types/intersection"
|
21
|
+
require "steep/ast/types/void"
|
22
|
+
require "steep/ast/types/bot"
|
23
|
+
require "steep/ast/types/top"
|
24
|
+
require "steep/ast/method_type"
|
25
|
+
require "steep/ast/type_params"
|
26
|
+
require "steep/ast/signature/class"
|
27
|
+
require "steep/ast/signature/module"
|
28
|
+
require "steep/ast/signature/members"
|
29
|
+
require "steep/ast/signature/extension"
|
30
|
+
require "steep/ast/signature/interface"
|
31
|
+
require "steep/ast/signature/env"
|
32
|
+
require "steep/ast/signature/const"
|
33
|
+
require "steep/ast/signature/gvar"
|
34
|
+
require "steep/ast/annotation"
|
35
|
+
require "steep/ast/annotation/collection"
|
36
|
+
require "steep/ast/buffer"
|
6
37
|
|
7
|
-
require "steep/types"
|
8
38
|
require "steep/type_name"
|
9
|
-
|
10
|
-
require "steep/
|
11
|
-
require "steep/
|
39
|
+
|
40
|
+
require "steep/interface/method_type"
|
41
|
+
require "steep/interface/method"
|
42
|
+
require "steep/interface/builder"
|
43
|
+
require "steep/interface/substitution"
|
44
|
+
require "steep/interface/abstract"
|
45
|
+
require "steep/interface/instantiated"
|
46
|
+
require "steep/interface/ivar_chain"
|
47
|
+
|
48
|
+
require "steep/subtyping/check"
|
49
|
+
require "steep/subtyping/result"
|
50
|
+
require "steep/subtyping/relation"
|
51
|
+
require "steep/subtyping/trace"
|
52
|
+
require "steep/subtyping/constraints"
|
53
|
+
require "steep/subtyping/variable_variance"
|
54
|
+
require "steep/subtyping/variable_occurrence"
|
55
|
+
|
12
56
|
require "steep/signature/errors"
|
13
|
-
require "steep/signature/extension"
|
14
|
-
require "steep/types/any"
|
15
|
-
require "steep/types/name"
|
16
|
-
require "steep/types/var"
|
17
|
-
require "steep/types/union"
|
18
|
-
require "steep/types/class"
|
19
|
-
require "steep/types/instance"
|
20
|
-
require "steep/types/merge"
|
21
|
-
require "steep/type_assignability"
|
22
57
|
require "steep/parser"
|
23
|
-
require "steep/annotation"
|
24
58
|
require "steep/source"
|
25
59
|
require "steep/typing"
|
26
60
|
require "steep/errors"
|
27
61
|
require "steep/type_construction"
|
62
|
+
require "steep/type_inference/send_args"
|
63
|
+
require "steep/type_inference/block_params"
|
64
|
+
require "steep/type_inference/constant_env"
|
65
|
+
require "steep/type_inference/type_env"
|
28
66
|
|
67
|
+
require "steep/drivers/utils/validator"
|
68
|
+
require "steep/drivers/utils/each_signature"
|
29
69
|
require "steep/drivers/check"
|
70
|
+
require "steep/drivers/validate"
|
71
|
+
require "steep/drivers/annotations"
|
72
|
+
require "steep/drivers/scaffold"
|
73
|
+
|
74
|
+
if ENV["NO_COLOR"]
|
75
|
+
Rainbow.enabled = false
|
76
|
+
end
|
30
77
|
|
31
78
|
module Steep
|
32
|
-
|
79
|
+
def self.logger
|
80
|
+
unless @logger
|
81
|
+
@logger = ActiveSupport::TaggedLogging.new(Logger.new(STDERR))
|
82
|
+
@logger.push_tags "Steep #{VERSION}"
|
83
|
+
@logger.level = Logger::ERROR
|
84
|
+
end
|
85
|
+
|
86
|
+
@logger
|
87
|
+
end
|
33
88
|
end
|
data/smoke/and/a.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# @type var b: String
|
2
|
-
# @type var c: Integer
|
2
|
+
# @type var c: ::Integer
|
3
3
|
|
4
4
|
a = "foo"
|
5
5
|
|
6
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=(::NilClass | ::String)
|
6
7
|
b = a && a.to_str
|
7
8
|
|
8
|
-
# !expects IncompatibleAssignment: lhs_type
|
9
|
+
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=(::NilClass | ::String)
|
9
10
|
c = a && a.to_str
|
11
|
+
|
data/smoke/array/a.rb
CHANGED
@@ -3,20 +3,19 @@
|
|
3
3
|
a = []
|
4
4
|
a[1] = 3
|
5
5
|
|
6
|
-
# !expects ArgumentTypeMismatch:
|
6
|
+
# !expects ArgumentTypeMismatch: receiver=::Array<::Integer>, expected=::Integer, actual=::String
|
7
7
|
a[2] = "foo"
|
8
8
|
|
9
9
|
# @type var i: Integer
|
10
|
-
# @type var s: String
|
11
|
-
|
12
10
|
i = a[0]
|
13
11
|
|
14
|
-
#
|
12
|
+
# @type var s: String
|
13
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
15
14
|
s = a[1]
|
16
15
|
|
17
16
|
|
18
17
|
b = ["a", "b", "c"]
|
19
18
|
|
20
19
|
s = b[0]
|
21
|
-
# !expects IncompatibleAssignment: lhs_type
|
20
|
+
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=::String
|
22
21
|
i = b[1]
|
data/smoke/array/b.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
x = ""
|
2
2
|
y = 1
|
3
3
|
|
4
|
-
# !expects IncompatibleAssignment: lhs_type
|
4
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
5
5
|
x = y
|
6
|
-
# !expects IncompatibleAssignment: lhs_type
|
6
|
+
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=::String
|
7
7
|
y = x
|
8
8
|
|
9
9
|
# @type var a: Array<Integer>
|
10
10
|
# @type var b: Array<String>
|
11
11
|
|
12
12
|
a = []
|
13
|
-
# !expects IncompatibleAssignment: lhs_type
|
13
|
+
# !expects IncompatibleAssignment: lhs_type=::Array<::String>, rhs_type=::Array<::Integer>
|
14
14
|
b = a
|
15
|
-
# !expects IncompatibleAssignment: lhs_type
|
15
|
+
# !expects IncompatibleAssignment: lhs_type=::Array<::Integer>, rhs_type=::Array<::String>
|
16
16
|
a = b
|
data/smoke/block/a.rb
CHANGED
@@ -5,8 +5,8 @@ a = A.new
|
|
5
5
|
# @type var i: Integer
|
6
6
|
# @type var s: String
|
7
7
|
|
8
|
-
# !expects IncompatibleAssignment: lhs_type
|
8
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
9
9
|
s = a.foo
|
10
10
|
|
11
|
-
# !expects IncompatibleAssignment: lhs_type
|
11
|
+
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=::String
|
12
12
|
i = a.foo { nil }
|
data/smoke/block/a.rbi
CHANGED
data/smoke/block/b.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# @type var a: A
|
2
|
+
a = (_ = nil)
|
3
|
+
|
4
|
+
a.bar do |x|
|
5
|
+
# !expects BreakTypeMismatch: expected=::Symbol, actual=::Integer
|
6
|
+
break 3
|
7
|
+
end
|
8
|
+
|
9
|
+
# @type var s: ::String
|
10
|
+
|
11
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=(::Integer | ::Symbol)
|
12
|
+
s = a.bar do |x|
|
13
|
+
# @type break: ::Integer
|
14
|
+
break 3
|
15
|
+
end
|
data/smoke/case/a.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# @type var a: Integer
|
2
2
|
|
3
|
-
# !expects IncompatibleAssignment: lhs_type
|
3
|
+
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=(::Array<::String> | ::Integer | ::NilClass | ::String)
|
4
4
|
a = case 1
|
5
5
|
when 2
|
6
6
|
1
|
@@ -14,7 +14,7 @@ a = case 1
|
|
14
14
|
end
|
15
15
|
|
16
16
|
a = case
|
17
|
-
# !expects ArgumentTypeMismatch:
|
17
|
+
# !expects ArgumentTypeMismatch: receiver=::Integer, expected=::Integer, actual=::String
|
18
18
|
when 1+"a"
|
19
|
-
nil
|
19
|
+
(_ = nil)
|
20
20
|
end
|
data/smoke/class/a.rb
CHANGED
@@ -8,13 +8,13 @@ class A
|
|
8
8
|
end
|
9
9
|
|
10
10
|
# A#bar is defined but the implementation is incompatible.
|
11
|
-
# !expects
|
11
|
+
# !expects MethodArityMismatch: method=bar
|
12
12
|
def bar(y)
|
13
13
|
y
|
14
14
|
end
|
15
15
|
|
16
16
|
# Object#to_s is defined but the implementation is incompatible.
|
17
|
-
# !expects MethodBodyTypeMismatch: method=to_s, expected
|
17
|
+
# !expects MethodBodyTypeMismatch: method=to_s, expected=::String, actual=::Integer
|
18
18
|
def to_s
|
19
19
|
3
|
20
20
|
end
|
@@ -24,7 +24,7 @@ class A
|
|
24
24
|
5
|
25
25
|
end
|
26
26
|
|
27
|
-
# !expects MethodBodyTypeMismatch: method=self.baz, expected
|
27
|
+
# !expects MethodBodyTypeMismatch: method=self.baz, expected=::Integer, actual=::String
|
28
28
|
def self.baz
|
29
29
|
"baz"
|
30
30
|
end
|
data/smoke/class/b.rb
CHANGED
data/smoke/class/d.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
# @type const B: A.class constructor
|
3
3
|
# @type const C: A.class noconstructor
|
4
4
|
|
5
|
-
# !expects NoMethodError: type
|
5
|
+
# !expects NoMethodError: type=::A.class, method=new
|
6
6
|
a = A.new
|
7
7
|
b = B.new
|
8
|
-
# !expects NoMethodError: type
|
8
|
+
# !expects NoMethodError: type=::A.class noconstructor, method=new
|
9
9
|
c = C.new
|
data/smoke/class/e.rb
CHANGED
data/smoke/class/f.rb
CHANGED
data/smoke/class/g.rb
ADDED
data/smoke/const/a.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# @type const A: Integer
|
2
2
|
# @type var x: String
|
3
3
|
|
4
|
-
# !expects IncompatibleAssignment: lhs_type
|
4
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
5
5
|
x = A
|
6
6
|
|
7
7
|
x = B
|
@@ -12,7 +12,7 @@ module X
|
|
12
12
|
def foo
|
13
13
|
# @type var x: String
|
14
14
|
|
15
|
-
# !expects IncompatibleAssignment: lhs_type
|
15
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
16
16
|
x = A
|
17
17
|
|
18
18
|
x = B
|
@@ -22,7 +22,7 @@ end
|
|
22
22
|
|
23
23
|
# @type const Foo::Bar::Baz: Integer
|
24
24
|
|
25
|
-
# !expects IncompatibleAssignment: lhs_type
|
25
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
26
26
|
x = Foo::Bar::Baz
|
27
27
|
|
28
28
|
z = Foo
|
data/smoke/dstr/a.rb
CHANGED
data/smoke/ensure/a.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# @type var a: Integer
|
2
|
+
# @type var b: Integer
|
3
|
+
|
4
|
+
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=::String
|
5
|
+
a = begin
|
6
|
+
'foo'
|
7
|
+
ensure
|
8
|
+
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=::Symbol
|
9
|
+
b = :foo
|
10
|
+
1
|
11
|
+
end
|
12
|
+
|
13
|
+
# @type method foo: (String) -> String
|
14
|
+
|
15
|
+
# !expects MethodBodyTypeMismatch: method=foo, expected=::String, actual=::Integer
|
16
|
+
def foo(a)
|
17
|
+
10
|
18
|
+
ensure
|
19
|
+
# !expects ArgumentTypeMismatch: receiver=::Integer, expected=::Integer, actual=::String
|
20
|
+
1 + '1'
|
21
|
+
a
|
22
|
+
end
|
data/smoke/enumerator/a.rb
CHANGED
@@ -2,18 +2,18 @@
|
|
2
2
|
|
3
3
|
a = [1]
|
4
4
|
|
5
|
-
# !expects IncompatibleAssignment: lhs_type
|
5
|
+
# !expects IncompatibleAssignment: lhs_type=::Hash<::Symbol, ::String>, rhs_type=::String
|
6
6
|
hash = a.each.with_object("") do |x, y|
|
7
|
-
# !expects IncompatibleAssignment: lhs_type
|
7
|
+
# !expects IncompatibleAssignment: lhs_type=::Hash<::Symbol, ::String>, rhs_type=::Integer
|
8
8
|
hash = x
|
9
|
-
# !expects IncompatibleAssignment: lhs_type
|
9
|
+
# !expects IncompatibleAssignment: lhs_type=::Hash<::Symbol, ::String>, rhs_type=::String
|
10
10
|
hash = y
|
11
11
|
end
|
12
12
|
|
13
|
-
# !expects IncompatibleAssignment: lhs_type
|
13
|
+
# !expects IncompatibleAssignment: lhs_type=::Hash<::Symbol, ::String>, rhs_type=::Array<::Integer>
|
14
14
|
hash = a.each.with_index do |x, y|
|
15
|
-
# !expects IncompatibleAssignment: lhs_type
|
15
|
+
# !expects IncompatibleAssignment: lhs_type=::Hash<::Symbol, ::String>, rhs_type=::Integer
|
16
16
|
hash = x
|
17
|
-
# !expects IncompatibleAssignment: lhs_type
|
17
|
+
# !expects IncompatibleAssignment: lhs_type=::Hash<::Symbol, ::String>, rhs_type=::Integer
|
18
18
|
hash = y
|
19
19
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# @type var b: Array<String>
|
2
|
+
# @type var c: Array<Integer>
|
3
|
+
|
4
|
+
a = [1]
|
5
|
+
|
6
|
+
# !expects* UnsatisfiableConstraint:
|
7
|
+
b = a.each.with_object([]) do |i, xs|
|
8
|
+
# @type var xs: String
|
9
|
+
xs << i.to_s
|
10
|
+
end
|
11
|
+
|
12
|
+
# !expects IncompatibleAssignment: lhs_type=::Array<::Integer>, rhs_type=::Array<::String>
|
13
|
+
c = a.each.with_object([]) do |i, xs|
|
14
|
+
# @type var xs: Array<String>
|
15
|
+
xs << i.to_s
|
16
|
+
end
|
17
|
+
|
18
|
+
# @type var d: String
|
19
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Array<any>
|
20
|
+
d = a.each.with_object([]) do |i, xs|
|
21
|
+
xs << i.to_s
|
22
|
+
end
|
data/smoke/extension/a.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# @type var foo: Foo
|
2
2
|
|
3
|
-
foo = nil
|
3
|
+
foo = (_ = nil)
|
4
4
|
|
5
5
|
foo.try do |x|
|
6
6
|
# @type var string: String
|
7
7
|
|
8
|
-
# !expects IncompatibleAssignment: lhs_type
|
8
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Foo
|
9
9
|
string = x
|
10
10
|
end
|
11
11
|
|
data/smoke/extension/b.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# @type var foo: Foo
|
2
|
-
foo = nil
|
2
|
+
foo = (_ = nil)
|
3
3
|
|
4
4
|
# @type var integer: Integer
|
5
5
|
|
6
6
|
# Foo#f returns String because overridden
|
7
|
-
# !expects IncompatibleAssignment: lhs_type
|
7
|
+
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=::String
|
8
8
|
integer = foo.f()
|
9
9
|
|
10
10
|
# String#f returns Object because Object(X)#f is used
|
11
|
-
# !expects IncompatibleAssignment: lhs_type
|
11
|
+
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=::Object
|
12
12
|
integer = "".f()
|
data/smoke/extension/c.rb
CHANGED
data/smoke/hello/hello.rb
CHANGED
data/smoke/if/a.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# @type var a: String
|
2
2
|
|
3
|
-
|
3
|
+
x = y = z = (_ = nil)
|
4
|
+
|
5
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Symbol
|
4
6
|
a = if x
|
5
7
|
:foo
|
6
8
|
end
|
@@ -11,7 +13,7 @@ else
|
|
11
13
|
"baz"
|
12
14
|
end
|
13
15
|
|
14
|
-
# !expects IncompatibleAssignment: lhs_type
|
16
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=(::Integer | ::String)
|
15
17
|
a = if z
|
16
18
|
"foofoo"
|
17
19
|
else
|
data/smoke/kwbegin/a.rb
ADDED
data/smoke/literal/a.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# @type var x: String
|
2
2
|
# @type var y: Integer
|
3
3
|
|
4
|
-
# !expects IncompatibleAssignment: lhs_type
|
4
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
5
5
|
x = 1
|
6
6
|
|
7
|
-
# !expects IncompatibleAssignment: lhs_type
|
7
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Symbol
|
8
8
|
x = :foo
|
9
9
|
|
10
|
-
# !expects IncompatibleAssignment: lhs_type
|
10
|
+
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=::String
|
11
11
|
y = "foo"
|
12
12
|
|
13
|
-
# !expects IncompatibleAssignment: lhs_type
|
13
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=_Boolean
|
14
14
|
x = true
|
15
|
-
# !expects IncompatibleAssignment: lhs_type
|
15
|
+
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=_Boolean
|
16
16
|
y = false
|
data/smoke/method/a.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# @type method foo: (Integer, y: Integer) -> String
|
2
2
|
|
3
|
-
# !expects MethodBodyTypeMismatch: method=foo, expected
|
3
|
+
# !expects MethodBodyTypeMismatch: method=foo, expected=::String, actual=::Integer
|
4
4
|
def foo(x, y:)
|
5
5
|
# @type var z: String
|
6
6
|
|
7
|
-
# !expects IncompatibleAssignment: lhs_type
|
7
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
8
8
|
z = x
|
9
9
|
|
10
|
-
# !expects IncompatibleAssignment: lhs_type
|
10
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
11
11
|
z = y
|
12
12
|
|
13
13
|
3
|
@@ -15,11 +15,11 @@ end
|
|
15
15
|
|
16
16
|
# @type method bar: (Integer) -> String
|
17
17
|
|
18
|
-
# !expects
|
18
|
+
# !expects MethodArityMismatch: method=bar
|
19
19
|
def bar(x, y)
|
20
20
|
# @type var z: String
|
21
21
|
|
22
|
-
# !expects IncompatibleAssignment: lhs_type
|
22
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
23
23
|
z = x
|
24
24
|
|
25
25
|
z = y
|
data/smoke/method/a.rbi
CHANGED
data/smoke/method/b.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
class A
|
2
|
+
# @implements X
|
3
|
+
|
4
|
+
# !expects*@+2 MethodDefinitionWithOverloading: method=foo, types=
|
5
|
+
# !expects MethodBodyTypeMismatch: method=foo, expected=(::Integer | ::String), actual=::Symbol
|
6
|
+
def foo(x)
|
7
|
+
:foobar
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class B
|
12
|
+
# @implements X
|
13
|
+
|
14
|
+
# @type method foo: (::String | ::Integer) -> any
|
15
|
+
def foo(x)
|
16
|
+
3
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class C
|
21
|
+
# @implements X
|
22
|
+
|
23
|
+
# @type method foo: (Symbol) -> Symbol
|
24
|
+
|
25
|
+
# !expects IncompatibleMethodTypeAnnotation: interface_method=::X.foo, annotation_method=foo
|
26
|
+
def foo(x)
|
27
|
+
:foo
|
28
|
+
end
|
29
|
+
end
|
data/smoke/module/a.rb
CHANGED
@@ -2,7 +2,7 @@ module A
|
|
2
2
|
# @implements A
|
3
3
|
|
4
4
|
def count
|
5
|
-
# @type var n: Integer
|
5
|
+
# @type var n: ::Integer
|
6
6
|
n = 0
|
7
7
|
|
8
8
|
each do |_|
|
@@ -10,10 +10,10 @@ module A
|
|
10
10
|
end
|
11
11
|
|
12
12
|
# @type var s: String
|
13
|
-
# !expects IncompatibleAssignment: lhs_type
|
13
|
+
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
14
14
|
s = n
|
15
15
|
|
16
|
-
# !expects NoMethodError: type=Object
|
16
|
+
# !expects NoMethodError: type=(::A & ::Object & _Each<::Integer>), method=foo
|
17
17
|
foo()
|
18
18
|
|
19
19
|
n
|
data/smoke/module/a.rbi
CHANGED
data/smoke/module/b.rb
CHANGED
data/smoke/module/c.rb
CHANGED
data/smoke/module/d.rb
ADDED