steep 1.0.2 → 1.1.0.pre.1
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 +5 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +22 -3
- data/Gemfile +6 -3
- data/Gemfile.lock +12 -16
- data/Gemfile.steep +3 -0
- data/Gemfile.steep.lock +49 -0
- data/Rakefile +5 -0
- data/Steepfile +6 -1
- data/bin/setup +2 -0
- data/bin/steep +19 -0
- data/lib/steep/ast/types/factory.rb +1 -1
- data/lib/steep/diagnostic/ruby.rb +49 -3
- data/lib/steep/diagnostic/signature.rb +18 -0
- data/lib/steep/drivers/watch.rb +3 -1
- data/lib/steep/method_name.rb +9 -3
- data/lib/steep/node_helper.rb +49 -0
- data/lib/steep/services/completion_provider.rb +22 -15
- data/lib/steep/services/hover_provider/ruby.rb +30 -12
- data/lib/steep/services/type_check_service.rb +12 -12
- data/lib/steep/shims/symbol_start_with.rb +18 -0
- data/lib/steep/signature/validator.rb +19 -0
- data/lib/steep/subtyping/constraints.rb +43 -14
- data/lib/steep/type_construction.rb +666 -746
- data/lib/steep/type_inference/constant_env.rb +0 -2
- data/lib/steep/type_inference/context.rb +23 -17
- data/lib/steep/type_inference/logic_type_interpreter.rb +210 -119
- data/lib/steep/type_inference/method_call.rb +80 -6
- data/lib/steep/type_inference/multiple_assignment.rb +189 -0
- data/lib/steep/type_inference/type_env.rb +271 -120
- data/lib/steep/type_inference/type_env_builder.rb +138 -0
- data/lib/steep/typing.rb +2 -0
- data/lib/steep/version.rb +1 -1
- data/lib/steep.rb +4 -3
- data/rbs_collection.steep.lock.yaml +112 -0
- data/rbs_collection.steep.yaml +19 -0
- data/sample/sig/conference.rbs +8 -0
- data/sig/shims/parser/source/map.rbs +146 -0
- data/sig/shims/parser/source/range.rbs +237 -0
- data/sig/shims/parser.rbs +17 -0
- data/sig/steep/ast/annotation/collection.rbs +75 -0
- data/sig/steep/ast/annotation.rbs +126 -0
- data/sig/steep/ast/builtin.rbs +69 -0
- data/sig/steep/ast/type_params.rbs +11 -0
- data/sig/steep/ast/types/any.rbs +29 -0
- data/sig/steep/ast/types/boolean.rbs +31 -0
- data/sig/steep/ast/types/bot.rbs +29 -0
- data/sig/steep/ast/types/class.rbs +29 -0
- data/sig/steep/ast/types/factory.rbs +76 -0
- data/sig/steep/ast/types/helper.rbs +19 -0
- data/sig/steep/ast/types/instance.rbs +29 -0
- data/sig/steep/ast/types/intersection.rbs +35 -0
- data/sig/steep/ast/types/literal.rbs +33 -0
- data/sig/steep/ast/types/logic.rbs +78 -0
- data/sig/steep/ast/types/name.rbs +71 -0
- data/sig/steep/ast/types/nil.rbs +31 -0
- data/sig/steep/ast/types/proc.rbs +46 -0
- data/sig/steep/ast/types/record.rbs +38 -0
- data/sig/steep/ast/types/self.rbs +29 -0
- data/sig/steep/ast/types/top.rbs +29 -0
- data/sig/steep/ast/types/tuple.rbs +34 -0
- data/sig/steep/ast/types/union.rbs +38 -0
- data/sig/steep/ast/types/var.rbs +37 -0
- data/sig/steep/ast/types/void.rbs +29 -0
- data/sig/steep/ast/types.rbs +37 -0
- data/sig/steep/diagnostic/deprecated/unknown_constant_assigned.rbs +15 -0
- data/sig/steep/diagnostic/helper.rbs +9 -0
- data/sig/steep/diagnostic/lsp_formatter.rbs +29 -0
- data/sig/steep/diagnostic/ruby.rbs +494 -0
- data/sig/steep/diagnostic/signature.rbs +215 -0
- data/sig/steep/interface/block.rbs +35 -0
- data/sig/steep/interface/function.rbs +253 -0
- data/sig/steep/interface/interface.rbs +23 -0
- data/sig/steep/interface/method_type.rbs +55 -0
- data/sig/steep/interface/substitution.rbs +53 -0
- data/sig/steep/interface/type_param.rbs +35 -0
- data/sig/steep/method_name.rbs +26 -0
- data/sig/steep/module_helper.rbs +7 -0
- data/sig/steep/node_helper.rbs +11 -0
- data/sig/steep/project/dsl.rbs +94 -0
- data/sig/steep/project/options.rbs +15 -0
- data/sig/steep/project/pattern.rbs +25 -0
- data/sig/steep/project/target.rbs +25 -0
- data/sig/steep/project.rbs +19 -0
- data/sig/steep/services/completion_provider.rbs +123 -0
- data/sig/steep/services/content_change.rbs +35 -0
- data/sig/steep/services/file_loader.rbs +13 -0
- data/sig/steep/services/goto_service.rbs +45 -0
- data/sig/steep/services/hover_provider/rbs.rbs +21 -0
- data/sig/steep/services/hover_provider/ruby.rbs +109 -0
- data/sig/steep/services/hover_provider/singleton_methods.rbs +11 -0
- data/sig/steep/services/path_assignment.rbs +21 -0
- data/sig/steep/services/signature_service.rbs +91 -0
- data/sig/steep/services/stats_calculator.rbs +17 -0
- data/sig/steep/services/type_check_service.rbs +93 -0
- data/sig/steep/source.rbs +55 -0
- data/sig/steep/subtyping/cache.rbs +17 -0
- data/sig/steep/subtyping/check.rbs +93 -0
- data/sig/steep/subtyping/constraints.rbs +111 -0
- data/sig/steep/subtyping/relation.rbs +51 -0
- data/sig/steep/subtyping/result.rbs +157 -0
- data/sig/steep/subtyping/variable_variance.rbs +23 -0
- data/sig/steep/type_construction.rbs +285 -0
- data/sig/steep/type_inference/block_params.rbs +52 -0
- data/sig/steep/type_inference/constant_env.rbs +27 -0
- data/sig/steep/type_inference/context.rbs +137 -0
- data/sig/steep/type_inference/logic_type_interpreter.rbs +72 -0
- data/sig/steep/type_inference/method_call.rbs +124 -0
- data/sig/steep/type_inference/method_params.rbs +104 -0
- data/sig/steep/type_inference/multiple_assignment.rbs +76 -0
- data/sig/steep/type_inference/type_env.rbs +158 -0
- data/sig/steep/type_inference/type_env_builder.rbs +77 -0
- data/sig/steep/typing.rbs +68 -0
- data/sig/steep.rbs +31 -0
- data/smoke/class/f.rb +1 -0
- data/smoke/class/test_expectations.yml +2 -2
- data/smoke/diagnostics/test_expectations.yml +4 -2
- metadata +90 -6
- data/lib/steep/type_inference/local_variable_type_env.rb +0 -249
- data/lib/steep/type_inference/logic.rb +0 -161
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1094b2c84b950883393bb887dbc8476ba59d911ebee1d358c605e9110bfae8f
|
4
|
+
data.tar.gz: 54fbfd4ea0120bcc45766f530a4c381c9b79c78929a7aa749059d03e69bf7eae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b4d09f5d02029a75099f541e27194f88fcb0eb50fa69fbc6cfa030b7b6ee83873cfff9478a781ff7a12ea94c45ea5c4ca31aed10bf065ce960dbdbf11ebd918
|
7
|
+
data.tar.gz: 8ddfdbdab223a916a6b42715f16df891aed80f107f96c19aa8a53ce8bafa8172888fd992a52bf5d4bba38e2ae8ff7484f1a823586d89e2e267854e84d8fd0222
|
data/.github/workflows/ruby.yml
CHANGED
@@ -11,6 +11,7 @@ jobs:
|
|
11
11
|
strategy:
|
12
12
|
matrix:
|
13
13
|
container_tag:
|
14
|
+
- "2.6"
|
14
15
|
- "2.7"
|
15
16
|
- "3.0"
|
16
17
|
- "3.1"
|
@@ -24,6 +25,10 @@ jobs:
|
|
24
25
|
image: rubylang/ruby:${{ matrix.container_tag }}
|
25
26
|
steps:
|
26
27
|
- uses: actions/checkout@v3
|
28
|
+
- name: Reset bundler
|
29
|
+
run: |
|
30
|
+
rm Gemfile.lock Gemfile.steep.lock
|
31
|
+
if: contains(matrix.container_tag, '2.6')
|
27
32
|
- name: Run test
|
28
33
|
run: |
|
29
34
|
git config --global --add safe.directory /__w/steep/steep
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,11 +2,30 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 1.1.0.pre.1 (2022-07-26)
|
6
|
+
|
7
|
+
### Type checker core
|
8
|
+
|
9
|
+
* Type refinement with method calls ([#590](https://github.com/soutaro/steep/issues/590))
|
10
|
+
* Better multiple assignment type checking ([\#605](https://github.com/soutaro/steep/pull/605))
|
11
|
+
* Fix generics issues around proc types ([\#609](https://github.com/soutaro/steep/pull/609), [\#611](https://github.com/soutaro/steep/pull/611))
|
12
|
+
* Fix type application validation ([#607](https://github.com/soutaro/steep/pull/607); backport from 1.0.2)
|
13
|
+
* Add class variable validation ([\#593](https://github.com/soutaro/steep/pull/593))
|
14
|
+
* Fix type application validation ([\#607](https://github.com/soutaro/steep/pull/607))
|
15
|
+
|
16
|
+
### Commandline tool
|
17
|
+
|
18
|
+
* Appends "done!" to the watch output when the type check is complete ([\#596](https://github.com/soutaro/steep/pull/596))
|
19
|
+
|
20
|
+
### Language server
|
21
|
+
|
22
|
+
* Fix hover on multiple assignment ([\#606](https://github.com/soutaro/steep/pull/606))
|
23
|
+
|
5
24
|
## 1.0.2 (2022-07-19)
|
6
25
|
|
7
26
|
This is another patch release for Steep 1.0.
|
8
27
|
|
9
|
-
### Type checker
|
28
|
+
### Type checker core
|
10
29
|
|
11
30
|
* Fix type application validation ([#607](https://github.com/soutaro/steep/pull/607))
|
12
31
|
|
@@ -16,7 +35,7 @@ This is the first patch release for Steep 1.0.
|
|
16
35
|
However, this release includes one non-trivial type system update, [\#570](https://github.com/soutaro/steep/pull/570), which adds a special typing rule for `Hash#compact` like `Array#compact`.
|
17
36
|
The change will make type checking more permissive and precise, so no new error won't be reported with the fix.
|
18
37
|
|
19
|
-
### Type checker
|
38
|
+
### Type checker core
|
20
39
|
|
21
40
|
* Support shorthand hash for Ruby 3.1 ([\#567](https://github.com/soutaro/steep/pull/567))
|
22
41
|
* Fix super and zsuper with block ([\#568](https://github.com/soutaro/steep/pull/568))
|
@@ -30,7 +49,7 @@ The change will make type checking more permissive and precise, so no new error
|
|
30
49
|
* Type check `gvar` and `gvasgn` in methods([\#579](https://github.com/soutaro/steep/pull/579))
|
31
50
|
* Avoid `UnexpectedError` when assigning untyped singleton class ([\#586](https://github.com/soutaro/steep/pull/586))
|
32
51
|
|
33
|
-
###
|
52
|
+
### Commandline tool
|
34
53
|
|
35
54
|
* Improve Windows support ([\#561](https://github.com/soutaro/steep/pull/561), [\#573](https://github.com/soutaro/steep/pull/573))
|
36
55
|
* Test if `.ruby-version` exists before `rvm do` in binstub ([\#558](https://github.com/soutaro/steep/pull/558))
|
data/Gemfile
CHANGED
@@ -3,9 +3,6 @@ source 'https://rubygems.org'
|
|
3
3
|
# Specify your gem's dependencies in steep.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem "with_steep_types", path: "test/gems/with_steep_types"
|
7
|
-
gem "without_steep_types", path: "test/gems/without_steep_types"
|
8
|
-
|
9
6
|
gem "rake"
|
10
7
|
gem "minitest", "~> 5.16"
|
11
8
|
gem "minitest-hooks"
|
@@ -13,3 +10,9 @@ group :stackprof, optional: true do
|
|
13
10
|
gem "stackprof"
|
14
11
|
end
|
15
12
|
gem 'minitest-slow_test'
|
13
|
+
gem "rbs", "~> 2.5.1"
|
14
|
+
|
15
|
+
group :ide, optional: true do
|
16
|
+
gem "ruby-debug-ide"
|
17
|
+
gem "debase", ">= 0.2.5.beta2"
|
18
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
steep (1.0.
|
4
|
+
steep (1.1.0.pre.1)
|
5
5
|
activesupport (>= 5.1)
|
6
6
|
language_server-protocol (>= 3.15, < 4.0)
|
7
7
|
listen (~> 3.0)
|
@@ -11,16 +11,6 @@ PATH
|
|
11
11
|
rbs (>= 2.3.2)
|
12
12
|
terminal-table (>= 2, < 4)
|
13
13
|
|
14
|
-
PATH
|
15
|
-
remote: test/gems/with_steep_types
|
16
|
-
specs:
|
17
|
-
with_steep_types (1.0.0)
|
18
|
-
|
19
|
-
PATH
|
20
|
-
remote: test/gems/without_steep_types
|
21
|
-
specs:
|
22
|
-
without_steep_types (1.0.0)
|
23
|
-
|
24
14
|
GEM
|
25
15
|
remote: https://rubygems.org/
|
26
16
|
specs:
|
@@ -31,6 +21,9 @@ GEM
|
|
31
21
|
tzinfo (~> 2.0)
|
32
22
|
ast (2.4.2)
|
33
23
|
concurrent-ruby (1.1.10)
|
24
|
+
debase (0.2.5.beta2)
|
25
|
+
debase-ruby_core_source (>= 0.10.12)
|
26
|
+
debase-ruby_core_source (0.10.16)
|
34
27
|
ffi (1.15.5)
|
35
28
|
i18n (1.12.0)
|
36
29
|
concurrent-ruby (~> 1.0)
|
@@ -38,7 +31,7 @@ GEM
|
|
38
31
|
listen (3.7.1)
|
39
32
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
40
33
|
rb-inotify (~> 0.9, >= 0.9.10)
|
41
|
-
minitest (5.16.
|
34
|
+
minitest (5.16.2)
|
42
35
|
minitest-hooks (1.5.0)
|
43
36
|
minitest (> 5.3)
|
44
37
|
minitest-slow_test (0.2.0)
|
@@ -51,11 +44,13 @@ GEM
|
|
51
44
|
rb-fsevent (0.11.1)
|
52
45
|
rb-inotify (0.10.1)
|
53
46
|
ffi (~> 1.0)
|
54
|
-
rbs (2.
|
47
|
+
rbs (2.5.1)
|
48
|
+
ruby-debug-ide (0.7.3)
|
49
|
+
rake (>= 0.8.1)
|
55
50
|
stackprof (0.2.19)
|
56
51
|
terminal-table (3.0.2)
|
57
52
|
unicode-display_width (>= 1.1.1, < 3)
|
58
|
-
tzinfo (2.0.
|
53
|
+
tzinfo (2.0.5)
|
59
54
|
concurrent-ruby (~> 1.0)
|
60
55
|
unicode-display_width (2.2.0)
|
61
56
|
|
@@ -63,14 +58,15 @@ PLATFORMS
|
|
63
58
|
ruby
|
64
59
|
|
65
60
|
DEPENDENCIES
|
61
|
+
debase (>= 0.2.5.beta2)
|
66
62
|
minitest (~> 5.16)
|
67
63
|
minitest-hooks
|
68
64
|
minitest-slow_test
|
69
65
|
rake
|
66
|
+
rbs (~> 2.5.1)
|
67
|
+
ruby-debug-ide
|
70
68
|
stackprof
|
71
69
|
steep!
|
72
|
-
with_steep_types!
|
73
|
-
without_steep_types!
|
74
70
|
|
75
71
|
BUNDLED WITH
|
76
72
|
2.3.8
|
data/Gemfile.steep
ADDED
data/Gemfile.steep.lock
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (7.0.3)
|
5
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
|
+
i18n (>= 1.6, < 2)
|
7
|
+
minitest (>= 5.1)
|
8
|
+
tzinfo (~> 2.0)
|
9
|
+
ast (2.4.2)
|
10
|
+
concurrent-ruby (1.1.10)
|
11
|
+
ffi (1.15.5)
|
12
|
+
i18n (1.10.0)
|
13
|
+
concurrent-ruby (~> 1.0)
|
14
|
+
language_server-protocol (3.16.0.3)
|
15
|
+
listen (3.7.1)
|
16
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
17
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
18
|
+
minitest (5.16.2)
|
19
|
+
parallel (1.22.1)
|
20
|
+
parser (3.1.2.0)
|
21
|
+
ast (~> 2.4.1)
|
22
|
+
rainbow (3.1.1)
|
23
|
+
rb-fsevent (0.11.1)
|
24
|
+
rb-inotify (0.10.1)
|
25
|
+
ffi (~> 1.0)
|
26
|
+
rbs (2.6.0)
|
27
|
+
steep (1.0.1)
|
28
|
+
activesupport (>= 5.1)
|
29
|
+
language_server-protocol (>= 3.15, < 4.0)
|
30
|
+
listen (~> 3.0)
|
31
|
+
parallel (>= 1.0.0)
|
32
|
+
parser (>= 3.1)
|
33
|
+
rainbow (>= 2.2.2, < 4.0)
|
34
|
+
rbs (>= 2.3.2)
|
35
|
+
terminal-table (>= 2, < 4)
|
36
|
+
terminal-table (3.0.2)
|
37
|
+
unicode-display_width (>= 1.1.1, < 3)
|
38
|
+
tzinfo (2.0.4)
|
39
|
+
concurrent-ruby (~> 1.0)
|
40
|
+
unicode-display_width (2.2.0)
|
41
|
+
|
42
|
+
PLATFORMS
|
43
|
+
arm64-darwin-21
|
44
|
+
|
45
|
+
DEPENDENCIES
|
46
|
+
steep
|
47
|
+
|
48
|
+
BUNDLED WITH
|
49
|
+
2.3.15
|
data/Rakefile
CHANGED
data/Steepfile
CHANGED
data/bin/setup
CHANGED
data/bin/steep
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
BINSTUB_DIR=$(cd $(dirname $0); pwd)
|
4
|
+
GEMFILE=$(readlink -f ${BINSTUB_DIR}/../Gemfile.steep)
|
5
|
+
ROOT_DIR=$(readlink -f ${BINSTUB_DIR}/..)
|
6
|
+
|
7
|
+
STEEP="bundle exec --gemfile=${GEMFILE} steep"
|
8
|
+
|
9
|
+
if type "rbenv" > /dev/null 2>&1; then
|
10
|
+
STEEP="rbenv exec ${STEEP}"
|
11
|
+
else
|
12
|
+
if type "rvm" > /dev/null 2>&1; then
|
13
|
+
if [ -e ${ROOT_DIR}/.ruby-version ]; then
|
14
|
+
STEEP="rvm ${ROOT_DIR} do ${STEEP}"
|
15
|
+
fi
|
16
|
+
fi
|
17
|
+
fi
|
18
|
+
|
19
|
+
exec $STEEP $@
|
@@ -7,7 +7,7 @@ module Steep
|
|
7
7
|
attr_reader :node
|
8
8
|
attr_reader :location
|
9
9
|
|
10
|
-
def initialize(node:, location: node
|
10
|
+
def initialize(node:, location: node&.location&.expression)
|
11
11
|
@node = node
|
12
12
|
@location = location
|
13
13
|
end
|
@@ -71,6 +71,8 @@ module Steep
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def header_line
|
74
|
+
node = node() or raise
|
75
|
+
|
74
76
|
element = case node.type
|
75
77
|
when :ivasgn, :lvasgn, :gvasgn, :cvasgn
|
76
78
|
"a variable"
|
@@ -387,6 +389,7 @@ module Steep
|
|
387
389
|
|
388
390
|
class UnexpectedJumpValue < Base
|
389
391
|
def header_line
|
392
|
+
node = node() or raise
|
390
393
|
"The value given to #{node.type} will be ignored"
|
391
394
|
end
|
392
395
|
end
|
@@ -452,7 +455,7 @@ module Steep
|
|
452
455
|
super(node: node)
|
453
456
|
@interface_method = interface_method
|
454
457
|
@annotation_method = annotation_method
|
455
|
-
@result =
|
458
|
+
@result = result
|
456
459
|
end
|
457
460
|
end
|
458
461
|
|
@@ -578,6 +581,32 @@ module Steep
|
|
578
581
|
|
579
582
|
autoload :UnknownConstantAssigned, "steep/diagnostic/deprecated/unknown_constant_assigned"
|
580
583
|
|
584
|
+
class UnknownInstanceVariable < Base
|
585
|
+
attr_reader :name
|
586
|
+
|
587
|
+
def initialize(node:, name:)
|
588
|
+
super(node: node, location: node.loc.name)
|
589
|
+
@name = name
|
590
|
+
end
|
591
|
+
|
592
|
+
def header_line
|
593
|
+
"Cannot find the declaration of instance variable: `#{name}`"
|
594
|
+
end
|
595
|
+
end
|
596
|
+
|
597
|
+
class UnknownGlobalVariable < Base
|
598
|
+
attr_reader :name
|
599
|
+
|
600
|
+
def initialize(node:, name:)
|
601
|
+
super(node: node, location: node.loc.name)
|
602
|
+
@name = name
|
603
|
+
end
|
604
|
+
|
605
|
+
def header_line
|
606
|
+
"Cannot find the declaration of global variable: `#{name}`"
|
607
|
+
end
|
608
|
+
end
|
609
|
+
|
581
610
|
class FallbackAny < Base
|
582
611
|
def initialize(node:)
|
583
612
|
super(node: node)
|
@@ -617,7 +646,7 @@ module Steep
|
|
617
646
|
attr_reader :relation
|
618
647
|
|
619
648
|
def initialize(node:, var_name:, result:, relation:)
|
620
|
-
super(node: node)
|
649
|
+
super(node: node, location: node.location.expression)
|
621
650
|
@var_name = var_name
|
622
651
|
@result = result
|
623
652
|
@relation = relation
|
@@ -688,6 +717,22 @@ module Steep
|
|
688
717
|
end
|
689
718
|
end
|
690
719
|
|
720
|
+
class MultipleAssignmentConversionError < Base
|
721
|
+
attr_reader :original_type, :returned_type
|
722
|
+
|
723
|
+
def initialize(node:, original_type:, returned_type:)
|
724
|
+
super(node: node)
|
725
|
+
|
726
|
+
@node = node
|
727
|
+
@original_type = original_type
|
728
|
+
@returned_type = returned_type
|
729
|
+
end
|
730
|
+
|
731
|
+
def header_line
|
732
|
+
"Cannot convert `#{original_type}` to Array or tuple (`#to_ary` returns `#{returned_type}`)"
|
733
|
+
end
|
734
|
+
end
|
735
|
+
|
691
736
|
class UnsupportedSyntax < Base
|
692
737
|
attr_reader :message
|
693
738
|
|
@@ -700,6 +745,7 @@ module Steep
|
|
700
745
|
if message
|
701
746
|
message
|
702
747
|
else
|
748
|
+
node = node() or raise
|
703
749
|
"Syntax `#{node.type}` is not supported in Steep"
|
704
750
|
end
|
705
751
|
end
|
@@ -264,6 +264,24 @@ module Steep
|
|
264
264
|
end
|
265
265
|
end
|
266
266
|
|
267
|
+
class ClassVariableDuplicationError < Base
|
268
|
+
attr_reader :class_name
|
269
|
+
attr_reader :other_class_name
|
270
|
+
attr_reader :variable_name
|
271
|
+
|
272
|
+
def initialize(class_name:, other_class_name:, variable_name:, location:)
|
273
|
+
super(location: location)
|
274
|
+
|
275
|
+
@class_name = class_name
|
276
|
+
@other_class_name = other_class_name
|
277
|
+
@variable_name = variable_name
|
278
|
+
end
|
279
|
+
|
280
|
+
def header_line
|
281
|
+
"Class variable definition `#{variable_name}` in `#{class_name}` may be overtaken by `#{other_class_name}`"
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
267
285
|
class InstanceVariableTypeError < Base
|
268
286
|
attr_reader :name
|
269
287
|
attr_reader :variable
|
data/lib/steep/drivers/watch.rb
CHANGED
@@ -79,7 +79,7 @@ module Steep
|
|
79
79
|
file_paths = Set.new(dirs.select(&:file?).map(&:realpath))
|
80
80
|
|
81
81
|
listener = Listen.to(*watch_paths.map(&:to_s)) do |modified, added, removed|
|
82
|
-
stdout.
|
82
|
+
stdout.print Rainbow("🔬 Type checking updated files...").bold
|
83
83
|
|
84
84
|
version = Time.now.to_i
|
85
85
|
Steep.logger.tagged "watch" do
|
@@ -112,6 +112,8 @@ module Steep
|
|
112
112
|
end
|
113
113
|
|
114
114
|
client_writer.write(method: "$/typecheck", params: { guid: nil })
|
115
|
+
|
116
|
+
stdout.puts Rainbow("done!").bold
|
115
117
|
end.tap(&:start)
|
116
118
|
|
117
119
|
begin
|
data/lib/steep/method_name.rb
CHANGED
@@ -1,24 +1,30 @@
|
|
1
1
|
module Steep
|
2
|
-
InstanceMethodName = Struct.new(:type_name, :method_name, keyword_init: true) do
|
2
|
+
InstanceMethodName = _ = Struct.new(:type_name, :method_name, keyword_init: true) do
|
3
|
+
# @implements InstanceMethodName
|
3
4
|
def to_s
|
4
5
|
"#{type_name}##{method_name}"
|
5
6
|
end
|
6
7
|
end
|
7
8
|
|
8
|
-
SingletonMethodName = Struct.new(:type_name, :method_name, keyword_init: true) do
|
9
|
+
SingletonMethodName = _ = Struct.new(:type_name, :method_name, keyword_init: true) do
|
10
|
+
# @implements SingletonMethodName
|
9
11
|
def to_s
|
10
12
|
"#{type_name}.#{method_name}"
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
14
|
-
|
16
|
+
class ::Object
|
15
17
|
def MethodName(string)
|
16
18
|
case string
|
17
19
|
when /#/
|
18
20
|
type_name, method_name = string.split(/#/, 2)
|
21
|
+
type_name or raise
|
22
|
+
method_name or raise
|
19
23
|
InstanceMethodName.new(type_name: TypeName(type_name), method_name: method_name.to_sym)
|
20
24
|
when /\./
|
21
25
|
type_name, method_name = string.split(/\./, 2)
|
26
|
+
type_name or raise
|
27
|
+
method_name or raise
|
22
28
|
SingletonMethodName.new(type_name: TypeName(type_name), method_name: method_name.to_sym)
|
23
29
|
else
|
24
30
|
raise "Unexpected method name: #{string}"
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Steep
|
2
|
+
module NodeHelper
|
3
|
+
def each_child_node(node, &block)
|
4
|
+
if block
|
5
|
+
node.children.each do |child|
|
6
|
+
if child.is_a?(Parser::AST::Node)
|
7
|
+
yield child
|
8
|
+
end
|
9
|
+
end
|
10
|
+
else
|
11
|
+
enum_for :each_child_node, node
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def each_descendant_node(node, &block)
|
16
|
+
if block
|
17
|
+
each_child_node(node) do |child|
|
18
|
+
yield child
|
19
|
+
each_descendant_node(child, &block)
|
20
|
+
end
|
21
|
+
else
|
22
|
+
enum_for :each_descendant_node, node
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def value_node?(node)
|
27
|
+
case node.type
|
28
|
+
when :true, :false, :str, :sym, :int, :float, :nil
|
29
|
+
true
|
30
|
+
when :lvar
|
31
|
+
true
|
32
|
+
when :const
|
33
|
+
each_child_node(node).all? {|child| child.type == :cbase || value_node?(child) }
|
34
|
+
when :array
|
35
|
+
each_child_node(node).all? {|child| value_node?(child) }
|
36
|
+
when :hash
|
37
|
+
each_child_node(node).all? do |pair|
|
38
|
+
each_child_node(pair).all? {|child| value_node?(child) }
|
39
|
+
end
|
40
|
+
when :dstr
|
41
|
+
each_child_node(node).all? {|child| value_node?(child)}
|
42
|
+
when :begin
|
43
|
+
each_child_node(node).all? {|child| value_node?(node) }
|
44
|
+
else
|
45
|
+
false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,16 +1,20 @@
|
|
1
1
|
module Steep
|
2
2
|
module Services
|
3
3
|
class CompletionProvider
|
4
|
-
Position = Struct.new(:line, :column, keyword_init: true) do
|
4
|
+
Position = _ = Struct.new(:line, :column, keyword_init: true) do
|
5
|
+
# @implements Position
|
5
6
|
def -(size)
|
6
7
|
Position.new(line: line, column: column - size)
|
7
8
|
end
|
8
9
|
end
|
9
|
-
Range = Struct.new(:start, :end, keyword_init: true)
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
Range = _ = Struct.new(:start, :end, keyword_init: true)
|
12
|
+
|
13
|
+
InstanceVariableItem = _ = Struct.new(:identifier, :range, :type, keyword_init: true)
|
14
|
+
LocalVariableItem = _ = Struct.new(:identifier, :range, :type, keyword_init: true)
|
15
|
+
ConstantItem = _ = Struct.new(:env, :identifier, :range, :type, :full_name, keyword_init: true) do
|
16
|
+
# @implements ConstantItem
|
17
|
+
|
14
18
|
def class?
|
15
19
|
if decl = env.class_decls[full_name]
|
16
20
|
decl.primary.decl.is_a?(RBS::AST::Declarations::Class)
|
@@ -34,20 +38,23 @@ module Steep
|
|
34
38
|
end
|
35
39
|
end
|
36
40
|
end
|
37
|
-
MethodNameItem = Struct.new(:identifier, :range, :receiver_type, :method_type, :method_decls, keyword_init: true) do
|
41
|
+
MethodNameItem = _ = Struct.new(:identifier, :range, :receiver_type, :method_type, :method_decls, keyword_init: true) do
|
42
|
+
# @implements MethodNameItem
|
43
|
+
|
38
44
|
def comment
|
39
45
|
case method_decls.size
|
40
46
|
when 0
|
41
47
|
nil
|
42
48
|
when 1
|
43
|
-
method_decls.to_a.first
|
49
|
+
method = method_decls.to_a.first or raise
|
50
|
+
method.method_def&.comment
|
44
51
|
else
|
45
52
|
nil
|
46
53
|
end
|
47
54
|
end
|
48
55
|
|
49
56
|
def inherited?
|
50
|
-
case receiver_type
|
57
|
+
case receiver_type = receiver_type()
|
51
58
|
when AST::Types::Name::Instance, AST::Types::Name::Singleton, AST::Types::Name::Interface
|
52
59
|
method_decls.any? do |decl|
|
53
60
|
decl.method_name.type_name != receiver_type.name
|
@@ -365,11 +372,11 @@ module Steep
|
|
365
372
|
|
366
373
|
def local_variable_items_for_context(context, position:, prefix:, items:)
|
367
374
|
range = range_for(position, prefix: prefix)
|
368
|
-
context.
|
375
|
+
context.type_env.local_variable_types.each do |name, pair|
|
376
|
+
type, _ = pair
|
377
|
+
|
369
378
|
if name.to_s.start_with?(prefix)
|
370
|
-
items << LocalVariableItem.new(identifier: name,
|
371
|
-
range: range,
|
372
|
-
type: type)
|
379
|
+
items << LocalVariableItem.new(identifier: name, range: range, type: type)
|
373
380
|
end
|
374
381
|
end
|
375
382
|
end
|
@@ -381,10 +388,10 @@ module Steep
|
|
381
388
|
case parent.type
|
382
389
|
when :const
|
383
390
|
const_name = typing.source_index.reference(constant_node: parent)
|
384
|
-
consts = context.
|
391
|
+
consts = context.type_env.constant_env.children(const_name)
|
385
392
|
end
|
386
393
|
else
|
387
|
-
consts = context.
|
394
|
+
consts = context.type_env.constant_env.constants
|
388
395
|
end
|
389
396
|
|
390
397
|
if consts
|
@@ -400,7 +407,7 @@ module Steep
|
|
400
407
|
|
401
408
|
def instance_variable_items_for_context(context, position:, prefix:, items:)
|
402
409
|
range = range_for(position, prefix: prefix)
|
403
|
-
context.type_env.
|
410
|
+
context.type_env.instance_variable_types.each do |name, type|
|
404
411
|
if name.to_s.start_with?(prefix)
|
405
412
|
items << InstanceVariableItem.new(identifier: name,
|
406
413
|
range: range,
|