rbs 1.7.0.beta.5 → 1.8.1

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/CHANGELOG.md +64 -3
  4. data/Steepfile +0 -1
  5. data/core/array.rbs +3 -3
  6. data/core/builtin.rbs +4 -0
  7. data/core/enumerable.rbs +3 -3
  8. data/core/env.rbs +881 -0
  9. data/core/false_class.rbs +2 -0
  10. data/core/nil_class.rbs +2 -0
  11. data/core/symbol.rbs +2 -0
  12. data/core/thread.rbs +1 -1
  13. data/core/true_class.rbs +2 -0
  14. data/docs/syntax.md +23 -20
  15. data/ext/rbs_extension/parser.c +97 -95
  16. data/ext/rbs_extension/ruby_objs.c +8 -6
  17. data/ext/rbs_extension/ruby_objs.h +2 -2
  18. data/lib/rbs/ast/declarations.rb +6 -2
  19. data/lib/rbs/cli.rb +1 -1
  20. data/lib/rbs/collection/sources/git.rb +9 -7
  21. data/lib/rbs/definition_builder.rb +58 -2
  22. data/lib/rbs/environment.rb +1 -0
  23. data/lib/rbs/environment_walker.rb +4 -1
  24. data/lib/rbs/errors.rb +12 -0
  25. data/lib/rbs/test/setup.rb +1 -0
  26. data/lib/rbs/type_alias_regularity.rb +115 -0
  27. data/lib/rbs/types.rb +11 -23
  28. data/lib/rbs/validator.rb +44 -15
  29. data/lib/rbs/variance_calculator.rb +52 -24
  30. data/lib/rbs/version.rb +1 -1
  31. data/lib/rbs/writer.rb +1 -1
  32. data/lib/rbs.rb +1 -0
  33. data/schema/decls.json +13 -1
  34. data/schema/types.json +8 -2
  35. data/sig/collection/collections.rbs +4 -2
  36. data/sig/declarations.rbs +9 -6
  37. data/sig/definition_builder.rbs +36 -0
  38. data/sig/environment_walker.rbs +26 -0
  39. data/sig/errors.rbs +10 -0
  40. data/sig/type_alias_regularity.rbs +92 -0
  41. data/sig/types.rbs +11 -8
  42. data/sig/validator.rbs +7 -0
  43. data/sig/variance_calculator.rbs +50 -0
  44. data/stdlib/bigdecimal/0/big_decimal.rbs +44 -0
  45. data/stdlib/csv/0/csv.rbs +49 -3
  46. data/stdlib/date/0/date.rbs +2 -2
  47. data/stdlib/set/0/set.rbs +3 -3
  48. data/steep/Gemfile.lock +10 -10
  49. metadata +7 -6
  50. data/lib/rbs/parser.y +0 -1805
  51. data/lib/ruby/signature.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 813a7a51e3db502f844756f75a52356945988ffc9e3230b6ff564d7864af02d4
4
- data.tar.gz: 2589b291bd8fa87c7228d3204d2c6b4541617c450e64da2efc28fa658c92f0bb
3
+ metadata.gz: df1527cdbc750871d430d1c69bd4c9188b8814af7f3163d62adc5f9c1297e0dc
4
+ data.tar.gz: 3d0cc66c78d043e5fd98b86b342a7e8944c1cee8bf31f8f876530caba4cd9bc9
5
5
  SHA512:
6
- metadata.gz: 1acea4997b9a4d30da59bb02b0d7bb8afa63794c9102b35efd9627efab007195a60ad3e42ebd1595333cd5965acb1e4d1af576cd23e28efab83da6fed5ee649e
7
- data.tar.gz: 4822b8fa8cb7fc652d847d90a1bf15215f8229eda1cd11ef9307e03a4abdc0be1ef3a5b117e6fdd00ec7ad43db8cfd914903125dcacea69a8e477b6b2d1cf917
6
+ metadata.gz: 5c7f150ac87495a3ef064b5b499a5ef72c13eeb23985b84def107c111c6973a02ce6c3984bf22d1389882adf6d02f70fc82773d78383dd3992a2d7dbe58a7e59
7
+ data.tar.gz: f99bd7edbf1b4cf1cb5f018538345fe8ea50653ad6fa908aa3cd98c46d45b095aabb0cc2314cfae064997c0db2c6a31c6f9ab4fda1b15d2890a6b9be8dc8244a
data/.gitignore CHANGED
@@ -13,7 +13,6 @@
13
13
  **/.rbfu-version
14
14
  **/.rbenv-version
15
15
  **/.versions.conf
16
- /lib/rbs/parser.output
17
16
  /vendor/sigs
18
17
  /Gemfile.lock
19
18
 
data/CHANGELOG.md CHANGED
@@ -2,22 +2,83 @@
2
2
 
3
3
  ## master
4
4
 
5
- ## 1.7.0 (beta.5)
5
+ ## 1.8.1 (2021-12-13)
6
+
7
+ ### Library changes
8
+
9
+ * Validate `extend` arguments ([\#840](https://github.com/ruby/rbs/pull/840))
10
+ * Allow a relative path as git remote in collection ([\#839](https://github.com/ruby/rbs/pull/839))
11
+
12
+ ## 1.8.0 (2021-12-02)
13
+
14
+ RBS 1.8.0 ships with a language feature enchancement, _generic type alias_.
15
+ You can define a type alias with type parameters now.
16
+
17
+ ```rbs
18
+ type list[T] = [T, list[T]] | nil # Defines a list of type T
19
+
20
+ type int_list = list[Integer] # List of Integer
21
+ type string_list = list[String] # List of String
22
+ ```
23
+
24
+ You can find the detail in the [PR](https://github.com/ruby/rbs/pull/823).
25
+
26
+ ### Signature updates
27
+
28
+ * `Date#+`, `Date#-` ([\#830](https://github.com/ruby/rbs/pull/830))
29
+ * `#include?`, `#member?`, `#delete`, `#count` ([\#835](https://github.com/ruby/rbs/pull/835))
30
+
31
+ ### Language updates
32
+
33
+ * Generic type alias ([\#823](https://github.com/ruby/rbs/pull/823))
34
+
35
+ ## 1.7.1 (2021-11-18)
36
+
37
+ ### Signature updates
38
+
39
+ * `Thread#value` ([\#824](https://github.com/ruby/rbs/pull/824/files))
40
+
41
+ ### Library changes
42
+
43
+ * Unquote parameter name ([\#827](https://github.com/ruby/rbs/pull/827))
44
+ * Remove `ruby/signature.rb` ([\#825](https://github.com/ruby/rbs/pull/825))
45
+
46
+ ### Miscellaneous
47
+
48
+ * Use `untyped` as an expectation of return value of `IO#ready?` in test ([\#828](https://github.com/ruby/rbs/pull/828/files))
49
+
50
+ ## 1.7.0 (2021-11-11)
51
+
52
+ This version replaces `RBS::Parser` implementation from pure Ruby code based on [Racc](https://github.com/ruby/racc) to C extension.
53
+ It improves the RBS file parsing performance up to 5 times faster. :rocket:
54
+
55
+ * There are some incompatibilties to drop obsolete syntax rules: `super` keyword and `any` type are no longer supported.
56
+ * [re2c](https://github.com/skvadrik/re2c) is used to generate lexical generator.
57
+
58
+ When you want to change the parser/lexer, change the files under `ext/rbs_extension` directory and run `rake compile` to compile the extension.
6
59
 
7
60
  ### Signature updates
8
61
 
9
62
  * io/console ([\#783](https://github.com/ruby/rbs/pull/783))
63
+ * `ENV` -- Note that it introduces a dummy `::ENVClass` class, which is not defined in Ruby. ([\#812](https://github.com/ruby/rbs/pull/812))
10
64
  * `Net::HTTPRequest` ([\#784](https://github.com/ruby/rbs/pull/784))
65
+ * `#clone` ([#811](https://github.com/ruby/rbs/pull/811), [\#813](https://github.com/ruby/rbs/pull/813))
66
+ * `Kernel#BigDecimal` ([\#817](https://github.com/ruby/rbs/pull/817))
11
67
  * `Tempfile.new`, `Tempfile.create` ([\#792](https://github.com/ruby/rbs/pull/792), [\#791](https://github.com/ruby/rbs/pull/791))
12
- * `#clone` ([#811](https://github.com/ruby/rbs/pull/811))
13
68
 
14
69
  ### Library changes
15
70
 
71
+ * Replace `RBS::Parser` ([#788](https://github.com/ruby/rbs/pull/788), [#789](https://github.com/ruby/rbs/pull/789))
16
72
  * Fix unexpected `CollectionNotAvailable` without `gems` from git source ([\#795](https://github.com/ruby/rbs/pull/795))
17
- * Replace RBS::Parser ([#788](https://github.com/ruby/rbs/pull/788), [#789](https://github.com/ruby/rbs/pull/789))
18
73
  * Print deprecation warning ([\#801](https://github.com/ruby/rbs/pull/801))
19
74
  * Make `Parser::KEYWORDS` a hash ([\#804](https://github.com/ruby/rbs/pull/804))
20
75
  * Use _partial clone_ for `rbs collection` installer ([#805](https://github.com/ruby/rbs/pull/805))
76
+ * Respect logger level for test/setup logger ([\#819](https://github.com/ruby/rbs/pull/819), [\#822](https://github.com/ruby/rbs/pull/822))
77
+
78
+ ## Miscellaneous
79
+
80
+ * Avoid a mixture of `Array#filter` and `Array#select` ([\#820](https://github.com/ruby/rbs/pull/820))
81
+ * Remove leftover documentation about `super` ([\#807](https://github.com/ruby/rbs/pull/807))
21
82
 
22
83
  ## 1.6.2 (2021-09-09)
23
84
 
data/Steepfile CHANGED
@@ -3,7 +3,6 @@ D = Steep::Diagnostic
3
3
  target :lib do
4
4
  signature "sig"
5
5
  check "lib"
6
- ignore "lib/rbs/parser.rb"
7
6
  ignore "lib/rbs/prototype", "lib/rbs/test", "lib/rbs/test.rb"
8
7
 
9
8
  library "set", "pathname", "json", "logger", "monitor", "tsort", "uri"
data/core/array.rbs CHANGED
@@ -699,7 +699,7 @@ class Array[unchecked out Elem] < Object
699
699
  # ary.count {|x| x%2 == 0} #=> 3
700
700
  #
701
701
  def count: () -> ::Integer
702
- | (untyped obj) -> ::Integer
702
+ | (Elem obj) -> ::Integer
703
703
  | () { (Elem) -> boolish } -> ::Integer
704
704
 
705
705
  # Calls the given block for each element `n` times or forever if `nil` is given.
@@ -733,7 +733,7 @@ class Array[unchecked out Elem] < Object
733
733
  # a.delete("z") #=> nil
734
734
  # a.delete("z") {"not found"} #=> "not found"
735
735
  #
736
- def delete: (untyped obj) -> Elem?
736
+ def delete: (Elem obj) -> Elem?
737
737
  | [S, T] (S obj) { (S) -> T } -> (Elem | T)
738
738
 
739
739
  # Deletes the element at the specified `index`, returning that element, or `nil`
@@ -1029,7 +1029,7 @@ class Array[unchecked out Elem] < Object
1029
1029
  # a.include?("b") #=> true
1030
1030
  # a.include?("z") #=> false
1031
1031
  #
1032
- def include?: (untyped object) -> bool
1032
+ def include?: (Elem object) -> bool
1033
1033
 
1034
1034
  # Returns the *index* of the first object in `ary` such that the object is `==`
1035
1035
  # to `obj`.
data/core/builtin.rbs CHANGED
@@ -6,6 +6,10 @@ interface _ToInt
6
6
  def to_int: -> Integer
7
7
  end
8
8
 
9
+ interface _ToR
10
+ def to_r: () -> Rational
11
+ end
12
+
9
13
  interface _ToS
10
14
  def to_s: -> String
11
15
  end
data/core/enumerable.rbs CHANGED
@@ -63,7 +63,7 @@ module Enumerable[unchecked out Elem]: _Each[Elem]
63
63
  # ary.count{ |x| x%2==0 } #=> 3
64
64
  # ```
65
65
  def count: () -> Integer
66
- | (?untyped) -> Integer
66
+ | (Elem) -> Integer
67
67
  | () { (Elem) -> boolish } -> Integer
68
68
 
69
69
  def cycle: (?Integer n) { (Elem arg0) -> untyped } -> NilClass
@@ -130,7 +130,7 @@ module Enumerable[unchecked out Elem]: _Each[Elem]
130
130
  def group_by: [U] () { (Elem arg0) -> U } -> ::Hash[U, ::Array[Elem]]
131
131
  | () -> ::Enumerator[Elem, ::Array[Elem]]
132
132
 
133
- def `include?`: (untyped arg0) -> bool
133
+ def `include?`: (Elem arg0) -> bool
134
134
 
135
135
  def inject: (untyped init, Symbol method) -> untyped
136
136
  | (Symbol method) -> untyped
@@ -341,7 +341,7 @@ module Enumerable[unchecked out Elem]: _Each[Elem]
341
341
  def map: [U] () { (Elem arg0) -> U } -> ::Array[U]
342
342
  | () -> ::Enumerator[Elem, ::Array[untyped]]
343
343
 
344
- def member?: (untyped arg0) -> bool
344
+ def member?: (Elem arg0) -> bool
345
345
 
346
346
  alias reduce inject
347
347