steep 0.39.0 → 0.40.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 +4 -4
- data/.github/workflows/ruby.yml +1 -1
- data/CHANGELOG.md +6 -0
- data/Rakefile +5 -2
- data/bin/output_rebaseline.rb +49 -0
- data/bin/output_test.rb +93 -0
- data/lib/steep.rb +8 -3
- data/lib/steep/cli.rb +1 -1
- data/lib/steep/diagnostic/helper.rb +17 -0
- data/lib/steep/diagnostic/lsp_formatter.rb +16 -0
- data/lib/steep/diagnostic/ruby.rb +623 -0
- data/lib/steep/diagnostic/signature.rb +224 -0
- data/lib/steep/drivers/annotations.rb +13 -6
- data/lib/steep/drivers/check.rb +83 -60
- data/lib/steep/drivers/diagnostic_printer.rb +94 -0
- data/lib/steep/drivers/stats.rb +125 -29
- data/lib/steep/drivers/trace_printer.rb +5 -1
- data/lib/steep/drivers/validate.rb +13 -6
- data/lib/steep/drivers/watch.rb +26 -9
- data/lib/steep/drivers/worker.rb +5 -0
- data/lib/steep/project/options.rb +4 -4
- data/lib/steep/project/signature_file.rb +8 -2
- data/lib/steep/project/stats_calculator.rb +80 -0
- data/lib/steep/project/target.rb +64 -53
- data/lib/steep/range_extension.rb +29 -0
- data/lib/steep/server/base_worker.rb +42 -4
- data/lib/steep/server/code_worker.rb +37 -24
- data/lib/steep/server/interaction_worker.rb +1 -0
- data/lib/steep/server/master.rb +268 -82
- data/lib/steep/server/signature_worker.rb +7 -59
- data/lib/steep/server/worker_process.rb +9 -9
- data/lib/steep/signature/validator.rb +33 -9
- data/lib/steep/type_construction.rb +276 -194
- data/lib/steep/version.rb +1 -1
- data/smoke/alias/a.rb +0 -3
- data/smoke/alias/b.rb +0 -1
- data/smoke/alias/c.rb +0 -2
- data/smoke/alias/test.yaml +73 -0
- data/smoke/and/a.rb +0 -3
- data/smoke/and/test.yaml +24 -0
- data/smoke/array/a.rb +0 -3
- data/smoke/array/b.rb +0 -2
- data/smoke/array/c.rb +0 -1
- data/smoke/array/test.yaml +80 -0
- data/smoke/block/a.rb +0 -2
- data/smoke/block/b.rb +0 -2
- data/smoke/block/d.rb +0 -4
- data/smoke/block/test.yaml +96 -0
- data/smoke/broken/Steepfile +5 -0
- data/smoke/broken/broken.rb +0 -0
- data/smoke/broken/broken.rbs +0 -0
- data/smoke/broken/test.yaml +6 -0
- data/smoke/case/a.rb +0 -3
- data/smoke/case/test.yaml +36 -0
- data/smoke/class/a.rb +0 -3
- data/smoke/class/c.rb +0 -1
- data/smoke/class/f.rb +0 -1
- data/smoke/class/g.rb +0 -2
- data/smoke/class/i.rb +0 -2
- data/smoke/class/test.yaml +89 -0
- data/smoke/const/a.rb +0 -3
- data/smoke/const/b.rb +7 -0
- data/smoke/const/b.rbs +5 -0
- data/smoke/const/test.yaml +96 -0
- data/smoke/diagnostics-rbs-duplicated/Steepfile +5 -0
- data/smoke/diagnostics-rbs-duplicated/a.rbs +5 -0
- data/smoke/diagnostics-rbs-duplicated/test.yaml +10 -0
- data/smoke/diagnostics-rbs/Steepfile +5 -0
- data/smoke/diagnostics-rbs/duplicated-method-definition.rbs +20 -0
- data/smoke/diagnostics-rbs/generic-parameter-mismatch.rbs +7 -0
- data/smoke/diagnostics-rbs/invalid-method-overload.rbs +3 -0
- data/smoke/diagnostics-rbs/invalid-type-application.rbs +7 -0
- data/smoke/diagnostics-rbs/invalid_variance_annotation.rbs +3 -0
- data/smoke/diagnostics-rbs/recursive-alias.rbs +5 -0
- data/smoke/diagnostics-rbs/recursive-class.rbs +8 -0
- data/smoke/diagnostics-rbs/superclass-mismatch.rbs +7 -0
- data/smoke/diagnostics-rbs/test.yaml +142 -0
- data/smoke/diagnostics-rbs/unknown-method-alias.rbs +3 -0
- data/smoke/diagnostics-rbs/unknown-type-name.rbs +13 -0
- data/smoke/diagnostics/Steepfile +5 -0
- data/smoke/diagnostics/a.rbs +26 -0
- data/smoke/diagnostics/argument_type_mismatch.rb +1 -0
- data/smoke/diagnostics/block_body_type_mismatch.rb +1 -0
- data/smoke/diagnostics/block_type_mismatch.rb +3 -0
- data/smoke/diagnostics/break_type_mismatch.rb +1 -0
- data/smoke/diagnostics/else_on_exhaustive_case.rb +12 -0
- data/smoke/diagnostics/incompatible_annotation.rb +6 -0
- data/smoke/diagnostics/incompatible_argument.rb +1 -0
- data/smoke/diagnostics/incompatible_assignment.rb +8 -0
- data/smoke/diagnostics/method_arity_mismatch.rb +11 -0
- data/smoke/diagnostics/method_body_type_mismatch.rb +6 -0
- data/smoke/diagnostics/method_definition_missing.rb +2 -0
- data/smoke/diagnostics/method_return_type_annotation_mismatch.rb +7 -0
- data/smoke/diagnostics/missing_keyword.rb +1 -0
- data/smoke/diagnostics/no_method.rb +1 -0
- data/smoke/diagnostics/required_block_missing.rb +1 -0
- data/smoke/diagnostics/return_type_mismatch.rb +6 -0
- data/smoke/diagnostics/test.yaml +333 -0
- data/smoke/diagnostics/unexpected_block_given.rb +1 -0
- data/smoke/diagnostics/unexpected_dynamic_method.rb +3 -0
- data/smoke/diagnostics/unexpected_jump.rb +4 -0
- data/smoke/diagnostics/unexpected_jump_value.rb +3 -0
- data/smoke/diagnostics/unexpected_keyword.rb +1 -0
- data/smoke/diagnostics/unexpected_splat.rb +1 -0
- data/smoke/diagnostics/unexpected_yield.rb +6 -0
- data/smoke/diagnostics/unknown_constant_assigned.rb +7 -0
- data/smoke/diagnostics/unresolved_overloading.rb +1 -0
- data/smoke/diagnostics/unsatisfiable_constraint.rb +7 -0
- data/smoke/diagnostics/unsupported_syntax.rb +2 -0
- data/smoke/dstr/a.rb +0 -1
- data/smoke/dstr/test.yaml +10 -0
- data/smoke/ensure/a.rb +0 -4
- data/smoke/ensure/test.yaml +47 -0
- data/smoke/enumerator/a.rb +0 -6
- data/smoke/enumerator/b.rb +0 -3
- data/smoke/enumerator/test.yaml +100 -0
- data/smoke/extension/a.rb +0 -1
- data/smoke/extension/b.rb +0 -2
- data/smoke/extension/c.rb +0 -1
- data/smoke/extension/test.yaml +50 -0
- data/smoke/hash/b.rb +0 -1
- data/smoke/hash/c.rb +0 -3
- data/smoke/hash/d.rb +0 -1
- data/smoke/hash/e.rb +0 -1
- data/smoke/hash/test.yaml +62 -0
- data/smoke/hello/hello.rb +0 -2
- data/smoke/hello/test.yaml +18 -0
- data/smoke/if/a.rb +0 -2
- data/smoke/if/test.yaml +27 -0
- data/smoke/implements/a.rb +0 -2
- data/smoke/implements/test.yaml +16 -0
- data/smoke/initialize/test.yaml +4 -0
- data/smoke/integer/a.rb +0 -7
- data/smoke/integer/test.yaml +66 -0
- data/smoke/interface/a.rb +0 -2
- data/smoke/interface/test.yaml +16 -0
- data/smoke/kwbegin/a.rb +0 -1
- data/smoke/kwbegin/test.yaml +14 -0
- data/smoke/lambda/a.rb +1 -4
- data/smoke/lambda/test.yaml +28 -0
- data/smoke/literal/a.rb +0 -5
- data/smoke/literal/b.rb +0 -2
- data/smoke/literal/test.yaml +79 -0
- data/smoke/map/test.yaml +4 -0
- data/smoke/method/a.rb +0 -5
- data/smoke/method/b.rb +0 -1
- data/smoke/method/test.yaml +71 -0
- data/smoke/module/a.rb +0 -2
- data/smoke/module/b.rb +0 -2
- data/smoke/module/c.rb +0 -1
- data/smoke/module/d.rb +0 -1
- data/smoke/module/f.rb +0 -2
- data/smoke/module/test.yaml +51 -0
- data/smoke/regexp/a.rb +0 -38
- data/smoke/regexp/b.rb +0 -26
- data/smoke/regexp/test.yaml +372 -0
- data/smoke/regression/set_divide.rb +0 -4
- data/smoke/regression/test.yaml +38 -0
- data/smoke/rescue/a.rb +0 -5
- data/smoke/rescue/test.yaml +60 -0
- data/smoke/self/a.rb +0 -2
- data/smoke/self/test.yaml +16 -0
- data/smoke/skip/skip.rb +0 -2
- data/smoke/skip/test.yaml +16 -0
- data/smoke/stdout/test.yaml +4 -0
- data/smoke/super/a.rb +0 -4
- data/smoke/super/test.yaml +52 -0
- data/smoke/toplevel/a.rb +0 -1
- data/smoke/toplevel/test.yaml +12 -0
- data/smoke/tsort/a.rb +0 -3
- data/smoke/tsort/test.yaml +32 -0
- data/smoke/type_case/a.rb +0 -4
- data/smoke/type_case/test.yaml +33 -0
- data/smoke/yield/a.rb +0 -3
- data/smoke/yield/b.rb +6 -0
- data/smoke/yield/test.yaml +49 -0
- data/steep.gemspec +3 -3
- metadata +108 -17
- data/bin/smoke_runner.rb +0 -139
- data/lib/steep/drivers/signature_error_printer.rb +0 -25
- data/lib/steep/errors.rb +0 -594
- data/lib/steep/signature/errors.rb +0 -128
- data/lib/steep/type_assignability.rb +0 -367
@@ -1,16 +1,12 @@
|
|
1
1
|
d = Set["1","2","3"]
|
2
|
-
# !expects NoMethodError: type=::Set[::String], method=ffffffff
|
3
2
|
d.ffffffff
|
4
3
|
|
5
4
|
d.divide do |x, y|
|
6
|
-
# !expects NoMethodError: type=::String, method=ggggg
|
7
5
|
x.ggggg
|
8
6
|
|
9
|
-
# !expects NoMethodError: type=::String, method=ggggg
|
10
7
|
y.ggggg
|
11
8
|
end
|
12
9
|
|
13
10
|
d.divide do |x|
|
14
|
-
# !expects NoMethodError: type=::String, method=ggggg
|
15
11
|
x.ggggg
|
16
12
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
array.rb:
|
4
|
+
diagnostics: []
|
5
|
+
fun.rb:
|
6
|
+
diagnostics: []
|
7
|
+
hash.rb:
|
8
|
+
diagnostics: []
|
9
|
+
poly_new.rb:
|
10
|
+
diagnostics: []
|
11
|
+
range.rb:
|
12
|
+
diagnostics: []
|
13
|
+
set_divide.rb:
|
14
|
+
diagnostics:
|
15
|
+
- |
|
16
|
+
set_divide.rb:2:2: [error] Type `::Set[::String]` does not have method `ffffffff`
|
17
|
+
│ Diagnostic ID: Ruby::NoMethod
|
18
|
+
│
|
19
|
+
└ d.ffffffff
|
20
|
+
~~~~~~~~
|
21
|
+
- |
|
22
|
+
set_divide.rb:5:4: [error] Type `::String` does not have method `ggggg`
|
23
|
+
│ Diagnostic ID: Ruby::NoMethod
|
24
|
+
│
|
25
|
+
└ x.ggggg
|
26
|
+
~~~~~
|
27
|
+
- |
|
28
|
+
set_divide.rb:7:4: [error] Type `::String` does not have method `ggggg`
|
29
|
+
│ Diagnostic ID: Ruby::NoMethod
|
30
|
+
│
|
31
|
+
└ y.ggggg
|
32
|
+
~~~~~
|
33
|
+
- |
|
34
|
+
set_divide.rb:11:4: [error] Type `::String` does not have method `ggggg`
|
35
|
+
│ Diagnostic ID: Ruby::NoMethod
|
36
|
+
│
|
37
|
+
└ x.ggggg
|
38
|
+
~~~~~
|
data/smoke/rescue/a.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# @type var a: Integer
|
2
2
|
|
3
|
-
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=(::String | ::Integer)
|
4
3
|
a = begin
|
5
4
|
'foo'
|
6
5
|
rescue
|
@@ -9,12 +8,10 @@ a = begin
|
|
9
8
|
|
10
9
|
# @type var b: Integer
|
11
10
|
|
12
|
-
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=(::String | ::Integer)
|
13
11
|
b = 'foo' rescue 1
|
14
12
|
|
15
13
|
# @type var c: Integer
|
16
14
|
|
17
|
-
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=(::String | ::Symbol | ::Integer)
|
18
15
|
c = begin
|
19
16
|
'foo'
|
20
17
|
rescue RuntimeError
|
@@ -25,7 +22,6 @@ c = begin
|
|
25
22
|
|
26
23
|
# @type var e: Integer
|
27
24
|
|
28
|
-
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=(::Array[::Integer] | ::Symbol | ::Integer)
|
29
25
|
e = begin
|
30
26
|
'foo'
|
31
27
|
rescue RuntimeError
|
@@ -38,7 +34,6 @@ e = begin
|
|
38
34
|
|
39
35
|
# @type method foo: (String) -> String
|
40
36
|
|
41
|
-
# !expects MethodBodyTypeMismatch: method=foo, expected=::String, actual=(::Integer | ::String)
|
42
37
|
def foo(a)
|
43
38
|
10
|
44
39
|
rescue
|
@@ -0,0 +1,60 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
a.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
a.rb:3:0: [error] Cannot assign a value of type `(::String | ::Integer)` to a variable of type `::Integer`
|
7
|
+
│ (::String | ::Integer) <: ::Integer
|
8
|
+
│ ::String <: ::Integer
|
9
|
+
│ ::Object <: ::Integer
|
10
|
+
│ ::BasicObject <: ::Integer
|
11
|
+
│
|
12
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
13
|
+
│
|
14
|
+
└ a = begin
|
15
|
+
~~~~~~~~~
|
16
|
+
- |
|
17
|
+
a.rb:11:0: [error] Cannot assign a value of type `(::String | ::Integer)` to a variable of type `::Integer`
|
18
|
+
│ (::String | ::Integer) <: ::Integer
|
19
|
+
│ ::String <: ::Integer
|
20
|
+
│ ::Object <: ::Integer
|
21
|
+
│ ::BasicObject <: ::Integer
|
22
|
+
│
|
23
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
24
|
+
│
|
25
|
+
└ b = 'foo' rescue 1
|
26
|
+
~~~~~~~~~~~~~~~~~~
|
27
|
+
- |
|
28
|
+
a.rb:15:0: [error] Cannot assign a value of type `(::String | ::Symbol | ::Integer)` to a variable of type `::Integer`
|
29
|
+
│ (::String | ::Symbol | ::Integer) <: ::Integer
|
30
|
+
│ ::String <: ::Integer
|
31
|
+
│ ::Object <: ::Integer
|
32
|
+
│ ::BasicObject <: ::Integer
|
33
|
+
│
|
34
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
35
|
+
│
|
36
|
+
└ c = begin
|
37
|
+
~~~~~~~~~
|
38
|
+
- |
|
39
|
+
a.rb:25:0: [error] Cannot assign a value of type `(::Array[::Integer] | ::Symbol | ::Integer)` to a variable of type `::Integer`
|
40
|
+
│ (::Array[::Integer] | ::Symbol | ::Integer) <: ::Integer
|
41
|
+
│ ::Array[::Integer] <: ::Integer
|
42
|
+
│ ::Object <: ::Integer
|
43
|
+
│ ::BasicObject <: ::Integer
|
44
|
+
│
|
45
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
46
|
+
│
|
47
|
+
└ e = begin
|
48
|
+
~~~~~~~~~
|
49
|
+
- |
|
50
|
+
a.rb:37:0: [error] Cannot allow method body have type `(::Integer | ::String)` because declared as type `::String`
|
51
|
+
│ (::Integer | ::String) <: ::String
|
52
|
+
│ ::Integer <: ::String
|
53
|
+
│ ::Numeric <: ::String
|
54
|
+
│ ::Object <: ::String
|
55
|
+
│ ::BasicObject <: ::String
|
56
|
+
│
|
57
|
+
│ Diagnostic ID: Ruby::MethodBodyTypeMismatch
|
58
|
+
│
|
59
|
+
└ def foo(a)
|
60
|
+
~~~~~~~~~~
|
data/smoke/self/a.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
a.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
a.rb:16:2: [error] Type `::Object` does not have method `baz`
|
7
|
+
│ Diagnostic ID: Ruby::NoMethod
|
8
|
+
│
|
9
|
+
└ baz
|
10
|
+
~~~
|
11
|
+
- |
|
12
|
+
a.rb:19:4: [error] Type `::Object` does not have method `baz`
|
13
|
+
│ Diagnostic ID: Ruby::NoMethod
|
14
|
+
│
|
15
|
+
└ baz
|
16
|
+
~~~
|
data/smoke/skip/skip.rb
CHANGED
@@ -5,11 +5,9 @@ end
|
|
5
5
|
# @type var foo: String
|
6
6
|
|
7
7
|
foo = _ = begin
|
8
|
-
# !expects NoMethodError: type=::Object, method=no_such_method
|
9
8
|
self.no_such_method
|
10
9
|
end
|
11
10
|
|
12
11
|
foo = __any__ = begin
|
13
|
-
# !expects NoMethodError: type=::Object, method=no_such_method
|
14
12
|
self.no_such_method
|
15
13
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
skip.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
skip.rb:8:7: [error] Type `::Object` does not have method `no_such_method`
|
7
|
+
│ Diagnostic ID: Ruby::NoMethod
|
8
|
+
│
|
9
|
+
└ self.no_such_method
|
10
|
+
~~~~~~~~~~~~~~
|
11
|
+
- |
|
12
|
+
skip.rb:12:7: [error] Type `::Object` does not have method `no_such_method`
|
13
|
+
│ Diagnostic ID: Ruby::NoMethod
|
14
|
+
│
|
15
|
+
└ self.no_such_method
|
16
|
+
~~~~~~~~~~~~~~
|
data/smoke/super/a.rb
CHANGED
@@ -3,9 +3,7 @@ class A
|
|
3
3
|
# @type self: A
|
4
4
|
|
5
5
|
# @type var a: Integer
|
6
|
-
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=::Object
|
7
6
|
a = super(x)
|
8
|
-
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=::Object
|
9
7
|
a = super
|
10
8
|
|
11
9
|
# @type var b: Object
|
@@ -25,10 +23,8 @@ class A
|
|
25
23
|
def baz
|
26
24
|
# @type self: A
|
27
25
|
|
28
|
-
# !expects UnexpectedSuper: method=baz
|
29
26
|
super()
|
30
27
|
|
31
|
-
# !expects UnexpectedSuper: method=baz
|
32
28
|
super
|
33
29
|
end
|
34
30
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
a.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
a.rb:6:4: [error] Cannot assign a value of type `::Object` to a variable of type `::Integer`
|
7
|
+
│ ::Object <: ::Integer
|
8
|
+
│ ::BasicObject <: ::Integer
|
9
|
+
│
|
10
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
11
|
+
│
|
12
|
+
└ a = super(x)
|
13
|
+
~~~~~~~~~~~~
|
14
|
+
- |
|
15
|
+
a.rb:7:4: [error] Cannot assign a value of type `::Object` to a variable of type `::Integer`
|
16
|
+
│ ::Object <: ::Integer
|
17
|
+
│ ::BasicObject <: ::Integer
|
18
|
+
│
|
19
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
20
|
+
│
|
21
|
+
└ a = super
|
22
|
+
~~~~~~~~~
|
23
|
+
- |
|
24
|
+
a.rb:19:4: [error] Cannot detect the type of the expression
|
25
|
+
│ Diagnostic ID: Ruby::FallbackAny
|
26
|
+
│
|
27
|
+
└ super()
|
28
|
+
~~~~~~~
|
29
|
+
- |
|
30
|
+
a.rb:20:4: [error] Cannot detect the type of the expression
|
31
|
+
│ Diagnostic ID: Ruby::FallbackAny
|
32
|
+
│
|
33
|
+
└ super
|
34
|
+
~~~~~
|
35
|
+
- |
|
36
|
+
a.rb:26:4: [error] UnexpectedSuper
|
37
|
+
│ Diagnostic ID: Ruby::UnexpectedSuper
|
38
|
+
│
|
39
|
+
└ super()
|
40
|
+
~~~~~~~
|
41
|
+
- |
|
42
|
+
a.rb:28:4: [error] UnexpectedSuper
|
43
|
+
│ Diagnostic ID: Ruby::UnexpectedSuper
|
44
|
+
│
|
45
|
+
└ super
|
46
|
+
~~~~~
|
47
|
+
- |
|
48
|
+
a.rb:28:4: [error] Cannot detect the type of the expression
|
49
|
+
│ Diagnostic ID: Ruby::FallbackAny
|
50
|
+
│
|
51
|
+
└ super
|
52
|
+
~~~~~
|
data/smoke/toplevel/a.rb
CHANGED
data/smoke/tsort/a.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# ALLOW FAILURE
|
2
|
-
|
3
1
|
require "tsort"
|
4
2
|
|
5
3
|
# @type var g: Hash[Integer, Array[Integer]]
|
@@ -11,5 +9,4 @@ each_node = -> (&b) { g.each_key(&b) }
|
|
11
9
|
each_child = -> (n, &b) { g[n].each(&b) }
|
12
10
|
|
13
11
|
# @type var xs: Array[String]
|
14
|
-
# !expects IncompatibleAssignment: lhs_type=::Array[::String], rhs_type=::Array[::Integer]
|
15
12
|
xs = TSort.tsort(each_node, each_child)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
a.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
a.rb:7:0: [error] Cannot assign a value of type `^() -> ::Hash[::Integer, ::Array[::Integer]]` to a variable of type `^() { (::Integer) -> void } -> void`
|
7
|
+
│ ^() -> ::Hash[::Integer, ::Array[::Integer]] <: ^() { (::Integer) -> void } -> void
|
8
|
+
│
|
9
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
10
|
+
│
|
11
|
+
└ each_node = -> (&b) { g.each_key(&b) }
|
12
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
13
|
+
- |
|
14
|
+
a.rb:9:0: [error] Cannot assign a value of type `^(::Integer) -> ::Array[::Integer]` to a variable of type `^(::Integer) { (::Integer) -> void } -> void`
|
15
|
+
│ ^(::Integer) -> ::Array[::Integer] <: ^(::Integer) { (::Integer) -> void } -> void
|
16
|
+
│
|
17
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
18
|
+
│
|
19
|
+
└ each_child = -> (n, &b) { g[n].each(&b) }
|
20
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
21
|
+
- |
|
22
|
+
a.rb:12:0: [error] Cannot assign a value of type `::Array[::Integer]` to a variable of type `::Array[::String]`
|
23
|
+
│ ::Array[::Integer] <: ::Array[::String]
|
24
|
+
│ ::Integer <: ::String
|
25
|
+
│ ::Numeric <: ::String
|
26
|
+
│ ::Object <: ::String
|
27
|
+
│ ::BasicObject <: ::String
|
28
|
+
│
|
29
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
30
|
+
│
|
31
|
+
└ xs = TSort.tsort(each_node, each_child)
|
32
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
data/smoke/type_case/a.rb
CHANGED
@@ -4,25 +4,21 @@ x = (_ = nil)
|
|
4
4
|
|
5
5
|
case x
|
6
6
|
when Integer, String
|
7
|
-
# !expects NoMethodError: type=(::Integer | ::String), method=foobar
|
8
7
|
x.foobar()
|
9
8
|
end
|
10
9
|
|
11
10
|
case x == (_ = 1)
|
12
11
|
when Integer
|
13
|
-
# !expects NoMethodError: type=(::Integer | ::String | ::Symbol), method=foobar
|
14
12
|
x.foobar
|
15
13
|
end
|
16
14
|
|
17
15
|
case x
|
18
16
|
when 1
|
19
|
-
# !expects NoMethodError: type=1, method=foobar
|
20
17
|
x.foobar
|
21
18
|
end
|
22
19
|
|
23
20
|
case x
|
24
21
|
when String
|
25
|
-
# !expects@+2 IncompatibleAnnotation: var_name=x, ::Integer <: ::String
|
26
22
|
# @type var x: Integer
|
27
23
|
x + 1
|
28
24
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
a.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
a.rb:7:4: [error] Type `(::Integer | ::String)` does not have method `foobar`
|
7
|
+
│ Diagnostic ID: Ruby::NoMethod
|
8
|
+
│
|
9
|
+
└ x.foobar()
|
10
|
+
~~~~~~
|
11
|
+
- |
|
12
|
+
a.rb:12:4: [error] Type `(::Integer | ::String | ::Symbol)` does not have method `foobar`
|
13
|
+
│ Diagnostic ID: Ruby::NoMethod
|
14
|
+
│
|
15
|
+
└ x.foobar
|
16
|
+
~~~~~~
|
17
|
+
- |
|
18
|
+
a.rb:17:4: [error] Type `1` does not have method `foobar`
|
19
|
+
│ Diagnostic ID: Ruby::NoMethod
|
20
|
+
│
|
21
|
+
└ x.foobar
|
22
|
+
~~~~~~
|
23
|
+
- |
|
24
|
+
a.rb:23:2: [error] Type annotation about `x` is incompatible since ::Integer <: ::String doesn't hold
|
25
|
+
│ ::Integer <: ::String
|
26
|
+
│ ::Numeric <: ::String
|
27
|
+
│ ::Object <: ::String
|
28
|
+
│ ::BasicObject <: ::String
|
29
|
+
│
|
30
|
+
│ Diagnostic ID: Ruby::IncompatibleAnnotation
|
31
|
+
│
|
32
|
+
└ x + 1
|
33
|
+
~~~~~
|
data/smoke/yield/a.rb
CHANGED
@@ -3,16 +3,13 @@ class A
|
|
3
3
|
def foo()
|
4
4
|
# @type var x: String
|
5
5
|
|
6
|
-
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
7
6
|
x = yield(3)
|
8
7
|
|
9
|
-
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=::String
|
10
8
|
yield(x)
|
11
9
|
end
|
12
10
|
|
13
11
|
# @type method bar: () -> untyped
|
14
12
|
def bar()
|
15
|
-
# !expects UnexpectedYield
|
16
13
|
yield 4
|
17
14
|
end
|
18
15
|
end
|