rbs 1.7.0.beta.2 → 1.7.0

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +20 -1
  3. data/.gitignore +9 -2
  4. data/CHANGELOG.md +36 -9
  5. data/Rakefile +15 -0
  6. data/Steepfile +0 -1
  7. data/core/binding.rbs +2 -0
  8. data/core/complex.rbs +0 -2
  9. data/core/env.rbs +881 -0
  10. data/core/false_class.rbs +2 -0
  11. data/core/float.rbs +0 -2
  12. data/core/integer.rbs +0 -2
  13. data/core/nil_class.rbs +2 -0
  14. data/core/numeric.rbs +7 -0
  15. data/core/object.rbs +1 -1
  16. data/core/proc.rbs +2 -0
  17. data/core/rational.rbs +0 -2
  18. data/core/symbol.rbs +2 -0
  19. data/core/true_class.rbs +2 -0
  20. data/core/unbound_method.rbs +13 -0
  21. data/docs/rbs_by_example.md +2 -2
  22. data/docs/syntax.md +2 -3
  23. data/ext/rbs_extension/constants.c +0 -1
  24. data/ext/rbs_extension/lexer.c +2526 -1063
  25. data/ext/rbs_extension/lexer.h +33 -17
  26. data/ext/rbs_extension/lexer.re +140 -0
  27. data/ext/rbs_extension/lexstate.c +139 -0
  28. data/ext/rbs_extension/parser.c +2 -32
  29. data/ext/rbs_extension/parser.h +0 -5
  30. data/ext/rbs_extension/parserstate.c +0 -1
  31. data/ext/rbs_extension/rbs_extension.h +1 -1
  32. data/ext/rbs_extension/ruby_objs.c +84 -148
  33. data/ext/rbs_extension/ruby_objs.h +0 -2
  34. data/lib/rbs/collection/installer.rb +1 -0
  35. data/lib/rbs/collection/sources/git.rb +6 -1
  36. data/lib/rbs/errors.rb +6 -0
  37. data/lib/rbs/parser_aux.rb +37 -5
  38. data/lib/rbs/parser_compat/lexer_error.rb +4 -0
  39. data/lib/rbs/parser_compat/located_value.rb +5 -0
  40. data/lib/rbs/parser_compat/semantics_error.rb +4 -0
  41. data/lib/rbs/parser_compat/syntax_error.rb +4 -0
  42. data/lib/rbs/prototype/helpers.rb +113 -0
  43. data/lib/rbs/prototype/rb.rb +2 -105
  44. data/lib/rbs/prototype/runtime.rb +16 -0
  45. data/lib/rbs/test/setup.rb +1 -0
  46. data/lib/rbs/types.rb +2 -2
  47. data/lib/rbs/version.rb +1 -1
  48. data/lib/rbs.rb +12 -0
  49. data/sig/parser.rbs +2 -0
  50. data/sig/rbs.rbs +4 -0
  51. data/stdlib/bigdecimal/0/big_decimal.rbs +44 -0
  52. data/stdlib/csv/0/csv.rbs +49 -3
  53. data/stdlib/io-console/0/io-console.rbs +137 -0
  54. data/stdlib/net-http/0/net-http.rbs +2 -1
  55. data/stdlib/tempfile/0/tempfile.rbs +4 -6
  56. metadata +13 -5
  57. data/lib/rbs/parser.y +0 -1805
data/core/false_class.rbs CHANGED
@@ -37,4 +37,6 @@ class FalseClass
37
37
  def |: (nil) -> false
38
38
  | (false) -> false
39
39
  | (untyped obj) -> true
40
+
41
+ def clone: (?freeze: true?) -> self
40
42
  end
data/core/float.rbs CHANGED
@@ -171,8 +171,6 @@ class Float < Numeric
171
171
  def ceil: () -> Integer
172
172
  | (int digits) -> (Integer | Float)
173
173
 
174
- def clone: (?freeze: bool) -> self
175
-
176
174
  # Returns an array with both `numeric` and `float` represented as Float objects.
177
175
  #
178
176
  # This is achieved by converting `numeric` to a Float.
data/core/integer.rbs CHANGED
@@ -272,8 +272,6 @@ class Integer < Numeric
272
272
  #
273
273
  def chr: (?encoding) -> String
274
274
 
275
- def clone: (?freeze: bool) -> self
276
-
277
275
  # Returns an array with both a `numeric` and a `big` represented as Bignum
278
276
  # objects.
279
277
  #
data/core/nil_class.rbs CHANGED
@@ -79,4 +79,6 @@ class NilClass
79
79
  def |: (nil) -> false
80
80
  | (false) -> false
81
81
  | (untyped obj) -> bool
82
+
83
+ def clone: (?freeze: true?) -> self
82
84
  end
data/core/numeric.rbs CHANGED
@@ -416,4 +416,11 @@ class Numeric
416
416
  # Returns `true` if `num` has a zero value.
417
417
  #
418
418
  def zero?: () -> bool
419
+
420
+ # Returns +self+.
421
+ #
422
+ # Raises an exception if the value for +freeze+ is neither +true+ nor +nil+.
423
+ #
424
+ # Related: Numeric#dup.
425
+ def clone: (?freeze: true?) -> self
419
426
  end
data/core/object.rbs CHANGED
@@ -76,7 +76,7 @@ class Object < BasicObject
76
76
  # This method may have class-specific behavior. If so, that behavior will be
77
77
  # documented under the #`initialize_copy` method of the class.
78
78
  #
79
- def clone: (?freeze: bool) -> self
79
+ def clone: (?freeze: bool?) -> self
80
80
 
81
81
  # Defines a singleton method in the receiver. The *method* parameter can be a
82
82
  # `Proc`, a `Method` or an `UnboundMethod` object. If a block is specified, it
data/core/proc.rbs CHANGED
@@ -210,6 +210,8 @@
210
210
  # {test: 1}.to_proc.call(:test) #=> 1
211
211
  # %i[test many keys].map(&{test: 1}) #=> [1, nil, nil]
212
212
  class Proc < Object
213
+ def clone: () -> self
214
+
213
215
  # Returns the number of mandatory arguments. If the block is declared to
214
216
  # take no arguments, returns 0. If the block is known to take exactly n
215
217
  # arguments, returns n. If the block has optional arguments, returns -n-1,
data/core/rational.rbs CHANGED
@@ -175,8 +175,6 @@ class Rational < Numeric
175
175
  def ceil: () -> Integer
176
176
  | (Integer digits) -> (Integer | Rational)
177
177
 
178
- def clone: (?freeze: bool) -> self
179
-
180
178
  def coerce: (Numeric) -> [Numeric, Numeric]
181
179
 
182
180
  def conj: () -> Rational
data/core/symbol.rbs CHANGED
@@ -226,4 +226,6 @@ class Symbol
226
226
  | (:ascii | :lithuanian | :turkic) -> Symbol
227
227
  | (:lithuanian, :turkic) -> Symbol
228
228
  | (:turkic, :lithuanian) -> Symbol
229
+
230
+ def clone: (?freeze: true?) -> self
229
231
  end
data/core/true_class.rbs CHANGED
@@ -43,4 +43,6 @@ class TrueClass
43
43
  # or
44
44
  #
45
45
  def |: (untyped obj) -> true
46
+
47
+ def clone: (?freeze: true?) -> self
46
48
  end
@@ -45,6 +45,19 @@
45
45
  # um.bind(t).call #=> :original
46
46
  #
47
47
  class UnboundMethod
48
+ # Returns a clone of this method.
49
+ #
50
+ # class A
51
+ # def foo
52
+ # return "bar"
53
+ # end
54
+ # end
55
+ #
56
+ # m = A.new.method(:foo)
57
+ # m.call # => "bar"
58
+ # n = m.clone.call # => "bar"
59
+ def clone: () -> self
60
+
48
61
  # Returns an indication of the number of arguments accepted by a method. Returns
49
62
  # a nonnegative integer for methods that take a fixed number of arguments. For
50
63
  # Ruby methods that take a variable number of arguments, returns -n-1, where n
@@ -229,9 +229,9 @@ end
229
229
 
230
230
  ```ruby
231
231
  # .rb
232
- [1,2,3,4,5].select {|num| num.even? }
232
+ [1,2,3,4,5].filter {|num| num.even? }
233
233
  # => [2, 4]
234
- %w[ a b c d e f ].select {|v| v =~ /[aeiou]/ }
234
+ %w[ a b c d e f ].filter {|v| v =~ /[aeiou]/ }
235
235
  # => ["a", "e"]
236
236
  [1,2,3,4,5].filter
237
237
  ```
data/docs/syntax.md CHANGED
@@ -110,10 +110,10 @@ Array[Integer | String] # Array of Integer or String
110
110
  Intersection type denotes _a type of all of the given types_.
111
111
 
112
112
  ```
113
- Integer & String # Integer and String
113
+ _Reader & _Writer # _Reader and _Writer
114
114
  ```
115
115
 
116
- Note that `&` has higher precedence than `|` that `Integer & String | Symbol` is `(Integer & String) | Symbol`.
116
+ Note that `&` has higher precedence than `|` that `A & B | C` is `(A & B) | C`.
117
117
 
118
118
  ### Optional type
119
119
 
@@ -289,7 +289,6 @@ _method-member_ ::= `def` _method-name_ `:` _method-types_ # Instance
289
289
  | `def self?.` _method-name_ `:` _method-types_ # Singleton and instance method
290
290
 
291
291
  _method-types_ ::= # Empty
292
- | `super` # `super` overloading
293
292
  | _type-parameters_ _method-type_ `|` _method-types_ # Overloading types
294
293
  | `...` # Overloading for duplicate definitions
295
294
 
@@ -1,7 +1,6 @@
1
1
  #include "rbs_extension.h"
2
2
 
3
3
  VALUE RBS_Parser;
4
- VALUE RBS_Parser_KEYWORDS;
5
4
 
6
5
  VALUE RBS;
7
6
  VALUE RBS_AST;