rigortype 0.0.3 → 0.0.5

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +215 -117
  3. data/data/builtins/ruby_core/comparable.yml +87 -0
  4. data/data/builtins/ruby_core/complex.yml +505 -0
  5. data/data/builtins/ruby_core/date.yml +1737 -0
  6. data/data/builtins/ruby_core/enumerable.yml +557 -0
  7. data/data/builtins/ruby_core/file.yml +9 -0
  8. data/data/builtins/ruby_core/hash.yml +936 -0
  9. data/data/builtins/ruby_core/range.yml +389 -0
  10. data/data/builtins/ruby_core/rational.yml +365 -0
  11. data/data/builtins/ruby_core/set.yml +594 -0
  12. data/data/builtins/ruby_core/string.yml +9 -0
  13. data/data/builtins/ruby_core/time.yml +752 -0
  14. data/lib/rigor/analysis/check_rules.rb +11 -3
  15. data/lib/rigor/builtins/imported_refinements.rb +192 -10
  16. data/lib/rigor/cli.rb +1 -1
  17. data/lib/rigor/inference/acceptance.rb +181 -12
  18. data/lib/rigor/inference/builtins/comparable_catalog.rb +27 -0
  19. data/lib/rigor/inference/builtins/complex_catalog.rb +41 -0
  20. data/lib/rigor/inference/builtins/date_catalog.rb +98 -0
  21. data/lib/rigor/inference/builtins/enumerable_catalog.rb +27 -0
  22. data/lib/rigor/inference/builtins/hash_catalog.rb +40 -0
  23. data/lib/rigor/inference/builtins/range_catalog.rb +46 -0
  24. data/lib/rigor/inference/builtins/rational_catalog.rb +38 -0
  25. data/lib/rigor/inference/builtins/set_catalog.rb +54 -0
  26. data/lib/rigor/inference/builtins/time_catalog.rb +64 -0
  27. data/lib/rigor/inference/method_dispatcher/constant_folding.rb +145 -11
  28. data/lib/rigor/inference/method_dispatcher/iterator_dispatch.rb +202 -1
  29. data/lib/rigor/inference/method_dispatcher/kernel_dispatch.rb +95 -0
  30. data/lib/rigor/inference/method_dispatcher/overload_selector.rb +23 -7
  31. data/lib/rigor/inference/method_dispatcher/shape_dispatch.rb +135 -6
  32. data/lib/rigor/inference/method_dispatcher.rb +3 -1
  33. data/lib/rigor/inference/method_parameter_binder.rb +29 -4
  34. data/lib/rigor/inference/narrowing.rb +211 -0
  35. data/lib/rigor/inference/scope_indexer.rb +87 -11
  36. data/lib/rigor/inference/statement_evaluator.rb +6 -0
  37. data/lib/rigor/rbs_extended.rb +170 -14
  38. data/lib/rigor/type/combinator.rb +90 -0
  39. data/lib/rigor/type/integer_range.rb +4 -2
  40. data/lib/rigor/type/intersection.rb +135 -0
  41. data/lib/rigor/type/refined.rb +174 -0
  42. data/lib/rigor/type.rb +2 -0
  43. data/lib/rigor/version.rb +1 -1
  44. data/sig/rigor/environment.rbs +4 -6
  45. data/sig/rigor/inference.rbs +2 -1
  46. data/sig/rigor/rbs_extended.rbs +11 -0
  47. data/sig/rigor/type.rbs +75 -35
  48. metadata +22 -1
data/sig/rigor/type.rbs CHANGED
@@ -8,9 +8,9 @@ module Rigor
8
8
  def self.instance: () -> Top
9
9
  def describe: (?Symbol verbosity) -> String
10
10
  def erase_to_rbs: () -> String
11
- def top: () -> Top
12
- def bot: () -> Bot
13
- def dynamic: () -> Dynamic
11
+ def top: () -> Trinary
12
+ def bot: () -> Trinary
13
+ def dynamic: () -> Trinary
14
14
  def accepts: (Type::t other, ?mode: accepts_mode) -> AcceptsResult
15
15
  def ==: (untyped other) -> bool
16
16
  def hash: () -> Integer
@@ -21,9 +21,9 @@ module Rigor
21
21
  def self.instance: () -> Bot
22
22
  def describe: (?Symbol verbosity) -> String
23
23
  def erase_to_rbs: () -> String
24
- def top: () -> Top
25
- def bot: () -> Bot
26
- def dynamic: () -> Dynamic
24
+ def top: () -> Trinary
25
+ def bot: () -> Trinary
26
+ def dynamic: () -> Trinary
27
27
  def accepts: (Type::t other, ?mode: accepts_mode) -> AcceptsResult
28
28
  def ==: (untyped other) -> bool
29
29
  def hash: () -> Integer
@@ -35,9 +35,9 @@ module Rigor
35
35
  def initialize: (Type::t static_facet) -> void
36
36
  def describe: (?Symbol verbosity) -> String
37
37
  def erase_to_rbs: () -> String
38
- def top: () -> Top
39
- def bot: () -> Bot
40
- def dynamic: () -> Dynamic
38
+ def top: () -> Trinary
39
+ def bot: () -> Trinary
40
+ def dynamic: () -> Trinary
41
41
  def accepts: (Type::t other, ?mode: accepts_mode) -> AcceptsResult
42
42
  def ==: (untyped other) -> bool
43
43
  def hash: () -> Integer
@@ -49,9 +49,9 @@ module Rigor
49
49
  def initialize: (untyped value) -> void
50
50
  def describe: (?Symbol verbosity) -> String
51
51
  def erase_to_rbs: () -> String
52
- def top: () -> Top
53
- def bot: () -> Bot
54
- def dynamic: () -> Dynamic
52
+ def top: () -> Trinary
53
+ def bot: () -> Trinary
54
+ def dynamic: () -> Trinary
55
55
  def accepts: (Type::t other, ?mode: accepts_mode) -> AcceptsResult
56
56
  def ==: (untyped other) -> bool
57
57
  def hash: () -> Integer
@@ -68,14 +68,14 @@ module Rigor
68
68
  def finite?: () -> bool
69
69
  def cardinality: () -> (Integer | Float)
70
70
  def covers?: (untyped value) -> bool
71
- def lower: () -> Numeric
72
- def upper: () -> Numeric
71
+ def lower: () -> (Integer | Float)
72
+ def upper: () -> (Integer | Float)
73
73
  def describe: (?Symbol verbosity) -> String
74
74
  def generic_description: () -> String
75
75
  def erase_to_rbs: () -> String
76
- def top: () -> Top
77
- def bot: () -> Bot
78
- def dynamic: () -> Dynamic
76
+ def top: () -> Trinary
77
+ def bot: () -> Trinary
78
+ def dynamic: () -> Trinary
79
79
  def accepts: (Type::t other, ?mode: accepts_mode) -> AcceptsResult
80
80
  def ==: (untyped other) -> bool
81
81
  def hash: () -> Integer
@@ -88,9 +88,9 @@ module Rigor
88
88
  def initialize: (String class_name, ?Array[Type::t] type_args) -> void
89
89
  def describe: (?Symbol verbosity) -> String
90
90
  def erase_to_rbs: () -> String
91
- def top: () -> Top
92
- def bot: () -> Bot
93
- def dynamic: () -> Dynamic
91
+ def top: () -> Trinary
92
+ def bot: () -> Trinary
93
+ def dynamic: () -> Trinary
94
94
  def accepts: (Type::t other, ?mode: accepts_mode) -> AcceptsResult
95
95
  def ==: (untyped other) -> bool
96
96
  def hash: () -> Integer
@@ -102,9 +102,9 @@ module Rigor
102
102
  def initialize: (String class_name) -> void
103
103
  def describe: (?Symbol verbosity) -> String
104
104
  def erase_to_rbs: () -> String
105
- def top: () -> Top
106
- def bot: () -> Bot
107
- def dynamic: () -> Dynamic
105
+ def top: () -> Trinary
106
+ def bot: () -> Trinary
107
+ def dynamic: () -> Trinary
108
108
  def accepts: (Type::t other, ?mode: accepts_mode) -> AcceptsResult
109
109
  def ==: (untyped other) -> bool
110
110
  def hash: () -> Integer
@@ -116,9 +116,9 @@ module Rigor
116
116
  def initialize: (Array[Type::t] members) -> void
117
117
  def describe: (?Symbol verbosity) -> String
118
118
  def erase_to_rbs: () -> String
119
- def top: () -> Top
120
- def bot: () -> Bot
121
- def dynamic: () -> Dynamic
119
+ def top: () -> Trinary
120
+ def bot: () -> Trinary
121
+ def dynamic: () -> Trinary
122
122
  def accepts: (Type::t other, ?mode: accepts_mode) -> AcceptsResult
123
123
  def ==: (untyped other) -> bool
124
124
  def hash: () -> Integer
@@ -131,9 +131,39 @@ module Rigor
131
131
  def initialize: (Type::t base, Type::t removed) -> void
132
132
  def describe: (?Symbol verbosity) -> String
133
133
  def erase_to_rbs: () -> String
134
- def top: () -> Top
135
- def bot: () -> Bot
136
- def dynamic: () -> Dynamic
134
+ def top: () -> Trinary
135
+ def bot: () -> Trinary
136
+ def dynamic: () -> Trinary
137
+ def accepts: (Type::t other, ?mode: accepts_mode) -> AcceptsResult
138
+ def ==: (untyped other) -> bool
139
+ def hash: () -> Integer
140
+ def inspect: () -> String
141
+ end
142
+
143
+ class Refined
144
+ attr_reader base: Type::t
145
+ attr_reader predicate_id: Symbol
146
+ def initialize: (Type::t base, Symbol predicate_id) -> void
147
+ def describe: (?Symbol verbosity) -> String
148
+ def erase_to_rbs: () -> String
149
+ def top: () -> Trinary
150
+ def bot: () -> Trinary
151
+ def dynamic: () -> Trinary
152
+ def accepts: (Type::t other, ?mode: accepts_mode) -> AcceptsResult
153
+ def matches?: (untyped value) -> bool?
154
+ def ==: (untyped other) -> bool
155
+ def hash: () -> Integer
156
+ def inspect: () -> String
157
+ end
158
+
159
+ class Intersection
160
+ attr_reader members: Array[Type::t]
161
+ def initialize: (Array[Type::t] members) -> void
162
+ def describe: (?Symbol verbosity) -> String
163
+ def erase_to_rbs: () -> String
164
+ def top: () -> Trinary
165
+ def bot: () -> Trinary
166
+ def dynamic: () -> Trinary
137
167
  def accepts: (Type::t other, ?mode: accepts_mode) -> AcceptsResult
138
168
  def ==: (untyped other) -> bool
139
169
  def hash: () -> Integer
@@ -145,9 +175,9 @@ module Rigor
145
175
  def initialize: (Array[Type::t] elements) -> void
146
176
  def describe: (?Symbol verbosity) -> String
147
177
  def erase_to_rbs: () -> String
148
- def top: () -> Top
149
- def bot: () -> Bot
150
- def dynamic: () -> Dynamic
178
+ def top: () -> Trinary
179
+ def bot: () -> Trinary
180
+ def dynamic: () -> Trinary
151
181
  def accepts: (Type::t other, ?mode: accepts_mode) -> AcceptsResult
152
182
  def ==: (untyped other) -> bool
153
183
  def hash: () -> Integer
@@ -168,9 +198,9 @@ module Rigor
168
198
  def required_key?: (untyped key) -> bool
169
199
  def optional_key?: (untyped key) -> bool
170
200
  def read_only_key?: (untyped key) -> bool
171
- def top: () -> Top
172
- def bot: () -> Bot
173
- def dynamic: () -> Dynamic
201
+ def top: () -> Trinary
202
+ def bot: () -> Trinary
203
+ def dynamic: () -> Trinary
174
204
  def accepts: (Type::t other, ?mode: accepts_mode) -> AcceptsResult
175
205
  def ==: (untyped other) -> bool
176
206
  def hash: () -> Integer
@@ -207,6 +237,16 @@ module Rigor
207
237
  def self?.non_zero_int: () -> Difference
208
238
  def self?.non_empty_array: (?Type::t element) -> Difference
209
239
  def self?.non_empty_hash: (?Type::t key, ?Type::t value) -> Difference
240
+ def self?.refined: (Type::t base, Symbol predicate_id) -> Refined
241
+ def self?.lowercase_string: () -> Refined
242
+ def self?.uppercase_string: () -> Refined
243
+ def self?.numeric_string: () -> Refined
244
+ def self?.decimal_int_string: () -> Refined
245
+ def self?.octal_int_string: () -> Refined
246
+ def self?.hex_int_string: () -> Refined
247
+ def self?.intersection: (*Type::t members) -> Type::t
248
+ def self?.non_empty_lowercase_string: () -> Type::t
249
+ def self?.non_empty_uppercase_string: () -> Type::t
210
250
  def self?.integer_range: ((Integer | Symbol) min, (Integer | Symbol) max) -> IntegerRange
211
251
  def self?.positive_int: () -> IntegerRange
212
252
  def self?.non_negative_int: () -> IntegerRange
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rigortype
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rigor contributors
@@ -161,10 +161,19 @@ files:
161
161
  - LICENSE
162
162
  - README.md
163
163
  - data/builtins/ruby_core/array.yml
164
+ - data/builtins/ruby_core/comparable.yml
165
+ - data/builtins/ruby_core/complex.yml
166
+ - data/builtins/ruby_core/date.yml
167
+ - data/builtins/ruby_core/enumerable.yml
164
168
  - data/builtins/ruby_core/file.yml
169
+ - data/builtins/ruby_core/hash.yml
165
170
  - data/builtins/ruby_core/io.yml
166
171
  - data/builtins/ruby_core/numeric.yml
172
+ - data/builtins/ruby_core/range.yml
173
+ - data/builtins/ruby_core/rational.yml
174
+ - data/builtins/ruby_core/set.yml
167
175
  - data/builtins/ruby_core/string.yml
176
+ - data/builtins/ruby_core/time.yml
168
177
  - exe/rigor
169
178
  - lib/rigor.rb
170
179
  - lib/rigor/analysis/check_rules.rb
@@ -189,9 +198,18 @@ files:
189
198
  - lib/rigor/inference/acceptance.rb
190
199
  - lib/rigor/inference/block_parameter_binder.rb
191
200
  - lib/rigor/inference/builtins/array_catalog.rb
201
+ - lib/rigor/inference/builtins/comparable_catalog.rb
202
+ - lib/rigor/inference/builtins/complex_catalog.rb
203
+ - lib/rigor/inference/builtins/date_catalog.rb
204
+ - lib/rigor/inference/builtins/enumerable_catalog.rb
205
+ - lib/rigor/inference/builtins/hash_catalog.rb
192
206
  - lib/rigor/inference/builtins/method_catalog.rb
193
207
  - lib/rigor/inference/builtins/numeric_catalog.rb
208
+ - lib/rigor/inference/builtins/range_catalog.rb
209
+ - lib/rigor/inference/builtins/rational_catalog.rb
210
+ - lib/rigor/inference/builtins/set_catalog.rb
194
211
  - lib/rigor/inference/builtins/string_catalog.rb
212
+ - lib/rigor/inference/builtins/time_catalog.rb
195
213
  - lib/rigor/inference/closure_escape_analyzer.rb
196
214
  - lib/rigor/inference/coverage_scanner.rb
197
215
  - lib/rigor/inference/expression_typer.rb
@@ -201,6 +219,7 @@ files:
201
219
  - lib/rigor/inference/method_dispatcher/constant_folding.rb
202
220
  - lib/rigor/inference/method_dispatcher/file_folding.rb
203
221
  - lib/rigor/inference/method_dispatcher/iterator_dispatch.rb
222
+ - lib/rigor/inference/method_dispatcher/kernel_dispatch.rb
204
223
  - lib/rigor/inference/method_dispatcher/overload_selector.rb
205
224
  - lib/rigor/inference/method_dispatcher/rbs_dispatch.rb
206
225
  - lib/rigor/inference/method_dispatcher/shape_dispatch.rb
@@ -226,7 +245,9 @@ files:
226
245
  - lib/rigor/type/dynamic.rb
227
246
  - lib/rigor/type/hash_shape.rb
228
247
  - lib/rigor/type/integer_range.rb
248
+ - lib/rigor/type/intersection.rb
229
249
  - lib/rigor/type/nominal.rb
250
+ - lib/rigor/type/refined.rb
230
251
  - lib/rigor/type/singleton.rb
231
252
  - lib/rigor/type/top.rb
232
253
  - lib/rigor/type/tuple.rb