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/lib/steep/version.rb
CHANGED
data/smoke/alias/a.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# @type var x: foo
|
2
2
|
x = ""
|
3
3
|
|
4
|
-
# !expects* UnresolvedOverloading: receiver=(::String | ::Integer), method_name=+,
|
5
4
|
x + 123
|
6
5
|
|
7
6
|
# @type var y: bar
|
@@ -11,9 +10,7 @@ y = []
|
|
11
10
|
# @type var z: Symbol
|
12
11
|
case x
|
13
12
|
when String
|
14
|
-
# !expects IncompatibleAssignment: lhs_type=::Symbol, rhs_type=::String
|
15
13
|
z = x
|
16
14
|
when Integer
|
17
|
-
# !expects IncompatibleAssignment: lhs_type=::Symbol, rhs_type=::Integer
|
18
15
|
z = x
|
19
16
|
end
|
data/smoke/alias/b.rb
CHANGED
data/smoke/alias/c.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
# @type var x: String
|
2
2
|
|
3
|
-
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
4
3
|
x = AliasMethodArg.new.foo(:foo)
|
5
4
|
|
6
5
|
# @type var name: name
|
7
6
|
name = :bar
|
8
7
|
|
9
|
-
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
10
8
|
x = AliasMethodArg.new.foo(name)
|
@@ -0,0 +1,73 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
a.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
a.rb:4:0: [error] Cannot find compatible overloading of method `+` of type `(::String | ::Integer)`
|
7
|
+
│ Method types:
|
8
|
+
│ def +: ((::string & ::Integer)) -> (::String | ::Integer)
|
9
|
+
│ | ((::string & ::Float)) -> (::String | ::Float)
|
10
|
+
│ | ((::string & ::Rational)) -> (::String | ::Rational)
|
11
|
+
│ | ((::string & ::Complex)) -> (::String | ::Complex)
|
12
|
+
│
|
13
|
+
│ Diagnostic ID: Ruby::UnresolvedOverloading
|
14
|
+
│
|
15
|
+
└ x + 123
|
16
|
+
~~~~~~~
|
17
|
+
- |
|
18
|
+
a.rb:13:2: [error] Cannot assign a value of type `::String` to a variable of type `::Symbol`
|
19
|
+
│ ::String <: ::Symbol
|
20
|
+
│ ::Object <: ::Symbol
|
21
|
+
│ ::BasicObject <: ::Symbol
|
22
|
+
│
|
23
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
24
|
+
│
|
25
|
+
└ z = x
|
26
|
+
~~~~~
|
27
|
+
- |
|
28
|
+
a.rb:15:2: [error] Cannot assign a value of type `::Integer` to a variable of type `::Symbol`
|
29
|
+
│ ::Integer <: ::Symbol
|
30
|
+
│ ::Numeric <: ::Symbol
|
31
|
+
│ ::Object <: ::Symbol
|
32
|
+
│ ::BasicObject <: ::Symbol
|
33
|
+
│
|
34
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
35
|
+
│
|
36
|
+
└ z = x
|
37
|
+
~~~~~
|
38
|
+
b.rb:
|
39
|
+
diagnostics:
|
40
|
+
- |
|
41
|
+
b.rb:6:0: [error] Cannot assign a value of type `::String` to a variable of type `::Integer`
|
42
|
+
│ ::String <: ::Integer
|
43
|
+
│ ::Object <: ::Integer
|
44
|
+
│ ::BasicObject <: ::Integer
|
45
|
+
│
|
46
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
47
|
+
│
|
48
|
+
└ x = a[0]
|
49
|
+
~~~~~~~~
|
50
|
+
c.rb:
|
51
|
+
diagnostics:
|
52
|
+
- |
|
53
|
+
c.rb:3:0: [error] Cannot assign a value of type `::Integer` to a variable of type `::String`
|
54
|
+
│ ::Integer <: ::String
|
55
|
+
│ ::Numeric <: ::String
|
56
|
+
│ ::Object <: ::String
|
57
|
+
│ ::BasicObject <: ::String
|
58
|
+
│
|
59
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
60
|
+
│
|
61
|
+
└ x = AliasMethodArg.new.foo(:foo)
|
62
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
63
|
+
- |
|
64
|
+
c.rb:8:0: [error] Cannot assign a value of type `::Integer` to a variable of type `::String`
|
65
|
+
│ ::Integer <: ::String
|
66
|
+
│ ::Numeric <: ::String
|
67
|
+
│ ::Object <: ::String
|
68
|
+
│ ::BasicObject <: ::String
|
69
|
+
│
|
70
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
71
|
+
│
|
72
|
+
└ x = AliasMethodArg.new.foo(name)
|
73
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
data/smoke/and/a.rb
CHANGED
data/smoke/and/test.yaml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
a.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
a.rb:6:0: [error] Cannot assign a value of type `(::String | nil)` to a variable of type `::String`
|
7
|
+
│ (::String | nil) <: ::String
|
8
|
+
│ nil <: ::String
|
9
|
+
│
|
10
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
11
|
+
│
|
12
|
+
└ b = a && a.to_str
|
13
|
+
~~~~~~~~~~~~~~~~~
|
14
|
+
- |
|
15
|
+
a.rb:8:0: [error] Cannot assign a value of type `(::String | nil)` to a variable of type `::Integer`
|
16
|
+
│ (::String | nil) <: ::Integer
|
17
|
+
│ ::String <: ::Integer
|
18
|
+
│ ::Object <: ::Integer
|
19
|
+
│ ::BasicObject <: ::Integer
|
20
|
+
│
|
21
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
22
|
+
│
|
23
|
+
└ c = a && a.to_str
|
24
|
+
~~~~~~~~~~~~~~~~~
|
data/smoke/array/a.rb
CHANGED
@@ -3,19 +3,16 @@
|
|
3
3
|
a = []
|
4
4
|
a[1] = 3
|
5
5
|
|
6
|
-
# !expects* UnresolvedOverloading: receiver=::Array[::Integer], method_name=[]=,
|
7
6
|
a[2] = "foo"
|
8
7
|
|
9
8
|
# @type var i: Integer
|
10
9
|
i = a[0]
|
11
10
|
|
12
11
|
# @type var s: String
|
13
|
-
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=::Integer
|
14
12
|
s = a[1]
|
15
13
|
|
16
14
|
|
17
15
|
b = ["a", "b", "c"]
|
18
16
|
|
19
17
|
s = b[0]
|
20
|
-
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=::String
|
21
18
|
i = b[1]
|
data/smoke/array/b.rb
CHANGED
data/smoke/array/c.rb
CHANGED
@@ -0,0 +1,80 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
a.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
a.rb:6:0: [error] Cannot find compatible overloading of method `[]=` of type `::Array[::Integer]`
|
7
|
+
│ Method types:
|
8
|
+
│ def []=: (::int, ::Integer) -> ::Integer
|
9
|
+
│ | (::int, ::int, ::Integer) -> ::Integer
|
10
|
+
│ | (::int, ::int, ::Array[::Integer]) -> ::Array[::Integer]
|
11
|
+
│ | (::int, ::int, nil) -> nil
|
12
|
+
│ | (::Range[::Integer], ::Integer) -> ::Integer
|
13
|
+
│ | (::Range[::Integer], ::Array[::Integer]) -> ::Array[::Integer]
|
14
|
+
│ | (::Range[::Integer], nil) -> nil
|
15
|
+
│
|
16
|
+
│ Diagnostic ID: Ruby::UnresolvedOverloading
|
17
|
+
│
|
18
|
+
└ a[2] = "foo"
|
19
|
+
~~~~~~~~~~~~
|
20
|
+
- |
|
21
|
+
a.rb:12:0: [error] Cannot assign a value of type `::Integer` to a variable of type `::String`
|
22
|
+
│ ::Integer <: ::String
|
23
|
+
│ ::Numeric <: ::String
|
24
|
+
│ ::Object <: ::String
|
25
|
+
│ ::BasicObject <: ::String
|
26
|
+
│
|
27
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
28
|
+
│
|
29
|
+
└ s = a[1]
|
30
|
+
~~~~~~~~
|
31
|
+
- |
|
32
|
+
a.rb:18:0: [error] Cannot assign a value of type `::String` to a variable of type `::Integer`
|
33
|
+
│ ::String <: ::Integer
|
34
|
+
│ ::Object <: ::Integer
|
35
|
+
│ ::BasicObject <: ::Integer
|
36
|
+
│
|
37
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
38
|
+
│
|
39
|
+
└ i = b[1]
|
40
|
+
~~~~~~~~
|
41
|
+
b.rb:
|
42
|
+
diagnostics:
|
43
|
+
- |
|
44
|
+
b.rb:11:0: [error] Cannot assign a value of type `::Array[::Integer]` to a variable of type `::Array[::String]`
|
45
|
+
│ ::Array[::Integer] <: ::Array[::String]
|
46
|
+
│ ::Integer <: ::String
|
47
|
+
│ ::Numeric <: ::String
|
48
|
+
│ ::Object <: ::String
|
49
|
+
│ ::BasicObject <: ::String
|
50
|
+
│
|
51
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
52
|
+
│
|
53
|
+
└ b = a
|
54
|
+
~~~~~
|
55
|
+
- |
|
56
|
+
b.rb:12:0: [error] Cannot assign a value of type `::Array[::String]` to a variable of type `::Array[::Integer]`
|
57
|
+
│ ::Array[::String] <: ::Array[::Integer]
|
58
|
+
│ ::String <: ::Integer
|
59
|
+
│ ::Object <: ::Integer
|
60
|
+
│ ::BasicObject <: ::Integer
|
61
|
+
│
|
62
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
63
|
+
│
|
64
|
+
└ a = b
|
65
|
+
~~~~~
|
66
|
+
c.rb:
|
67
|
+
diagnostics:
|
68
|
+
- |
|
69
|
+
c.rb:6:0: [error] Cannot assign a value of type `::Array[::Integer]` to a variable of type `::Array[(::String | nil)]`
|
70
|
+
│ ::Array[::Integer] <: ::Array[(::String | nil)]
|
71
|
+
│ ::Integer <: (::String | nil)
|
72
|
+
│ ::Integer <: ::String
|
73
|
+
│ ::Numeric <: ::String
|
74
|
+
│ ::Object <: ::String
|
75
|
+
│ ::BasicObject <: ::String
|
76
|
+
│
|
77
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
78
|
+
│
|
79
|
+
└ x = [1]
|
80
|
+
~~~~~~~
|
data/smoke/block/a.rb
CHANGED
data/smoke/block/b.rb
CHANGED
@@ -2,13 +2,11 @@
|
|
2
2
|
a = (_ = nil)
|
3
3
|
|
4
4
|
a.bar do |x|
|
5
|
-
# !expects BreakTypeMismatch: expected=::Symbol, actual=::Integer
|
6
5
|
break 3
|
7
6
|
end
|
8
7
|
|
9
8
|
# @type var s: ::String
|
10
9
|
|
11
|
-
# !expects IncompatibleAssignment: lhs_type=::String, rhs_type=(::Integer | ::Symbol)
|
12
10
|
s = a.bar do |x|
|
13
11
|
# @type break: ::Integer
|
14
12
|
break 3
|
data/smoke/block/d.rb
CHANGED
@@ -3,13 +3,9 @@ a = -> (x) { x.to_s }
|
|
3
3
|
|
4
4
|
# @type var b: Array[Float]
|
5
5
|
|
6
|
-
# !expects IncompatibleAssignment: lhs_type=::Array[::Float], rhs_type=::Array[::String]
|
7
6
|
b = [1,2,3].map(&a)
|
8
7
|
|
9
|
-
# !expects IncompatibleAssignment: lhs_type=::Array[::Float], rhs_type=::Array[::String]
|
10
8
|
b = [1,2,3].map(&:to_s)
|
11
9
|
|
12
|
-
# !expects* UnresolvedOverloading: receiver=::Array[::Integer], method_name=map,
|
13
10
|
[1,2,3].map(&:no_such_method)
|
14
|
-
# !expects* UnresolvedOverloading: receiver=::Array[::Integer], method_name=map,
|
15
11
|
[1,2,3].map(&:divmod)
|
@@ -0,0 +1,96 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
a.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
a.rb:8: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
|
+
└ s = a.foo
|
15
|
+
~~~~~~~~~
|
16
|
+
- |
|
17
|
+
a.rb:10:0: [error] Cannot assign a value of type `::String` to a variable of type `::Integer`
|
18
|
+
│ ::String <: ::Integer
|
19
|
+
│ ::Object <: ::Integer
|
20
|
+
│ ::BasicObject <: ::Integer
|
21
|
+
│
|
22
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
23
|
+
│
|
24
|
+
└ i = a.foo { nil }
|
25
|
+
~~~~~~~~~~~~~~~~~
|
26
|
+
b.rb:
|
27
|
+
diagnostics:
|
28
|
+
- |
|
29
|
+
b.rb:5:2: [error] Cannot break with a value of type `::Integer` because type `::Symbol` is assumed
|
30
|
+
│ ::Integer <: ::Symbol
|
31
|
+
│ ::Numeric <: ::Symbol
|
32
|
+
│ ::Object <: ::Symbol
|
33
|
+
│ ::BasicObject <: ::Symbol
|
34
|
+
│
|
35
|
+
│ Diagnostic ID: Ruby::BreakTypeMismatch
|
36
|
+
│
|
37
|
+
└ break 3
|
38
|
+
~~~~~~~
|
39
|
+
- |
|
40
|
+
b.rb:10:0: [error] Cannot assign a value of type `(::Integer | ::Symbol)` to a variable of type `::String`
|
41
|
+
│ (::Integer | ::Symbol) <: ::String
|
42
|
+
│ ::Integer <: ::String
|
43
|
+
│ ::Numeric <: ::String
|
44
|
+
│ ::Object <: ::String
|
45
|
+
│ ::BasicObject <: ::String
|
46
|
+
│
|
47
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
48
|
+
│
|
49
|
+
└ s = a.bar do |x|
|
50
|
+
~~~~~~~~~~~~~~~~
|
51
|
+
c.rb:
|
52
|
+
diagnostics: []
|
53
|
+
d.rb:
|
54
|
+
diagnostics:
|
55
|
+
- |
|
56
|
+
d.rb:6:0: [error] Cannot assign a value of type `::Array[::String]` to a variable of type `::Array[::Float]`
|
57
|
+
│ ::Array[::String] <: ::Array[::Float]
|
58
|
+
│ ::String <: ::Float
|
59
|
+
│ ::Object <: ::Float
|
60
|
+
│ ::BasicObject <: ::Float
|
61
|
+
│
|
62
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
63
|
+
│
|
64
|
+
└ b = [1,2,3].map(&a)
|
65
|
+
~~~~~~~~~~~~~~~~~~~
|
66
|
+
- |
|
67
|
+
d.rb:8:0: [error] Cannot assign a value of type `::Array[::String]` to a variable of type `::Array[::Float]`
|
68
|
+
│ ::Array[::String] <: ::Array[::Float]
|
69
|
+
│ ::String <: ::Float
|
70
|
+
│ ::Object <: ::Float
|
71
|
+
│ ::BasicObject <: ::Float
|
72
|
+
│
|
73
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
74
|
+
│
|
75
|
+
└ b = [1,2,3].map(&:to_s)
|
76
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
77
|
+
- |
|
78
|
+
d.rb:10:0: [error] Cannot find compatible overloading of method `map` of type `::Array[::Integer]`
|
79
|
+
│ Method types:
|
80
|
+
│ def map: [U] () { (::Integer) -> U } -> ::Array[U]
|
81
|
+
│ | () -> ::Enumerator[::Integer, ::Array[untyped]]
|
82
|
+
│
|
83
|
+
│ Diagnostic ID: Ruby::UnresolvedOverloading
|
84
|
+
│
|
85
|
+
└ [1,2,3].map(&:no_such_method)
|
86
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
87
|
+
- |
|
88
|
+
d.rb:11:0: [error] Cannot find compatible overloading of method `map` of type `::Array[::Integer]`
|
89
|
+
│ Method types:
|
90
|
+
│ def map: [U] () { (::Integer) -> U } -> ::Array[U]
|
91
|
+
│ | () -> ::Enumerator[::Integer, ::Array[untyped]]
|
92
|
+
│
|
93
|
+
│ Diagnostic ID: Ruby::UnresolvedOverloading
|
94
|
+
│
|
95
|
+
└ [1,2,3].map(&:divmod)
|
96
|
+
~~~~~~~~~~~~~~~~~~~~~
|
Binary file
|
Binary file
|
data/smoke/case/a.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# @type var a: Integer
|
2
2
|
|
3
|
-
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=(::Integer | ::Array[::String] | nil | ::String)
|
4
3
|
a = case 1
|
5
4
|
when 2
|
6
5
|
1
|
@@ -13,9 +12,7 @@ a = case 1
|
|
13
12
|
"string"
|
14
13
|
end
|
15
14
|
|
16
|
-
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=(::Integer | nil)
|
17
15
|
a = case
|
18
|
-
# !expects* UnresolvedOverloading: receiver=::Integer, method_name=+,
|
19
16
|
when 1+"a"
|
20
17
|
30
|
21
18
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
a.rb:
|
4
|
+
diagnostics:
|
5
|
+
- |
|
6
|
+
a.rb:3:0: [error] Cannot assign a value of type `(::Integer | ::Array[::String] | nil | ::String)` to a variable of type `::Integer`
|
7
|
+
│ (::Integer | ::Array[::String] | nil | ::String) <: ::Integer
|
8
|
+
│ ::Array[::String] <: ::Integer
|
9
|
+
│ ::Object <: ::Integer
|
10
|
+
│ ::BasicObject <: ::Integer
|
11
|
+
│
|
12
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
13
|
+
│
|
14
|
+
└ a = case 1
|
15
|
+
~~~~~~~~~~
|
16
|
+
- |
|
17
|
+
a.rb:16:9: [error] Cannot find compatible overloading of method `+` of type `::Integer`
|
18
|
+
│ Method types:
|
19
|
+
│ def +: (::Integer) -> ::Integer
|
20
|
+
│ | (::Float) -> ::Float
|
21
|
+
│ | (::Rational) -> ::Rational
|
22
|
+
│ | (::Complex) -> ::Complex
|
23
|
+
│
|
24
|
+
│ Diagnostic ID: Ruby::UnresolvedOverloading
|
25
|
+
│
|
26
|
+
└ when 1+"a"
|
27
|
+
~~~~~
|
28
|
+
- |
|
29
|
+
a.rb:15:0: [error] Cannot assign a value of type `(::Integer | nil)` to a variable of type `::Integer`
|
30
|
+
│ (::Integer | nil) <: ::Integer
|
31
|
+
│ nil <: ::Integer
|
32
|
+
│
|
33
|
+
│ Diagnostic ID: Ruby::IncompatibleAssignment
|
34
|
+
│
|
35
|
+
└ a = case
|
36
|
+
~~~~~~~~
|