rbs 1.7.0.beta.4 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/CHANGELOG.md +58 -2
  4. data/Steepfile +0 -1
  5. data/core/array.rbs +3 -3
  6. data/core/binding.rbs +2 -0
  7. data/core/builtin.rbs +4 -0
  8. data/core/complex.rbs +0 -2
  9. data/core/enumerable.rbs +3 -3
  10. data/core/env.rbs +881 -0
  11. data/core/false_class.rbs +2 -0
  12. data/core/float.rbs +0 -2
  13. data/core/integer.rbs +0 -2
  14. data/core/nil_class.rbs +2 -0
  15. data/core/numeric.rbs +7 -0
  16. data/core/object.rbs +1 -1
  17. data/core/proc.rbs +2 -0
  18. data/core/rational.rbs +0 -2
  19. data/core/symbol.rbs +2 -0
  20. data/core/thread.rbs +1 -1
  21. data/core/true_class.rbs +2 -0
  22. data/core/unbound_method.rbs +13 -0
  23. data/docs/rbs_by_example.md +2 -2
  24. data/docs/syntax.md +25 -23
  25. data/ext/rbs_extension/parser.c +99 -95
  26. data/ext/rbs_extension/parserstate.c +0 -1
  27. data/ext/rbs_extension/rbs_extension.h +1 -1
  28. data/ext/rbs_extension/ruby_objs.c +8 -6
  29. data/ext/rbs_extension/ruby_objs.h +2 -4
  30. data/lib/rbs/ast/declarations.rb +6 -2
  31. data/lib/rbs/cli.rb +1 -1
  32. data/lib/rbs/collection/sources/git.rb +6 -1
  33. data/lib/rbs/definition_builder.rb +29 -2
  34. data/lib/rbs/environment.rb +1 -0
  35. data/lib/rbs/environment_walker.rb +4 -1
  36. data/lib/rbs/errors.rb +12 -0
  37. data/lib/rbs/prototype/helpers.rb +113 -0
  38. data/lib/rbs/prototype/rb.rb +2 -105
  39. data/lib/rbs/prototype/runtime.rb +16 -0
  40. data/lib/rbs/test/setup.rb +1 -0
  41. data/lib/rbs/type_alias_regularity.rb +115 -0
  42. data/lib/rbs/types.rb +11 -23
  43. data/lib/rbs/validator.rb +40 -7
  44. data/lib/rbs/variance_calculator.rb +52 -24
  45. data/lib/rbs/version.rb +1 -1
  46. data/lib/rbs/writer.rb +1 -1
  47. data/lib/rbs.rb +2 -0
  48. data/schema/decls.json +13 -1
  49. data/schema/types.json +8 -2
  50. data/sig/collection/collections.rbs +2 -0
  51. data/sig/declarations.rbs +9 -6
  52. data/sig/definition_builder.rbs +29 -0
  53. data/sig/environment_walker.rbs +26 -0
  54. data/sig/errors.rbs +10 -0
  55. data/sig/type_alias_regularity.rbs +92 -0
  56. data/sig/types.rbs +11 -8
  57. data/sig/validator.rbs +7 -0
  58. data/sig/variance_calculator.rbs +50 -0
  59. data/stdlib/bigdecimal/0/big_decimal.rbs +44 -0
  60. data/stdlib/csv/0/csv.rbs +49 -3
  61. data/stdlib/date/0/date.rbs +2 -2
  62. data/stdlib/set/0/set.rbs +3 -3
  63. data/steep/Gemfile.lock +10 -10
  64. metadata +8 -6
  65. data/lib/rbs/parser.y +0 -1805
  66. data/lib/ruby/signature.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afd173e37912ce2897a5ff7b9ec6e54bed7258abd7015ac80ae5fa9baa380df5
4
- data.tar.gz: 77b07c52dc592c5f5b01df9d4ab8c91d59942c67f158a8f3386926922e197042
3
+ metadata.gz: 9b12d92ea4eeeb5dbd6de6c5d58351b0306bdcd017d0f1e51a36599766bfded3
4
+ data.tar.gz: d60cfb836027441a5bb3f85fbebb0e2ab9bc03c49a21f00c3f10d4ab8dd1de65
5
5
  SHA512:
6
- metadata.gz: e03c35027deec7e866534c1f79fe02060ea5672a3e3e8abe9ac1ae5940f2dd7cd99eeed5ee71d9a5991b3074984a6daaaa58d09c380b0cdcb40c568bae50427d
7
- data.tar.gz: 92a8cc1a171669ca98c5e323293258ff774747712fb24c0b342e28da866077fc10f4c4bbb2699857842ca7bba9829c014c3b69b5e80a1690aa77027f55c7b083
6
+ metadata.gz: 9ef926a62415189173d41204d1a16674a4a8331e3fdefafe00a4e52c9cbf0f3eb84281194a5b5c43027455334c13ea0ab14e1b3f0a6b8d5f5644cb80733a246b
7
+ data.tar.gz: ce07016eee6b4142a66a28d8c7ffc356b3d4fdd747027f2dd521b347efcb6ac791385e903a1e3b9f8d468ec66e13995e341516137ceba990db511982c6d0d206
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,20 +2,76 @@
2
2
 
3
3
  ## master
4
4
 
5
- ## 1.7.0 (beta.4)
5
+ ## 1.8.0 (2021-12-02)
6
+
7
+ RBS 1.8.0 ships with a language feature enchancement, _generic type alias_.
8
+ You can define a type alias with type parameters now.
9
+
10
+ ```rbs
11
+ type list[T] = [T, list[T]] | nil # Defines a list of type T
12
+
13
+ type int_list = list[Integer] # List of Integer
14
+ type string_list = list[String] # List of String
15
+ ```
16
+
17
+ You can find the detail in the [PR](https://github.com/ruby/rbs/pull/823).
18
+
19
+ ### Signature updates
20
+
21
+ * `Date#+`, `Date#-` ([\#830](https://github.com/ruby/rbs/pull/830))
22
+ * `#include?`, `#member?`, `#delete`, `#count` ([\#835](https://github.com/ruby/rbs/pull/835))
23
+
24
+ ### Language updates
25
+
26
+ * Generic type alias ([\#823](https://github.com/ruby/rbs/pull/823))
27
+
28
+ ## 1.7.1 (2021-11-18)
29
+
30
+ ### Signature updates
31
+
32
+ * `Thread#value` ([\#824](https://github.com/ruby/rbs/pull/824/files))
33
+
34
+ ### Library changes
35
+
36
+ * Unquote parameter name ([\#827](https://github.com/ruby/rbs/pull/827))
37
+ * Remove `ruby/signature.rb` ([\#825](https://github.com/ruby/rbs/pull/825))
38
+
39
+ ### Miscellaneous
40
+
41
+ * Use `untyped` as an expectation of return value of `IO#ready?` in test ([\#828](https://github.com/ruby/rbs/pull/828/files))
42
+
43
+ ## 1.7.0 (2021-11-11)
44
+
45
+ This version replaces `RBS::Parser` implementation from pure Ruby code based on [Racc](https://github.com/ruby/racc) to C extension.
46
+ It improves the RBS file parsing performance up to 5 times faster. :rocket:
47
+
48
+ * There are some incompatibilties to drop obsolete syntax rules: `super` keyword and `any` type are no longer supported.
49
+ * [re2c](https://github.com/skvadrik/re2c) is used to generate lexical generator.
50
+
51
+ 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
52
 
7
53
  ### Signature updates
8
54
 
9
55
  * io/console ([\#783](https://github.com/ruby/rbs/pull/783))
56
+ * `ENV` -- Note that it introduces a dummy `::ENVClass` class, which is not defined in Ruby. ([\#812](https://github.com/ruby/rbs/pull/812))
10
57
  * `Net::HTTPRequest` ([\#784](https://github.com/ruby/rbs/pull/784))
58
+ * `#clone` ([#811](https://github.com/ruby/rbs/pull/811), [\#813](https://github.com/ruby/rbs/pull/813))
59
+ * `Kernel#BigDecimal` ([\#817](https://github.com/ruby/rbs/pull/817))
11
60
  * `Tempfile.new`, `Tempfile.create` ([\#792](https://github.com/ruby/rbs/pull/792), [\#791](https://github.com/ruby/rbs/pull/791))
12
61
 
13
62
  ### Library changes
14
63
 
64
+ * Replace `RBS::Parser` ([#788](https://github.com/ruby/rbs/pull/788), [#789](https://github.com/ruby/rbs/pull/789))
15
65
  * Fix unexpected `CollectionNotAvailable` without `gems` from git source ([\#795](https://github.com/ruby/rbs/pull/795))
16
- * Replace RBS::Parser ([#788](https://github.com/ruby/rbs/pull/788), [#789](https://github.com/ruby/rbs/pull/789))
17
66
  * Print deprecation warning ([\#801](https://github.com/ruby/rbs/pull/801))
18
67
  * Make `Parser::KEYWORDS` a hash ([\#804](https://github.com/ruby/rbs/pull/804))
68
+ * Use _partial clone_ for `rbs collection` installer ([#805](https://github.com/ruby/rbs/pull/805))
69
+ * Respect logger level for test/setup logger ([\#819](https://github.com/ruby/rbs/pull/819), [\#822](https://github.com/ruby/rbs/pull/822))
70
+
71
+ ## Miscellaneous
72
+
73
+ * Avoid a mixture of `Array#filter` and `Array#select` ([\#820](https://github.com/ruby/rbs/pull/820))
74
+ * Remove leftover documentation about `super` ([\#807](https://github.com/ruby/rbs/pull/807))
19
75
 
20
76
  ## 1.6.2 (2021-09-09)
21
77
 
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/binding.rbs CHANGED
@@ -31,6 +31,8 @@
31
31
  class Binding
32
32
  public
33
33
 
34
+ def clone: () -> self
35
+
34
36
  # Evaluates the Ruby expression(s) in *string*, in the *binding*'s context. If
35
37
  # the optional *filename* and *lineno* parameters are present, they will be used
36
38
  # when reporting syntax errors.
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/complex.rbs CHANGED
@@ -165,8 +165,6 @@ class Complex < Numeric
165
165
 
166
166
  def ceil: (*untyped) -> bot
167
167
 
168
- def clone: (?freeze: bool) -> self
169
-
170
168
  def coerce: (Numeric) -> [ Complex, Complex ]
171
169
 
172
170
  # Returns the complex conjugate.
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