steep 0.39.0 → 0.40.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/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
data/smoke/hello/hello.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
hello.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
hello.rb:9:6: [error] Type `::_Bar` does not have method `foo`
|
7
|
+
│ Diagnostic ID: Ruby::NoMethod
|
8
|
+
│
|
9
|
+
└ b = y.foo
|
10
|
+
~~~
|
11
|
+
- |
|
12
|
+
hello.rb:11:0: [error] Cannot assign a value of type `::_Bar` to a variable of type `::_Foo`
|
13
|
+
│ ::_Bar <: ::_Foo
|
14
|
+
│
|
15
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
16
|
+
│
|
17
|
+
└ x = y
|
18
|
+
~~~~~
|
data/smoke/if/a.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
x = y = z = (_ = nil)
|
4
4
|
|
5
|
-
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=(::Symbol | nil)
|
6
5
|
a = if x
|
7
6
|
:foo
|
8
7
|
end
|
@@ -13,7 +12,6 @@ else
|
|
13
12
|
"baz"
|
14
13
|
end
|
15
14
|
|
16
|
-
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=(::String | ::Integer)
|
17
15
|
a = if z
|
18
16
|
"foofoo"
|
19
17
|
else
|
data/smoke/if/test.yaml
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
a.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
a.rb:5:0: [error] Cannot assign a value of type `(::Symbol | nil)` to a variable of type `::String`
|
7
|
+
│ (::Symbol | nil) <: ::String
|
8
|
+
│ ::Symbol <: ::String
|
9
|
+
│ ::Object <: ::String
|
10
|
+
│ ::BasicObject <: ::String
|
11
|
+
│
|
12
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
13
|
+
│
|
14
|
+
└ a = if x
|
15
|
+
~~~~~~~~
|
16
|
+
- |
|
17
|
+
a.rb:15:0: [error] Cannot assign a value of type `(::String | ::Integer)` to a variable of type `::String`
|
18
|
+
│ (::String | ::Integer) <: ::String
|
19
|
+
│ ::Integer <: ::String
|
20
|
+
│ ::Numeric <: ::String
|
21
|
+
│ ::Object <: ::String
|
22
|
+
│ ::BasicObject <: ::String
|
23
|
+
│
|
24
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
25
|
+
│
|
26
|
+
└ a = if z
|
27
|
+
~~~~~~~~
|
data/smoke/implements/a.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
a.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
a.rb:1:6: [error] Cannot find implementation of method `::A#baz`
|
7
|
+
│ Diagnostic ID: Ruby::MethodDefinitionMissing
|
8
|
+
│
|
9
|
+
└ class A
|
10
|
+
~
|
11
|
+
- |
|
12
|
+
a.rb:1:6: [error] Cannot find implementation of method `::A.bar`
|
13
|
+
│ Diagnostic ID: Ruby::MethodDefinitionMissing
|
14
|
+
│
|
15
|
+
└ class A
|
16
|
+
~
|
data/smoke/integer/a.rb
CHANGED
@@ -1,33 +1,26 @@
|
|
1
1
|
# @type var x: Numeric
|
2
2
|
x = _ = 1
|
3
3
|
integer_1 = Integer(x)
|
4
|
-
# !expects NoMethodError: type=::Integer, method=foo
|
5
4
|
integer_1.foo
|
6
5
|
|
7
6
|
integer_2 = Integer("1")
|
8
|
-
# !expects NoMethodError: type=::Integer, method=foo
|
9
7
|
integer_2.foo
|
10
8
|
|
11
9
|
class WithToInt
|
12
10
|
def to_int; 1; end
|
13
11
|
end
|
14
12
|
integer_3 = Integer(WithToInt.new)
|
15
|
-
# !expects NoMethodError: type=::Integer, method=foo
|
16
13
|
integer_3.foo
|
17
14
|
|
18
15
|
class WithToI
|
19
16
|
def to_i; 1; end
|
20
17
|
end
|
21
18
|
integer_4 = Integer(WithToI.new)
|
22
|
-
# !expects NoMethodError: type=::Integer, method=foo
|
23
19
|
integer_4.foo
|
24
20
|
|
25
21
|
integer_5 = Integer("10", 2)
|
26
|
-
# !expects NoMethodError: type=::Integer, method=foo
|
27
22
|
integer_5.foo
|
28
23
|
|
29
|
-
# !expects* UnresolvedOverloading: receiver=::Object, method_name=Integer,
|
30
24
|
Integer(Object.new)
|
31
25
|
|
32
|
-
# !expects* UnresolvedOverloading: receiver=::Object, method_name=Integer,
|
33
26
|
Integer(nil)
|
@@ -0,0 +1,66 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
a.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
a.rb:4:10: [error] Type `::Integer` does not have method `foo`
|
7
|
+
│ Diagnostic ID: Ruby::NoMethod
|
8
|
+
│
|
9
|
+
└ integer_1.foo
|
10
|
+
~~~
|
11
|
+
- |
|
12
|
+
a.rb:7:10: [error] Type `::Integer` does not have method `foo`
|
13
|
+
│ Diagnostic ID: Ruby::NoMethod
|
14
|
+
│
|
15
|
+
└ integer_2.foo
|
16
|
+
~~~
|
17
|
+
- |
|
18
|
+
a.rb:12:20: [error] Cannot detect the type of the expression
|
19
|
+
│ Diagnostic ID: Ruby::FallbackAny
|
20
|
+
│
|
21
|
+
└ integer_3 = Integer(WithToInt.new)
|
22
|
+
~~~~~~~~~
|
23
|
+
- |
|
24
|
+
a.rb:13:10: [error] Type `::Integer` does not have method `foo`
|
25
|
+
│ Diagnostic ID: Ruby::NoMethod
|
26
|
+
│
|
27
|
+
└ integer_3.foo
|
28
|
+
~~~
|
29
|
+
- |
|
30
|
+
a.rb:18:20: [error] Cannot detect the type of the expression
|
31
|
+
│ Diagnostic ID: Ruby::FallbackAny
|
32
|
+
│
|
33
|
+
└ integer_4 = Integer(WithToI.new)
|
34
|
+
~~~~~~~
|
35
|
+
- |
|
36
|
+
a.rb:19:10: [error] Type `::Integer` does not have method `foo`
|
37
|
+
│ Diagnostic ID: Ruby::NoMethod
|
38
|
+
│
|
39
|
+
└ integer_4.foo
|
40
|
+
~~~
|
41
|
+
- |
|
42
|
+
a.rb:22:10: [error] Type `::Integer` does not have method `foo`
|
43
|
+
│ Diagnostic ID: Ruby::NoMethod
|
44
|
+
│
|
45
|
+
└ integer_5.foo
|
46
|
+
~~~
|
47
|
+
- |
|
48
|
+
a.rb:24:0: [error] Cannot find compatible overloading of method `Integer` of type `::Object`
|
49
|
+
│ Method types:
|
50
|
+
│ def Integer: ((::Numeric | ::String), ?exception: bool) -> ::Integer
|
51
|
+
│ | (::String, ?::Integer, ?exception: bool) -> ::Integer
|
52
|
+
│
|
53
|
+
│ Diagnostic ID: Ruby::UnresolvedOverloading
|
54
|
+
│
|
55
|
+
└ Integer(Object.new)
|
56
|
+
~~~~~~~~~~~~~~~~~~~
|
57
|
+
- |
|
58
|
+
a.rb:26:0: [error] Cannot find compatible overloading of method `Integer` of type `::Object`
|
59
|
+
│ Method types:
|
60
|
+
│ def Integer: ((::Numeric | ::String), ?exception: bool) -> ::Integer
|
61
|
+
│ | (::String, ?::Integer, ?exception: bool) -> ::Integer
|
62
|
+
│
|
63
|
+
│ Diagnostic ID: Ruby::UnresolvedOverloading
|
64
|
+
│
|
65
|
+
└ Integer(nil)
|
66
|
+
~~~~~~~~~~~~
|
data/smoke/interface/a.rb
CHANGED
@@ -2,13 +2,11 @@ class A
|
|
2
2
|
# @dynamic foo
|
3
3
|
|
4
4
|
def hello
|
5
|
-
# !expects NoMethodError: type=::A::Object, method=bar
|
6
5
|
foo.foo.bar
|
7
6
|
|
8
7
|
# @type var object: ::Object
|
9
8
|
object = _ = nil
|
10
9
|
|
11
|
-
# !expects NoMethodError: type=::Object, method=object?
|
12
10
|
object.object?
|
13
11
|
end
|
14
12
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
a.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
a.rb:5:12: [error] Type `::A::Object` does not have method `bar`
|
7
|
+
│ Diagnostic ID: Ruby::NoMethod
|
8
|
+
│
|
9
|
+
└ foo.foo.bar
|
10
|
+
~~~
|
11
|
+
- |
|
12
|
+
a.rb:10:11: [error] Type `::Object` does not have method `object?`
|
13
|
+
│ Diagnostic ID: Ruby::NoMethod
|
14
|
+
│
|
15
|
+
└ object.object?
|
16
|
+
~~~~~~~
|
data/smoke/kwbegin/a.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
a.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
a.rb:3:0: [error] Cannot assign a value of type `::String` to a variable of type `::Integer`
|
7
|
+
│ ::String <: ::Integer
|
8
|
+
│ ::Object <: ::Integer
|
9
|
+
│ ::BasicObject <: ::Integer
|
10
|
+
│
|
11
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
12
|
+
│
|
13
|
+
└ a = begin
|
14
|
+
~~~~~~~~~
|
data/smoke/lambda/a.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# @type var a: Integer
|
2
2
|
|
3
|
-
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=::String
|
4
3
|
a = -> (x, y) do
|
5
4
|
# @type var x: String
|
6
5
|
# @type var y: String
|
@@ -8,10 +7,8 @@ a = -> (x, y) do
|
|
8
7
|
end["foo", "bar"]
|
9
8
|
|
10
9
|
# @type var b: ^(Integer) -> Integer
|
11
|
-
# !expects IncompatibleAssignment: lhs_type=^(::Integer) -> ::Integer, rhs_type=::Proc
|
12
10
|
b = lambda do |x|
|
13
|
-
|
14
|
-
x + 1
|
11
|
+
x + 1
|
15
12
|
end
|
16
13
|
|
17
14
|
# @type var c: ^(Integer) -> Integer
|
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
a.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
a.rb:3:0: [error] Cannot assign a value of type `::String` to a variable of type `::Integer`
|
7
|
+
│ ::String <: ::Integer
|
8
|
+
│ ::Object <: ::Integer
|
9
|
+
│ ::BasicObject <: ::Integer
|
10
|
+
│
|
11
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
12
|
+
│
|
13
|
+
└ a = -> (x, y) do
|
14
|
+
~~~~~~~~~~~~~~~~
|
15
|
+
- |
|
16
|
+
a.rb:11:4: [error] Type `nil` does not have method `+`
|
17
|
+
│ Diagnostic ID: Ruby::NoMethod
|
18
|
+
│
|
19
|
+
└ x + 1
|
20
|
+
~
|
21
|
+
- |
|
22
|
+
a.rb:10:0: [error] Cannot assign a value of type `::Proc` to a variable of type `^(::Integer) -> ::Integer`
|
23
|
+
│ ::Proc <: ^(::Integer) -> ::Integer
|
24
|
+
│
|
25
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
26
|
+
│
|
27
|
+
└ b = lambda do |x|
|
28
|
+
~~~~~~~~~~~~~~~~~
|
data/smoke/literal/a.rb
CHANGED
@@ -1,16 +1,11 @@
|
|
1
1
|
# @type var x: String
|
2
2
|
# @type var y: Integer
|
3
3
|
|
4
|
-
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
5
4
|
x = 1
|
6
5
|
|
7
|
-
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Symbol
|
8
6
|
x = :foo
|
9
7
|
|
10
|
-
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=::String
|
11
8
|
y = "foo"
|
12
9
|
|
13
|
-
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=bool
|
14
10
|
x = true
|
15
|
-
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=bool
|
16
11
|
y = false
|
data/smoke/literal/b.rb
CHANGED
@@ -0,0 +1,79 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
a.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
a.rb:4:0: [error] Cannot assign a value of type `::Integer` to a variable of type `::String`
|
7
|
+
│ ::Integer <: ::String
|
8
|
+
│ ::Numeric <: ::String
|
9
|
+
│ ::Object <: ::String
|
10
|
+
│ ::BasicObject <: ::String
|
11
|
+
│
|
12
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
13
|
+
│
|
14
|
+
└ x = 1
|
15
|
+
~~~~~
|
16
|
+
- |
|
17
|
+
a.rb:6:0: [error] Cannot assign a value of type `::Symbol` to a variable of type `::String`
|
18
|
+
│ ::Symbol <: ::String
|
19
|
+
│ ::Object <: ::String
|
20
|
+
│ ::BasicObject <: ::String
|
21
|
+
│
|
22
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
23
|
+
│
|
24
|
+
└ x = :foo
|
25
|
+
~~~~~~~~
|
26
|
+
- |
|
27
|
+
a.rb:8:0: [error] Cannot assign a value of type `::String` to a variable of type `::Integer`
|
28
|
+
│ ::String <: ::Integer
|
29
|
+
│ ::Object <: ::Integer
|
30
|
+
│ ::BasicObject <: ::Integer
|
31
|
+
│
|
32
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
33
|
+
│
|
34
|
+
└ y = "foo"
|
35
|
+
~~~~~~~~~
|
36
|
+
- |
|
37
|
+
a.rb:10:0: [error] Cannot assign a value of type `bool` to a variable of type `::String`
|
38
|
+
│ bool <: ::String
|
39
|
+
│ (true | false) <: ::String
|
40
|
+
│ true <: ::String
|
41
|
+
│ ::TrueClass <: ::String
|
42
|
+
│ ::Object <: ::String
|
43
|
+
│ ::BasicObject <: ::String
|
44
|
+
│
|
45
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
46
|
+
│
|
47
|
+
└ x = true
|
48
|
+
~~~~~~~~
|
49
|
+
- |
|
50
|
+
a.rb:11:0: [error] Cannot assign a value of type `bool` to a variable of type `::Integer`
|
51
|
+
│ bool <: ::Integer
|
52
|
+
│ (true | false) <: ::Integer
|
53
|
+
│ true <: ::Integer
|
54
|
+
│ ::TrueClass <: ::Integer
|
55
|
+
│ ::Object <: ::Integer
|
56
|
+
│ ::BasicObject <: ::Integer
|
57
|
+
│
|
58
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
59
|
+
│
|
60
|
+
└ y = false
|
61
|
+
~~~~~~~~~
|
62
|
+
b.rb:
|
63
|
+
diagnostics:
|
64
|
+
- |
|
65
|
+
b.rb:4:6: [error] Cannot pass a value of type `::Integer` as an argument of type `3`
|
66
|
+
│ ::Integer <: 3
|
67
|
+
│
|
68
|
+
│ Diagnostic ID: Ruby::ArgumentTypeMismatch
|
69
|
+
│
|
70
|
+
└ l.foo(4)
|
71
|
+
~
|
72
|
+
- |
|
73
|
+
b.rb:7:11: [error] Cannot assign a value of type `::Symbol` to an expression of type `:foo`
|
74
|
+
│ ::Symbol <: :foo
|
75
|
+
│
|
76
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
77
|
+
│
|
78
|
+
└ l.bar(foo: :bar)
|
79
|
+
~~~~
|
data/smoke/map/test.yaml
ADDED
data/smoke/method/a.rb
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
# @type method foo: (Integer, y: Integer) -> String
|
2
2
|
|
3
|
-
# !expects MethodBodyTypeMismatch: method=foo, expected=::String, actual=::Integer
|
4
3
|
def foo(x, y:)
|
5
4
|
# @type var z: String
|
6
5
|
|
7
|
-
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
8
6
|
z = x
|
9
7
|
|
10
|
-
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
11
8
|
z = y
|
12
9
|
|
13
10
|
3
|
@@ -15,11 +12,9 @@ end
|
|
15
12
|
|
16
13
|
# @type method bar: (Integer) -> String
|
17
14
|
|
18
|
-
# !expects MethodArityMismatch: method=bar
|
19
15
|
def bar(x, y)
|
20
16
|
# @type var z: String
|
21
17
|
|
22
|
-
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
23
18
|
z = x
|
24
19
|
|
25
20
|
z = y
|