steep 1.3.0 → 1.4.0.dev.2
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-windows.yml +1 -0
- data/.github/workflows/ruby.yml +1 -5
- data/Gemfile +3 -1
- data/Gemfile.lock +22 -19
- data/Gemfile.steep +2 -1
- data/Gemfile.steep.lock +18 -14
- data/Steepfile +16 -0
- data/bin/rbs +21 -0
- data/bin/setup +1 -1
- data/lib/steep/annotation_parser.rb +40 -20
- data/lib/steep/ast/types/factory.rb +56 -10
- data/lib/steep/ast/types/name.rb +10 -0
- data/lib/steep/diagnostic/ruby.rb +1 -1
- data/lib/steep/diagnostic/signature.rb +40 -0
- data/lib/steep/index/rbs_index.rb +25 -9
- data/lib/steep/index/signature_symbol_provider.rb +1 -1
- data/lib/steep/project/dsl.rb +12 -4
- data/lib/steep/project/options.rb +3 -1
- data/lib/steep/project/target.rb +1 -3
- data/lib/steep/server/interaction_worker.rb +37 -20
- data/lib/steep/server/lsp_formatter.rb +14 -5
- data/lib/steep/services/completion_provider.rb +10 -12
- data/lib/steep/services/goto_service.rb +15 -14
- data/lib/steep/services/hover_provider/rbs.rb +29 -9
- data/lib/steep/services/hover_provider/ruby.rb +16 -10
- data/lib/steep/services/signature_service.rb +36 -39
- data/lib/steep/signature/validator.rb +28 -6
- data/lib/steep/subtyping/check.rb +1 -1
- data/lib/steep/type_construction.rb +16 -14
- data/lib/steep/type_inference/constant_env.rb +7 -3
- data/lib/steep/version.rb +1 -1
- data/rbs_collection.steep.lock.yaml +48 -51
- data/rbs_collection.steep.yaml +3 -1
- data/sample/lib/conference.rb +10 -0
- data/sample/sig/conference.rbs +23 -0
- data/sig/steep/annotation_parser.rbs +3 -2
- data/sig/steep/ast/annotation/collection.rbs +1 -1
- data/sig/steep/ast/types/factory.rbs +2 -0
- data/sig/steep/ast/types/name.rbs +4 -0
- data/sig/steep/diagnostic/signature.rbs +18 -14
- data/sig/steep/index/rbs_index.rbs +92 -42
- data/sig/steep/project/dsl.rbs +35 -30
- data/sig/steep/project/options.rbs +16 -4
- data/sig/steep/project/target.rbs +7 -7
- data/sig/steep/server/interaction_worker.rbs +2 -2
- data/sig/steep/server/lsp_formatter.rbs +4 -2
- data/sig/steep/services/completion_provider.rbs +6 -0
- data/sig/steep/services/hover_provider/rbs.rbs +6 -4
- data/sig/steep/services/hover_provider/ruby.rbs +8 -4
- data/sig/steep/services/signature_service.rbs +27 -3
- data/sig/steep/signature/validator.rbs +9 -5
- data/sig/steep/type_construction.rbs +1 -1
- data/sig/steep/type_inference/constant_env.rbs +2 -0
- data/smoke/diagnostics-rbs/test_expectations.yml +1 -1
- data/smoke/regexp/a.rb +2 -2
- data/steep.gemspec +2 -1
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14e9c57b89791ad6d989bddd6439f1ce792ceccf8e17034a1f2ab56c85f2ca41
|
4
|
+
data.tar.gz: dfbe3445dcc72a84a2d4d4e608eb5d74e9da4e1cef03f4979a44e377bf65a917
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c14673012d5db258399c4f5d7bda6e3fb6aaca0dbc5c241efca52f8c4e947a5a4fd1a60a42ce6a45e87642926b6e44f65d6058bb241581e5a143251a158f383f
|
7
|
+
data.tar.gz: '0889651d16f198063b243aef34cb300325fb04dcbb7165f0d8c972d7f0f2076d86af77393c8c3f0f216d1a42f6fa8bd2c4cbf78d3e0c106d8c7f883d96099839'
|
data/.github/workflows/ruby.yml
CHANGED
@@ -11,10 +11,10 @@ jobs:
|
|
11
11
|
strategy:
|
12
12
|
matrix:
|
13
13
|
container_tag:
|
14
|
-
- "2.6"
|
15
14
|
- "2.7"
|
16
15
|
- "3.0"
|
17
16
|
- "3.1"
|
17
|
+
- "3.2"
|
18
18
|
- "master-nightly-focal"
|
19
19
|
task:
|
20
20
|
- test
|
@@ -25,10 +25,6 @@ jobs:
|
|
25
25
|
image: rubylang/ruby:${{ matrix.container_tag }}
|
26
26
|
steps:
|
27
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')
|
32
28
|
- name: Run test
|
33
29
|
run: |
|
34
30
|
git config --global --add safe.directory /__w/steep/steep
|
data/Gemfile
CHANGED
@@ -3,8 +3,10 @@ source 'https://rubygems.org'
|
|
3
3
|
# Specify your gem's dependencies in steep.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
+
gem "rbs", "~> 3.0.0"
|
7
|
+
|
6
8
|
gem "rake"
|
7
|
-
gem "minitest", "~> 5.
|
9
|
+
gem "minitest", "~> 5.17"
|
8
10
|
gem "minitest-hooks"
|
9
11
|
group :stackprof, optional: true do
|
10
12
|
gem "stackprof"
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
steep (1.
|
4
|
+
steep (1.4.0.dev.2)
|
5
5
|
activesupport (>= 5.1)
|
6
6
|
csv (>= 3.0.9)
|
7
7
|
fileutils (>= 1.1.0)
|
@@ -11,6 +11,7 @@ PATH
|
|
11
11
|
logger (>= 1.3.0)
|
12
12
|
parallel (>= 1.0.0)
|
13
13
|
parser (>= 3.1)
|
14
|
+
pathname (>= 0.2.1)
|
14
15
|
rainbow (>= 2.2.2, < 4.0)
|
15
16
|
rbs (>= 2.8.0)
|
16
17
|
securerandom (>= 0.1)
|
@@ -20,61 +21,63 @@ PATH
|
|
20
21
|
GEM
|
21
22
|
remote: https://rubygems.org/
|
22
23
|
specs:
|
23
|
-
activesupport (7.0.4)
|
24
|
+
activesupport (7.0.4.2)
|
24
25
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
25
26
|
i18n (>= 1.6, < 2)
|
26
27
|
minitest (>= 5.1)
|
27
28
|
tzinfo (~> 2.0)
|
28
29
|
ast (2.4.2)
|
29
|
-
concurrent-ruby (1.
|
30
|
-
csv (3.2.
|
30
|
+
concurrent-ruby (1.2.2)
|
31
|
+
csv (3.2.6)
|
31
32
|
debase (0.2.5.beta2)
|
32
33
|
debase-ruby_core_source (>= 0.10.12)
|
33
|
-
debase-ruby_core_source (
|
34
|
+
debase-ruby_core_source (3.2.0)
|
34
35
|
ffi (1.15.5)
|
35
|
-
fileutils (1.
|
36
|
+
fileutils (1.7.0)
|
36
37
|
i18n (1.12.0)
|
37
38
|
concurrent-ruby (~> 1.0)
|
38
|
-
json (2.6.
|
39
|
-
language_server-protocol (3.17.0.
|
40
|
-
listen (3.
|
39
|
+
json (2.6.3)
|
40
|
+
language_server-protocol (3.17.0.3)
|
41
|
+
listen (3.8.0)
|
41
42
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
42
43
|
rb-inotify (~> 0.9, >= 0.9.10)
|
43
|
-
logger (1.5.
|
44
|
-
minitest (5.
|
44
|
+
logger (1.5.3)
|
45
|
+
minitest (5.17.0)
|
45
46
|
minitest-hooks (1.5.0)
|
46
47
|
minitest (> 5.3)
|
47
48
|
minitest-slow_test (0.2.0)
|
48
49
|
minitest (>= 5.0)
|
49
50
|
parallel (1.22.1)
|
50
|
-
parser (3.
|
51
|
+
parser (3.2.1.0)
|
51
52
|
ast (~> 2.4.1)
|
53
|
+
pathname (0.2.1)
|
52
54
|
rainbow (3.1.1)
|
53
55
|
rake (13.0.6)
|
54
56
|
rb-fsevent (0.11.2)
|
55
57
|
rb-inotify (0.10.1)
|
56
58
|
ffi (~> 1.0)
|
57
|
-
rbs (
|
59
|
+
rbs (3.0.1)
|
58
60
|
ruby-debug-ide (0.7.3)
|
59
61
|
rake (>= 0.8.1)
|
60
|
-
securerandom (0.2.
|
61
|
-
stackprof (0.2.
|
62
|
-
strscan (3.0.
|
62
|
+
securerandom (0.2.2)
|
63
|
+
stackprof (0.2.23)
|
64
|
+
strscan (3.0.6)
|
63
65
|
terminal-table (3.0.2)
|
64
66
|
unicode-display_width (>= 1.1.1, < 3)
|
65
|
-
tzinfo (2.0.
|
67
|
+
tzinfo (2.0.6)
|
66
68
|
concurrent-ruby (~> 1.0)
|
67
|
-
unicode-display_width (2.
|
69
|
+
unicode-display_width (2.4.2)
|
68
70
|
|
69
71
|
PLATFORMS
|
70
72
|
ruby
|
71
73
|
|
72
74
|
DEPENDENCIES
|
73
75
|
debase (>= 0.2.5.beta2)
|
74
|
-
minitest (~> 5.
|
76
|
+
minitest (~> 5.17)
|
75
77
|
minitest-hooks
|
76
78
|
minitest-slow_test
|
77
79
|
rake
|
80
|
+
rbs (~> 3.0.0)
|
78
81
|
ruby-debug-ide
|
79
82
|
stackprof
|
80
83
|
steep!
|
data/Gemfile.steep
CHANGED
data/Gemfile.steep.lock
CHANGED
@@ -8,28 +8,29 @@ GEM
|
|
8
8
|
tzinfo (~> 2.0)
|
9
9
|
ast (2.4.2)
|
10
10
|
concurrent-ruby (1.1.10)
|
11
|
-
csv (3.2.
|
11
|
+
csv (3.2.6)
|
12
12
|
ffi (1.15.5)
|
13
|
-
fileutils (1.
|
13
|
+
fileutils (1.7.0)
|
14
14
|
i18n (1.12.0)
|
15
15
|
concurrent-ruby (~> 1.0)
|
16
|
-
json (2.6.
|
17
|
-
language_server-protocol (3.17.0.
|
16
|
+
json (2.6.3)
|
17
|
+
language_server-protocol (3.17.0.2)
|
18
18
|
listen (3.7.1)
|
19
19
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
20
20
|
rb-inotify (~> 0.9, >= 0.9.10)
|
21
|
-
logger (1.5.
|
22
|
-
minitest (5.
|
21
|
+
logger (1.5.3)
|
22
|
+
minitest (5.17.0)
|
23
23
|
parallel (1.22.1)
|
24
|
-
parser (3.
|
24
|
+
parser (3.2.0.0)
|
25
25
|
ast (~> 2.4.1)
|
26
|
+
pathname (0.2.1)
|
26
27
|
rainbow (3.1.1)
|
27
28
|
rb-fsevent (0.11.2)
|
28
29
|
rb-inotify (0.10.1)
|
29
30
|
ffi (~> 1.0)
|
30
|
-
rbs (
|
31
|
-
securerandom (0.2.
|
32
|
-
steep (1.
|
31
|
+
rbs (3.0.0.dev.1)
|
32
|
+
securerandom (0.2.2)
|
33
|
+
steep (1.4.0.dev.1)
|
33
34
|
activesupport (>= 5.1)
|
34
35
|
csv (>= 3.0.9)
|
35
36
|
fileutils (>= 1.1.0)
|
@@ -39,23 +40,26 @@ GEM
|
|
39
40
|
logger (>= 1.3.0)
|
40
41
|
parallel (>= 1.0.0)
|
41
42
|
parser (>= 3.1)
|
43
|
+
pathname (>= 0.2.1)
|
42
44
|
rainbow (>= 2.2.2, < 4.0)
|
43
|
-
rbs (>= 2.8.0
|
45
|
+
rbs (>= 2.8.0)
|
44
46
|
securerandom (>= 0.1)
|
45
47
|
strscan (>= 1.0.0)
|
46
48
|
terminal-table (>= 2, < 4)
|
47
|
-
strscan (3.0.
|
49
|
+
strscan (3.0.5)
|
48
50
|
terminal-table (3.0.2)
|
49
51
|
unicode-display_width (>= 1.1.1, < 3)
|
50
52
|
tzinfo (2.0.5)
|
51
53
|
concurrent-ruby (~> 1.0)
|
52
|
-
unicode-display_width (2.
|
54
|
+
unicode-display_width (2.4.2)
|
53
55
|
|
54
56
|
PLATFORMS
|
55
57
|
arm64-darwin-21
|
58
|
+
arm64-darwin-22
|
56
59
|
|
57
60
|
DEPENDENCIES
|
58
|
-
|
61
|
+
rbs (~> 3.0.0.dev)
|
62
|
+
steep (~> 1.4.0.dev)
|
59
63
|
|
60
64
|
BUNDLED WITH
|
61
65
|
2.3.15
|
data/Steepfile
CHANGED
@@ -10,7 +10,23 @@ target :app do
|
|
10
10
|
hash[D::Ruby::MethodDefinitionMissing] = :hint
|
11
11
|
end
|
12
12
|
|
13
|
+
FileUtils.mkpath("tmp")
|
14
|
+
tmp_rbs_dir = File.join("tmp", "rbs-sig")
|
15
|
+
|
16
|
+
definition = Bundler::Definition.build(Pathname("Gemfile"), Pathname("Gemfile.lock"), nil)
|
17
|
+
rbs_dep = definition.dependencies.find {|dep| dep.name == "rbs" }
|
18
|
+
if (source = rbs_dep.source).is_a?(Bundler::Source::Path)
|
19
|
+
unless Pathname(tmp_rbs_dir).exist?
|
20
|
+
FileUtils.ln_s(Pathname.pwd + source.path + "sig", tmp_rbs_dir, force: true)
|
21
|
+
end
|
22
|
+
signature tmp_rbs_dir
|
23
|
+
else
|
24
|
+
FileUtils.rm_f(tmp_rbs_dir)
|
25
|
+
library "rbs"
|
26
|
+
end
|
27
|
+
|
13
28
|
library(
|
29
|
+
"rdoc",
|
14
30
|
"set",
|
15
31
|
"pathname",
|
16
32
|
"monitor",
|
data/bin/rbs
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
BINSTUB_DIR=$(cd $(dirname $0); pwd)
|
4
|
+
GEMFILE=$(readlink -f ${BINSTUB_DIR}/../Gemfile.steep)
|
5
|
+
COLLECTION=$(readlink -f ${BINSTUB_DIR}/../rbs_collection.steep.yaml)
|
6
|
+
ROOT_DIR=$(readlink -f ${BINSTUB_DIR}/..)
|
7
|
+
|
8
|
+
RBS="bundle exec --gemfile=${GEMFILE} rbs --collection=${COLLECTION}"
|
9
|
+
|
10
|
+
if type "rbenv" > /dev/null 2>&1; then
|
11
|
+
RBS="rbenv exec ${RBS}"
|
12
|
+
else
|
13
|
+
if type "rvm" > /dev/null 2>&1; then
|
14
|
+
if [ -e ${ROOT_DIR}/.ruby-version ]; then
|
15
|
+
RBS="rvm ${ROOT_DIR} do ${RBS}"
|
16
|
+
fi
|
17
|
+
fi
|
18
|
+
fi
|
19
|
+
|
20
|
+
exec $RBS $@
|
21
|
+
|
data/bin/setup
CHANGED
@@ -20,16 +20,19 @@ module Steep
|
|
20
20
|
attr_reader :source
|
21
21
|
attr_reader :location
|
22
22
|
|
23
|
-
def initialize(source:, location:, exn: nil)
|
23
|
+
def initialize(source:, location:, exn: nil, message: nil)
|
24
24
|
@source = source
|
25
25
|
@location = location
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
if exn
|
28
|
+
message =
|
29
|
+
case exn
|
30
|
+
when RBS::ParsingError
|
31
|
+
Diagnostic::Signature::SyntaxError.parser_syntax_error_message(exn)
|
32
|
+
else
|
33
|
+
exn.message
|
34
|
+
end
|
35
|
+
end
|
33
36
|
|
34
37
|
super message
|
35
38
|
end
|
@@ -41,8 +44,25 @@ module Steep
|
|
41
44
|
PARAM = /[A-Z][A-Za-z0-9_]*/
|
42
45
|
TYPE_PARAMS = /(\[(?<params>#{PARAM}(,\s*#{PARAM})*)\])?/
|
43
46
|
|
44
|
-
def parse_type(
|
45
|
-
|
47
|
+
def parse_type(match, name = :type, location:)
|
48
|
+
string = match[name] or raise
|
49
|
+
st, en = match.offset(name)
|
50
|
+
st or raise
|
51
|
+
en or raise
|
52
|
+
loc = RBS::Location.new(location.buffer, location.start_pos + st, location.start_pos + en)
|
53
|
+
|
54
|
+
type =
|
55
|
+
begin
|
56
|
+
RBS::Parser.parse_type(string)
|
57
|
+
rescue RBS::ParsingError => exn
|
58
|
+
raise SyntaxError.new(source: string, location: loc, exn: exn)
|
59
|
+
end or raise
|
60
|
+
|
61
|
+
unless (type.location || raise).source == string.strip
|
62
|
+
raise SyntaxError.new(source: string, location: loc, message: "Failed to parse a type in annotation")
|
63
|
+
end
|
64
|
+
|
65
|
+
factory.type(type)
|
46
66
|
end
|
47
67
|
|
48
68
|
def keyword_subject_type(keyword, name)
|
@@ -59,10 +79,9 @@ module Steep
|
|
59
79
|
Regexp.last_match.yield_self do |match|
|
60
80
|
match or raise
|
61
81
|
name = match[:name] or raise
|
62
|
-
type = match[:type] or raise
|
63
82
|
|
64
83
|
AST::Annotation::VarType.new(name: name.to_sym,
|
65
|
-
type: parse_type(
|
84
|
+
type: parse_type(match, location: location),
|
66
85
|
location: location)
|
67
86
|
end
|
68
87
|
|
@@ -72,7 +91,7 @@ module Steep
|
|
72
91
|
name = match[:name] or raise
|
73
92
|
type = match[:type] or raise
|
74
93
|
|
75
|
-
method_type = factory.method_type(RBS::Parser.parse_method_type(type), method_decls: Set[])
|
94
|
+
method_type = factory.method_type(RBS::Parser.parse_method_type(type) || raise, method_decls: Set[])
|
76
95
|
|
77
96
|
AST::Annotation::MethodType.new(name: name.to_sym,
|
78
97
|
type: method_type,
|
@@ -83,7 +102,7 @@ module Steep
|
|
83
102
|
Regexp.last_match.yield_self do |match|
|
84
103
|
match or raise
|
85
104
|
name = match[:name] or raise
|
86
|
-
type = parse_type(match
|
105
|
+
type = parse_type(match, location: location)
|
87
106
|
|
88
107
|
AST::Annotation::ConstType.new(name: TypeName(name), type: type, location: location)
|
89
108
|
end
|
@@ -92,7 +111,7 @@ module Steep
|
|
92
111
|
Regexp.last_match.yield_self do |match|
|
93
112
|
match or raise
|
94
113
|
name = match[:name] or raise
|
95
|
-
type = parse_type(match
|
114
|
+
type = parse_type(match, location: location)
|
96
115
|
|
97
116
|
AST::Annotation::IvarType.new(name: name.to_sym,
|
98
117
|
type: type,
|
@@ -102,42 +121,43 @@ module Steep
|
|
102
121
|
when keyword_and_type("return")
|
103
122
|
Regexp.last_match.yield_self do |match|
|
104
123
|
match or raise
|
105
|
-
type = parse_type(match
|
124
|
+
type = parse_type(match, location: location)
|
106
125
|
AST::Annotation::ReturnType.new(type: type, location: location)
|
107
126
|
end
|
108
127
|
|
109
128
|
when keyword_and_type("block")
|
110
129
|
Regexp.last_match.yield_self do |match|
|
111
130
|
match or raise
|
112
|
-
type = parse_type(match
|
131
|
+
type = parse_type(match, location: location)
|
113
132
|
AST::Annotation::BlockType.new(type: type, location: location)
|
114
133
|
end
|
115
134
|
|
116
135
|
when keyword_and_type("self")
|
117
136
|
Regexp.last_match.yield_self do |match|
|
118
137
|
match or raise
|
119
|
-
type = parse_type(match
|
138
|
+
type = parse_type(match, location: location)
|
120
139
|
AST::Annotation::SelfType.new(type: type, location: location)
|
121
140
|
end
|
122
141
|
|
123
142
|
when keyword_and_type("instance")
|
124
143
|
Regexp.last_match.yield_self do |match|
|
125
144
|
match or raise
|
126
|
-
type = parse_type(match
|
145
|
+
type = parse_type(match, location: location)
|
127
146
|
AST::Annotation::InstanceType.new(type: type, location: location)
|
128
147
|
end
|
129
148
|
|
130
149
|
when keyword_and_type("module")
|
131
150
|
Regexp.last_match.yield_self do |match|
|
132
151
|
match or raise
|
133
|
-
type = parse_type(match
|
152
|
+
type = parse_type(match, location: location)
|
134
153
|
AST::Annotation::ModuleType.new(type: type, location: location)
|
135
154
|
end
|
136
155
|
|
137
156
|
when keyword_and_type("break")
|
138
157
|
Regexp.last_match.yield_self do |match|
|
139
158
|
match or raise
|
140
|
-
type = parse_type(match
|
159
|
+
type = parse_type(match, location: location)
|
160
|
+
|
141
161
|
AST::Annotation::BreakType.new(type: type, location: location)
|
142
162
|
end
|
143
163
|
|
@@ -370,19 +370,11 @@ module Steep
|
|
370
370
|
end
|
371
371
|
|
372
372
|
def module_name?(type_name)
|
373
|
-
|
374
|
-
entry.is_a?(RBS::Environment::ModuleEntry)
|
375
|
-
else
|
376
|
-
false
|
377
|
-
end
|
373
|
+
env.module_entry(type_name) ? true : false
|
378
374
|
end
|
379
375
|
|
380
376
|
def class_name?(type_name)
|
381
|
-
|
382
|
-
entry.is_a?(RBS::Environment::ClassEntry)
|
383
|
-
else
|
384
|
-
false
|
385
|
-
end
|
377
|
+
env.class_entry(type_name) ? true : false
|
386
378
|
end
|
387
379
|
|
388
380
|
def env
|
@@ -434,6 +426,60 @@ module Steep
|
|
434
426
|
nil
|
435
427
|
end
|
436
428
|
end
|
429
|
+
|
430
|
+
def normalize_type(type)
|
431
|
+
case type
|
432
|
+
when AST::Types::Name::Instance
|
433
|
+
AST::Types::Name::Instance.new(
|
434
|
+
name: env.normalize_module_name(type.name),
|
435
|
+
args: type.args.map {|ty| normalize_type(ty) },
|
436
|
+
location: type.location
|
437
|
+
)
|
438
|
+
when AST::Types::Name::Singleton
|
439
|
+
AST::Types::Name::Singleton.new(
|
440
|
+
name: env.normalize_module_name(type.name),
|
441
|
+
location: type.location
|
442
|
+
)
|
443
|
+
when AST::Types::Any, AST::Types::Boolean, AST::Types::Bot, AST::Types::Nil,
|
444
|
+
AST::Types::Top, AST::Types::Void, AST::Types::Literal, AST::Types::Class, AST::Types::Instance,
|
445
|
+
AST::Types::Self, AST::Types::Var, AST::Types::Logic::Base
|
446
|
+
type
|
447
|
+
when AST::Types::Intersection
|
448
|
+
AST::Types::Intersection.build(
|
449
|
+
types: type.types.map {|type| normalize_type(type) },
|
450
|
+
location: type.location
|
451
|
+
)
|
452
|
+
when AST::Types::Union
|
453
|
+
AST::Types::Union.build(
|
454
|
+
types: type.types.map {|type| normalize_type(type) },
|
455
|
+
location: type.location
|
456
|
+
)
|
457
|
+
when AST::Types::Record
|
458
|
+
AST::Types::Record.new(
|
459
|
+
elements: type.elements.transform_values {|type| normalize_type(type) },
|
460
|
+
location: type.location
|
461
|
+
)
|
462
|
+
when AST::Types::Tuple
|
463
|
+
AST::Types::Tuple.new(
|
464
|
+
types: type.types.map {|type| normalize_type(type) },
|
465
|
+
location: type.location
|
466
|
+
)
|
467
|
+
when AST::Types::Proc
|
468
|
+
type.map_type {|type| normalize_type(type) }
|
469
|
+
when AST::Types::Name::Alias
|
470
|
+
AST::Types::Name::Alias.new(
|
471
|
+
name: type.name,
|
472
|
+
args: type.args.map {|ty| normalize_type(ty) },
|
473
|
+
location: type.location
|
474
|
+
)
|
475
|
+
when AST::Types::Name::Interface
|
476
|
+
AST::Types::Name::Interface.new(
|
477
|
+
name: type.name,
|
478
|
+
args: type.args.map {|ty| normalize_type(ty) },
|
479
|
+
location: type.location
|
480
|
+
)
|
481
|
+
end
|
482
|
+
end
|
437
483
|
end
|
438
484
|
end
|
439
485
|
end
|
data/lib/steep/ast/types/name.rb
CHANGED
@@ -20,6 +20,10 @@ module Steep
|
|
20
20
|
def level
|
21
21
|
[0]
|
22
22
|
end
|
23
|
+
|
24
|
+
def map_type(&block)
|
25
|
+
self
|
26
|
+
end
|
23
27
|
end
|
24
28
|
|
25
29
|
class Applying < Base
|
@@ -87,6 +91,12 @@ module Steep
|
|
87
91
|
def level
|
88
92
|
[0] + level_of_children(args)
|
89
93
|
end
|
94
|
+
|
95
|
+
def map_type(&block)
|
96
|
+
args = self.args.map(&block)
|
97
|
+
|
98
|
+
_ = self.class.new(name: self.name, args: self.args, location: self.location)
|
99
|
+
end
|
90
100
|
end
|
91
101
|
|
92
102
|
class Singleton < Base
|
@@ -783,7 +783,7 @@ module Steep
|
|
783
783
|
end
|
784
784
|
|
785
785
|
def header_line
|
786
|
-
"Assertion cannot hold: no relationship between
|
786
|
+
"Assertion cannot hold: no relationship between inferred type (`#{node_type.to_s}`) and asserted type (`#{assertion_type.to_s}`)"
|
787
787
|
end
|
788
788
|
end
|
789
789
|
|
@@ -381,6 +381,42 @@ module Steep
|
|
381
381
|
end
|
382
382
|
end
|
383
383
|
|
384
|
+
class InconsistentClassModuleAliasError < Base
|
385
|
+
attr_reader :decl
|
386
|
+
|
387
|
+
def initialize(decl:)
|
388
|
+
@decl = decl
|
389
|
+
super(location: decl.location&.[](:old_name))
|
390
|
+
end
|
391
|
+
|
392
|
+
def header_line
|
393
|
+
expected_kind =
|
394
|
+
case decl
|
395
|
+
when RBS::AST::Declarations::ModuleAlias
|
396
|
+
"module"
|
397
|
+
when RBS::AST::Declarations::ClassAlias
|
398
|
+
"class"
|
399
|
+
else
|
400
|
+
raise
|
401
|
+
end
|
402
|
+
|
403
|
+
"A #{expected_kind} `#{decl.new_name}` cannot be an alias of `#{decl.old_name}`"
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
class CyclicClassAliasDefinitionError < Base
|
408
|
+
attr_reader :decl
|
409
|
+
|
410
|
+
def initialize(decl:)
|
411
|
+
@decl = decl
|
412
|
+
super(location: decl.location&.[](:new_name))
|
413
|
+
end
|
414
|
+
|
415
|
+
def header_line
|
416
|
+
"#{decl.new_name} is a cyclic definition"
|
417
|
+
end
|
418
|
+
end
|
419
|
+
|
384
420
|
def self.from_rbs_error(error, factory:)
|
385
421
|
case error
|
386
422
|
when RBS::ParsingError
|
@@ -475,6 +511,10 @@ module Steep
|
|
475
511
|
)
|
476
512
|
when RBS::InheritModuleError
|
477
513
|
Diagnostic::Signature::InheritModuleError.new(error.super_decl)
|
514
|
+
when RBS::InconsistentClassModuleAliasError
|
515
|
+
Diagnostic::Signature::InconsistentClassModuleAliasError.new(decl: error.alias_entry.decl)
|
516
|
+
when RBS::CyclicClassAliasDefinitionError
|
517
|
+
Diagnostic::Signature::CyclicClassAliasDefinitionError.new(decl: error.alias_entry.decl)
|
478
518
|
else
|
479
519
|
raise error
|
480
520
|
end
|