rbs 2.7.0 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5774c0ae32533d1da69481ae4b413817580fd9974b445a67bef1faf4ff48080
4
- data.tar.gz: 3f4552b3a91d2fc233f110b8682b73674454163a540d271c9f355daf6e61b5d3
3
+ metadata.gz: 26f1a45c1e5dbf02bc102b1fc68c925979facec75a9971e9b405481087fc9ad9
4
+ data.tar.gz: b6e8bee27043e2bc710a894fe9518266dac265a8d0afc685193ca157dc5e8cac
5
5
  SHA512:
6
- metadata.gz: '0827ff2d63c104b99b07b5319f581b559b6dd7b6e9a26ae2f65d2fc5f8b9c435fff19690b9efe1dfed4c5d220c61c4afdb74203a2275b27bd95a934fbe467c16'
7
- data.tar.gz: 7584c2471066032562ca5c3eb39dc8880e764f0fa880fcb9d1ee5e5b56b29fad9d2991b570b17ccf8b9e1f9ecf395c4719609d176dc2058fce6bfac03455d79f
6
+ metadata.gz: 918413c661460215dc7de7404e6b9a6f117a56493e91b2c1f059524352c9fe84c6deff43c43987816eaca958224eb57c3206f463dd3fe09b7e402f2a5daed92d
7
+ data.tar.gz: b743905981aa9b998c41b84a6dc9ae81b5d2456a89218c2840a490260552dc1919a7c2cc46d4293b49df120ccada9b220ffd06b25ebfe47f941a0632b4cc63fc
@@ -12,23 +12,23 @@ jobs:
12
12
  container:
13
13
  image: rubylang/ruby:3.1-focal
14
14
  steps:
15
- - uses: actions/checkout@v3
16
- - name: Install dependencies
17
- run: |
18
- apt-get update
19
- apt-get install -y libdb-dev curl
20
- - name: Update rubygems & bundler
21
- run: |
22
- ruby -v
23
- gem update --system
24
- - name: bundle config set with
25
- run: |
26
- echo "NO_MINITEST=true" >> $GITHUB_ENV
27
- bundle config set --local without 'minitest'
28
- if: "contains(matrix.container_tag, 'master-nightly')"
29
- - name: bin/setup
30
- run: |
31
- bin/setup
32
- - name: Check if `rake annotate` has been executed
33
- run: |
34
- bundle exec rake annotate confirm_annotation
15
+ - uses: actions/checkout@v3
16
+ - name: Install dependencies
17
+ run: |
18
+ apt-get update
19
+ apt-get install -y libdb-dev curl
20
+ - name: Update rubygems & bundler
21
+ run: |
22
+ ruby -v
23
+ gem update --system
24
+ - name: bundle config set with
25
+ run: |
26
+ echo "NO_MINITEST=true" >> $GITHUB_ENV
27
+ bundle config set --local without 'minitest'
28
+ if: "contains(matrix.container_tag, 'master-nightly')"
29
+ - name: bin/setup
30
+ run: |
31
+ bin/setup
32
+ - name: Check if `rake annotate` has been executed
33
+ run: |
34
+ bundle exec rake annotate confirm_annotation
@@ -12,70 +12,70 @@ jobs:
12
12
  strategy:
13
13
  matrix:
14
14
  container_tag:
15
- - master-nightly-focal
16
- - 3.1-focal
17
- - 3.0-focal
18
- - 2.7-bionic
19
- - 2.6-bionic
15
+ - master-nightly-focal
16
+ - 3.1-focal
17
+ - 3.0-focal
18
+ - 2.7-bionic
19
+ - 2.6-bionic
20
20
  job:
21
- - test
22
- - stdlib_test
23
- - rubocop validate test_doc build test_generate_stdlib
24
- - lexer confirm_lexer
25
- - lexer compile
21
+ - test
22
+ - stdlib_test
23
+ - rubocop validate test_doc build test_generate_stdlib
24
+ - lexer confirm_lexer
25
+ - lexer compile
26
26
  exclude:
27
- - container_tag: master-nightly-focal
28
- job: confirm_lexer
29
- - container_tag: 2.6-bionic
30
- job: stdlib_test
31
- - container_tag: 2.7-bionic
32
- job: stdlib_test
33
- - container_tag: 3.0-focal
34
- job: stdlib_test
27
+ - container_tag: master-nightly-focal
28
+ job: confirm_lexer
29
+ - container_tag: 2.6-bionic
30
+ job: stdlib_test
31
+ - container_tag: 2.7-bionic
32
+ job: stdlib_test
33
+ - container_tag: 3.0-focal
34
+ job: stdlib_test
35
35
  container:
36
36
  image: rubylang/ruby:${{ matrix.container_tag }}
37
37
  steps:
38
- - uses: actions/checkout@v3
39
- - name: Set working directory as safe
40
- run: /usr/bin/git config --global --add safe.directory $(pwd)
41
- - name: Install dependencies
42
- run: |
43
- apt-get update
44
- apt-get install -y libdb-dev curl autoconf automake m4 libtool
45
- - name: Install Re2c
46
- if: contains(matrix.job, 'lexer')
47
- run: |
48
- cd /tmp
49
- curl -L https://github.com/skvadrik/re2c/archive/refs/tags/3.0.tar.gz > re2c-3.0.tar.gz
50
- tar xf re2c-3.0.tar.gz
51
- cd re2c-3.0
52
- autoreconf -i -W all
53
- ./configure
54
- make
55
- make install
56
- - name: Update rubygems & bundler
57
- run: |
58
- ruby -v
59
- gem update --system
60
- - name: bundle config set with
61
- run: |
62
- echo "NO_MINITEST=true" >> $GITHUB_ENV
63
- bundle config set --local without 'minitest'
64
- if: "contains(matrix.container_tag, 'master-nightly')"
65
- - name: bin/setup
66
- run: |
67
- bin/setup
68
- - name: Run test
69
- run: |
70
- bundle exec rake ${{ matrix.job }}
38
+ - uses: actions/checkout@v3
39
+ - name: Set working directory as safe
40
+ run: /usr/bin/git config --global --add safe.directory $(pwd)
41
+ - name: Install dependencies
42
+ run: |
43
+ apt-get update
44
+ apt-get install -y libdb-dev curl autoconf automake m4 libtool
45
+ - name: Install Re2c
46
+ if: contains(matrix.job, 'lexer')
47
+ run: |
48
+ cd /tmp
49
+ curl -L https://github.com/skvadrik/re2c/archive/refs/tags/3.0.tar.gz > re2c-3.0.tar.gz
50
+ tar xf re2c-3.0.tar.gz
51
+ cd re2c-3.0
52
+ autoreconf -i -W all
53
+ ./configure
54
+ make
55
+ make install
56
+ - name: Update rubygems & bundler
57
+ run: |
58
+ ruby -v
59
+ gem update --system
60
+ - name: bundle config set with
61
+ run: |
62
+ echo "NO_MINITEST=true" >> $GITHUB_ENV
63
+ bundle config set --local without 'minitest'
64
+ if: "contains(matrix.container_tag, 'master-nightly')"
65
+ - name: bin/setup
66
+ run: |
67
+ bin/setup
68
+ - name: Run test
69
+ run: |
70
+ bundle exec rake ${{ matrix.job }}
71
71
 
72
72
  windows:
73
73
  runs-on: ${{ matrix.os }}
74
74
  strategy:
75
75
  fail-fast: false
76
76
  matrix:
77
- os: [ windows-2019, windows-2022 ]
78
- ruby: [ ucrt, mswin ]
77
+ os: [windows-2019, windows-2022]
78
+ ruby: [ucrt, mswin]
79
79
  steps:
80
80
  - uses: actions/checkout@v3
81
81
  - name: load ruby
data/CHANGELOG.md CHANGED
@@ -2,6 +2,50 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 2.8.0 (2022-11-24)
6
+
7
+ ### Signature updates
8
+
9
+ * random ([#1144](https://github.com/ruby/rbs/pull/1144))
10
+
11
+ ### Library changes
12
+
13
+ * Fix SEGV when give invalid object to `variables:` ([#1153](https://github.com/ruby/rbs/pull/1153))
14
+
15
+ ### Miscellaneous
16
+
17
+ * Fix some typos ([#1155](https://github.com/ruby/rbs/pull/1155))
18
+ * Fix a formatting some YAML files ([#1154](https://github.com/ruby/rbs/pull/1154))
19
+
20
+ ## 2.8.0.pre.1 (2022-11-17)
21
+
22
+ ### Signature updates
23
+
24
+ * `IO` ([#1132](https://github.com/ruby/rbs/pull/1132))
25
+ * `IO::Buffer` ([#1137](https://github.com/ruby/rbs/pull/1137))
26
+ * `IPAddr` ([#1131](https://github.com/ruby/rbs/pull/1131), [#1151](https://github.com/ruby/rbs/pull/1151))
27
+ * `Socket` ([#1133](https://github.com/ruby/rbs/pull/1133), [#1134](https://github.com/ruby/rbs/pull/1134), [#1151](https://github.com/ruby/rbs/pull/1151))
28
+ * `Yaml` ([#1141](https://github.com/ruby/rbs/pull/1141))
29
+
30
+ ### Library changes
31
+
32
+ * Make type/method-type parser more flexible about input position ([#1140](https://github.com/ruby/rbs/pull/1140))
33
+ * Raise an error if a class definition inherits a module ([#1152](https://github.com/ruby/rbs/pull/1152))
34
+ * Fix SEGV when parse with invalid content ([#1146](https://github.com/ruby/rbs/pull/1146))
35
+
36
+ #### rbs collection
37
+
38
+ * Support to call collection command in child dir ([#1025](https://github.com/ruby/rbs/pull/1025), [#1135](https://github.com/ruby/rbs/pull/1135))
39
+
40
+ ### Miscellaneous
41
+
42
+ * Remove `rubygems` from `rbs`’s manifest ([#1150](https://github.com/ruby/rbs/pull/1150))
43
+ * Use `untyped` instead of `any` in `syntax.md` ([#1147](https://github.com/ruby/rbs/pull/1147))
44
+ * Fix typo and grammatical mistakes in "Generics" section of `syntax.md` ([#1127](https://github.com/ruby/rbs/pull/1127))
45
+ * Add a doc that describes tools related to RBS ([#1125](https://github.com/ruby/rbs/pull/1125))
46
+ * Add self-type-bindings to `syntax.md` ([#1123](https://github.com/ruby/rbs/pull/1123))
47
+ * Add documentation for `...` in `syntax.md` ([#1120](https://github.com/ruby/rbs/pull/1120))
48
+
5
49
  ## 2.7.0 (2022-10-07)
6
50
 
7
51
  ### Signature updates
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbs (2.7.0)
4
+ rbs (2.8.0)
5
5
 
6
6
  PATH
7
7
  remote: test/assets/test-gem
@@ -47,32 +47,32 @@ GEM
47
47
  rake
48
48
  rdoc (6.4.0)
49
49
  psych (>= 4.0.0)
50
- regexp_parser (2.5.0)
50
+ regexp_parser (2.6.0)
51
51
  rexml (3.2.5)
52
- rspec (3.11.0)
53
- rspec-core (~> 3.11.0)
54
- rspec-expectations (~> 3.11.0)
55
- rspec-mocks (~> 3.11.0)
56
- rspec-core (3.11.0)
57
- rspec-support (~> 3.11.0)
58
- rspec-expectations (3.11.0)
52
+ rspec (3.12.0)
53
+ rspec-core (~> 3.12.0)
54
+ rspec-expectations (~> 3.12.0)
55
+ rspec-mocks (~> 3.12.0)
56
+ rspec-core (3.12.0)
57
+ rspec-support (~> 3.12.0)
58
+ rspec-expectations (3.12.0)
59
59
  diff-lcs (>= 1.2.0, < 2.0)
60
- rspec-support (~> 3.11.0)
61
- rspec-mocks (3.11.1)
60
+ rspec-support (~> 3.12.0)
61
+ rspec-mocks (3.12.0)
62
62
  diff-lcs (>= 1.2.0, < 2.0)
63
- rspec-support (~> 3.11.0)
64
- rspec-support (3.11.0)
65
- rubocop (1.36.0)
63
+ rspec-support (~> 3.12.0)
64
+ rspec-support (3.12.0)
65
+ rubocop (1.38.0)
66
66
  json (~> 2.3)
67
67
  parallel (~> 1.10)
68
68
  parser (>= 3.1.2.1)
69
69
  rainbow (>= 2.2.2, < 4.0)
70
70
  regexp_parser (>= 1.8, < 3.0)
71
71
  rexml (>= 3.2.5, < 4.0)
72
- rubocop-ast (>= 1.20.1, < 2.0)
72
+ rubocop-ast (>= 1.23.0, < 2.0)
73
73
  ruby-progressbar (~> 1.7)
74
74
  unicode-display_width (>= 1.4.0, < 3.0)
75
- rubocop-ast (1.21.0)
75
+ rubocop-ast (1.23.0)
76
76
  parser (>= 3.1.1.0)
77
77
  rubocop-rubycw (0.1.6)
78
78
  rubocop (~> 1.0)
@@ -80,13 +80,13 @@ GEM
80
80
  rake (>= 0.8.1)
81
81
  ruby-progressbar (1.11.0)
82
82
  singleton (0.1.1)
83
- stackprof (0.2.21)
83
+ stackprof (0.2.22)
84
84
  stringio (3.0.2)
85
85
  strong_json (2.1.2)
86
86
  tempfile (0.1.2)
87
87
  test-unit (3.5.5)
88
88
  power_assert
89
- unicode-display_width (2.2.0)
89
+ unicode-display_width (2.3.0)
90
90
 
91
91
  PLATFORMS
92
92
  ruby
data/Steepfile CHANGED
@@ -9,14 +9,12 @@ target :lib do
9
9
  "lib/rbs/test.rb"
10
10
  )
11
11
 
12
- library "set", "pathname", "json", "logger", "monitor", "tsort", "uri", 'yaml', 'dbm', 'pstore', 'singleton', 'shellwords', 'fileutils', 'find', 'digest'
12
+ library "set", "pathname", "json", "logger", "monitor", "tsort", "uri", 'dbm', 'pstore', 'singleton', 'shellwords', 'fileutils', 'find', 'digest'
13
+ signature 'stdlib/yaml/0'
13
14
  signature "stdlib/strscan/0/"
14
15
  signature "stdlib/optparse/0/"
15
16
  signature "stdlib/rdoc/0/"
16
17
 
17
- # Please remove the following line after releasing #1107
18
- signature "core/rubygems/"
19
-
20
18
  configure_code_diagnostics do |config|
21
19
  config[D::Ruby::MethodDefinitionMissing] = :hint
22
20
  config[D::Ruby::ElseOnExhaustiveCase] = :hint
data/core/io/buffer.rbs CHANGED
@@ -706,5 +706,20 @@ class IO
706
706
  PRIVATE: Integer
707
707
 
708
708
  READONLY: Integer
709
+
710
+ class LockedError < RuntimeError
711
+ end
712
+
713
+ class AllocationError < RuntimeError
714
+ end
715
+
716
+ class AccessError < RuntimeError
717
+ end
718
+
719
+ class InvalidatedError < RuntimeError
720
+ end
721
+
722
+ class MaskError < ArgumentError
723
+ end
709
724
  end
710
725
  end
data/core/io.rbs CHANGED
@@ -2984,6 +2984,12 @@ IO::TRUNC: Integer
2984
2984
 
2985
2985
  IO::WRONLY: Integer
2986
2986
 
2987
+ IO::READABLE: Integer
2988
+
2989
+ IO::WRITABLE: Integer
2990
+
2991
+ IO::PRIORITY: Integer
2992
+
2987
2993
  # <!-- rdoc-file=io.c -->
2988
2994
  # exception to wait for reading by EAGAIN. see IO.select.
2989
2995
  #
data/core/random.rbs CHANGED
@@ -21,6 +21,26 @@
21
21
  # use SecureRandom for security purpose, instead of this PRNG.
22
22
  #
23
23
  class Random < RBS::Unnamed::Random_Base
24
+ # <!--
25
+ # rdoc-file=random.c
26
+ # - Random.new(seed = Random.new_seed) -> prng
27
+ # -->
28
+ # Creates a new PRNG using `seed` to set the initial state. If `seed` is
29
+ # omitted, the generator is initialized with Random.new_seed.
30
+ #
31
+ # See Random.srand for more information on the use of seed values.
32
+ #
33
+ def initialize: (?Integer seed) -> void
34
+
35
+ # <!--
36
+ # rdoc-file=random.c
37
+ # - Random.bytes(size) -> string
38
+ # -->
39
+ # Returns a random binary string. The argument `size` specifies the length of
40
+ # the returned string.
41
+ #
42
+ def self.bytes: (Integer size) -> String
43
+
24
44
  # <!--
25
45
  # rdoc-file=random.c
26
46
  # - prng1 == prng2 -> true or false
@@ -71,6 +91,7 @@ class Random < RBS::Unnamed::Random_Base
71
91
  def self.rand: () -> Float
72
92
  | (Integer | ::Range[Integer] max) -> Integer
73
93
  | (Float | ::Range[Float] max) -> Float
94
+ | [T < Numeric] (::Range[T]) -> T
74
95
 
75
96
  # <!--
76
97
  # rdoc-file=random.c
@@ -95,6 +116,52 @@ class Random < RBS::Unnamed::Random_Base
95
116
  # [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319]
96
117
  #
97
118
  def self.srand: (?Integer number) -> Integer
119
+
120
+ # <!--
121
+ # rdoc-file=random.c
122
+ # - Random.urandom(size) -> string
123
+ # -->
124
+ # Returns a string, using platform providing features. Returned value is
125
+ # expected to be a cryptographically secure pseudo-random number in binary form.
126
+ # This method raises a RuntimeError if the feature provided by platform failed
127
+ # to prepare the result.
128
+ #
129
+ # In 2017, Linux manpage random(7) writes that "no cryptographic primitive
130
+ # available today can hope to promise more than 256 bits of security". So it
131
+ # might be questionable to pass size > 32 to this method.
132
+ #
133
+ # Random.urandom(8) #=> "\x78\x41\xBA\xAF\x7D\xEA\xD8\xEA"
134
+ #
135
+ def self.urandom: (Integer) -> String
136
+
137
+ # <!--
138
+ # rdoc-file=random.c
139
+ # - prng.seed -> integer
140
+ # -->
141
+ # Returns the seed value used to initialize the generator. This may be used to
142
+ # initialize another generator with the same state at a later time, causing it
143
+ # to produce the same sequence of numbers.
144
+ #
145
+ # prng1 = Random.new(1234)
146
+ # prng1.seed #=> 1234
147
+ # prng1.rand(100) #=> 47
148
+ #
149
+ # prng2 = Random.new(prng1.seed)
150
+ # prng2.rand(100) #=> 47
151
+ #
152
+ def seed: () -> Integer
153
+
154
+ private
155
+
156
+ def initialize_copy: (self object) -> self
157
+
158
+ def left: () -> untyped
159
+
160
+ def marshal_dump: () -> untyped
161
+
162
+ def marshal_load: (untyped) -> untyped
163
+
164
+ def state: () -> untyped
98
165
  end
99
166
 
100
167
  Random::DEFAULT: Random
@@ -176,7 +176,7 @@ the type variable `Elem`, and the `?` suffix nilable marker.
176
176
  When called with an `Integer` positional argument, the return value will be an
177
177
  `Array` of whatever type is contained.
178
178
 
179
- The `?` syntax is a convenient shorthand for a union with nil. An equivalent union type woould be `(Elem | nil)`.
179
+ The `?` syntax is a convenient shorthand for a union with nil. An equivalent union type would be `(Elem | nil)`.
180
180
 
181
181
  ### Keyword Arguments
182
182
 
data/docs/syntax.md CHANGED
@@ -3,18 +3,17 @@
3
3
  ## Types
4
4
 
5
5
  ```markdown
6
- _type_ ::= _class-name_ _type-arguments_ (Class instance type)
7
- | _interface-name_ _type-arguments_ (Interface type)
8
- | _alias-name_ _type-arguments_ (Alias type)
9
- | `singleton(` _class-name_ `)` (Class singleton type)
10
- | _literal_ (Literal type)
11
- | _type_ `|` _type_ (Union type)
12
- | _type_ `&` _type_ (Intersection type)
13
- | _type_ `?` (Optional type)
14
- | `{` _record-name_ `:` _type_ `,` etc. `}` (Record type)
15
- | `[]` | `[` _type_ `,` etc. `]` (Tuples)
16
- | _type-variable_ (Type variables)
17
- | `^(` _parameters_ `) ->` _type_ (Proc type)
6
+ _type_ ::= _class-name_ _type-arguments_ (Class instance type)
7
+ | _interface-name_ _type-arguments_ (Interface type)
8
+ | _alias-name_ _type-arguments_ (Alias type)
9
+ | `singleton(` _class-name_ `)` (Class singleton type)
10
+ | _literal_ (Literal type)
11
+ | _type_ `|` _type_ (Union type)
12
+ | _type_ `&` _type_ (Intersection type)
13
+ | _type_ `?` (Optional type)
14
+ | `{` _record-name_ `:` _type_ `,` etc. `}` (Record type)
15
+ | `[]` | `[` _type_ `,` etc. `]` (Tuples)
16
+ | _type-variable_ (Type variables)
18
17
  | `self`
19
18
  | `instance`
20
19
  | `class`
@@ -24,6 +23,7 @@ _type_ ::= _class-name_ _type-arguments_ (Class instance type)
24
23
  | `top`
25
24
  | `bot`
26
25
  | `void`
26
+ | _proc_ (Proc type)
27
27
 
28
28
  _class-name_ ::= _namespace_ /[A-Z]\w*/
29
29
  _interface-name_ ::= _namespace_ /_[A-Z]\w*/
@@ -43,6 +43,8 @@ _literal_ ::= _string-literal_
43
43
  | _integer-literal_
44
44
  | `true`
45
45
  | `false`
46
+
47
+ _proc_ ::= _parameters?_ _self-type-binding?_ _block?_ `->` _type_
46
48
  ```
47
49
 
48
50
  ### Class instance type
@@ -164,15 +166,6 @@ class Ref[T] # Object is scoped in the class declaration.
164
166
  end
165
167
  ```
166
168
 
167
- ### Proc type
168
-
169
- Proc type denotes type of procedures, `Proc` instances.
170
-
171
- ```
172
- ^(Integer) -> String # A procedure with an `Integer` parameter and returns `String`
173
- ^(?String, size: Integer) -> bool # A procedure with `String` optional parameter, `size` keyword of `Integer`, and returns `bool`
174
- ```
175
-
176
169
  ### Base types
177
170
 
178
171
  `self` denotes the type of receiver. The type is used to model the open recursion via `self`.
@@ -221,14 +214,28 @@ They are all equivalent for the type system; they are all _top type_.
221
214
 
222
215
  `void` tells developers a hint that _the value should not be used_. `boolish` implies the value is used as a truth value. `top` is anything else.
223
216
 
224
- ## Method Types
217
+ ### Proc type
218
+
219
+ Proc type denotes type of procedures, `Proc` instances.
220
+
221
+ ```
222
+ ^(Integer) -> String # A procedure with an `Integer` parameter and returns `String`
223
+ ^(?String, size: Integer) -> bool # A procedure with `String` optional parameter, `size` keyword of `Integer`, and returns `bool`
224
+ ```
225
+
226
+ See the next section for details.
227
+
228
+ ## Method Types and Proc Types
225
229
 
226
230
  ```markdown
227
- _method-type_ ::= `(` _parameters_ `) ->` _type_ # Method without block
228
- | `(` _parameters_ `) { (` _parameters_ `) -> ` _type_ `} ->` _type_ # Method with required block
229
- | `(` _parameters_ `) ?{ (` _parameters_ `) -> ` _type_ `} ->` _type_ # Method with optional block
231
+ _method-type_ ::= _parameters?_ _block?_ `->` _type_ # Method type
232
+
233
+ _proc_ ::= `^` _parameters?_ _self-type-binding?_ _block?_ `->` _type_ # Proc type
230
234
 
231
- _parameters_ ::= _required-positionals_ _optional-positionals_ _rest-positional_ _trailing-positionals_ _keywords_
235
+ _parameters?_ ::= (Empty)
236
+ | _parameters_ (Parameters)
237
+
238
+ _parameters_ ::= `(` _required-positionals_ _optional-positionals_ _rest-positional_ _trailing-positionals_ _keywords_ `)`
232
239
 
233
240
  _parameter_ ::= _type_ _var-name_ # Parameter with var name
234
241
  | _type_ # Parameter without var name
@@ -243,6 +250,13 @@ _keywords_ ::= # Empty
243
250
  | `?` _keyword_ `:` _parameter_ `,` _keywords_ # Optional keyword
244
251
 
245
252
  _var-name_ ::= /[a-z]\w*/
253
+
254
+ _self-type-binding?_ = (Empty)
255
+ | `[` `self` `:` _type_ `]` (Self type binding)
256
+
257
+ _block?_ = (No block)
258
+ | `{` _parameters_ _self-type-binding?_ `->` _type_ `}` (Block)
259
+ | `?` `{` _parameters_ _self-type-binding?_ `->` _type_ `}` (Optional block)
246
260
  ```
247
261
 
248
262
  ### Parameters
@@ -250,7 +264,7 @@ _var-name_ ::= /[a-z]\w*/
250
264
  A parameter can be a type or a pair of type and variable name.
251
265
  Variable name can be used for documentation.
252
266
 
253
- ### Examples
267
+ #### Examples
254
268
 
255
269
  ```
256
270
  # Two required positional `Integer` parameters, and returns `String`
@@ -269,6 +283,29 @@ Variable name can be used for documentation.
269
283
  (size: Integer sz, ?name: String, ?created_at: Time?) -> void
270
284
  ```
271
285
 
286
+ ### Self type binding
287
+
288
+ Self type binding represents the type of methods that uses `#instance_eval`, which replaces the value of `self` inside blocks.
289
+
290
+ ```ruby
291
+ 123.instance_eval do
292
+ self + 1 # self is `123` here
293
+ end
294
+ ```
295
+
296
+ Proc types and blocks can have self type bindings.
297
+
298
+ ```rbs
299
+ ^(Integer) [self: String] -> void # Proc type with self type binding
300
+ ^(Integer) [self: String] { (Symbol) [self: bool] -> void } -> void # Proc type with self type binding of `String` and a block with self type binding of `bool`
301
+ ```
302
+
303
+ Method type can have blocks with self type bindings.
304
+
305
+ ```rbs
306
+ () { (Integer) [self: String] -> void } -> void # A method type with block with self type binding
307
+ ```
308
+
272
309
  ## Members
273
310
 
274
311
  ```markdown
@@ -349,6 +386,14 @@ def +: (Float) -> Float
349
386
  | (Numeric) -> Numeric
350
387
  ```
351
388
 
389
+ Overloaded method can have `...` to overload an existing method. It is useful for monkey-patching.
390
+
391
+ ```
392
+ def +: (Float) -> Float
393
+ def +: (BigDecimal) -> BigDecimal
394
+ | ...
395
+ ```
396
+
352
397
  You need extra parentheses on return type to avoid ambiguity.
353
398
 
354
399
  ```
@@ -516,7 +561,7 @@ Interface declaration can have parameters but allows only a few of the members.
516
561
  ```
517
562
  interface _Hashing
518
563
  def hash: () -> Integer
519
- def eql?: (any) -> bool
564
+ def eql?: (untyped) -> bool
520
565
  end
521
566
  ```
522
567
 
@@ -574,8 +619,8 @@ _generics-bound_ ::= (No type bound)
574
619
  | `<` _bound-type_ (The generics parameter is bounded)
575
620
 
576
621
  _bound-type_ ::= _class-name_ _type-arguments_ (Class instance type)
577
- | _interface-name_ _type-arguments_ (Interface type)
578
- | `singleton(` _class-name_ `)` (Class singleton type)
622
+ | _interface-name_ _type-arguments_ (Interface type)
623
+ | `singleton(` _class-name_ `)` (Class singleton type)
579
624
 
580
625
  _generics-variance_ ::= (Invariant)
581
626
  | `out` (Covariant)
@@ -607,8 +652,8 @@ class Array[out T]
607
652
  end
608
653
  ```
609
654
 
610
- There's a limitation with this is for mutable objects (like arrays): a mutation could invalidate this.
611
- If an array of `String` is passed to a method as an array of `Objects`, and that method adds an Integer to the array, the promise is broken.
655
+ There's a limitation with this for mutable objects (like arrays): a mutation could invalidate this.
656
+ If an `Array` of `String` is passed to a method as an `Array` of `Object`, and that method adds an `Integer` to the `Array`, the promise is broken.
612
657
 
613
658
  In those cases, one must use the `unchecked` keyword:
614
659
 
data/docs/tools.md ADDED
@@ -0,0 +1,16 @@
1
+ # Tools
2
+
3
+ This documentation describes major tools related to RBS. They are listed alphabetically.
4
+
5
+ ## Type Checkers
6
+
7
+ * [Steep](https://github.com/soutaro/steep) is a static type checker based on RBS. You can use it as a language server integrated with an editor or IDE and run it from the command line.
8
+ * [TypeProf](https://github.com/ruby/typeprof)
9
+
10
+ ## Editor integrations
11
+
12
+ * Emacs: [rbs-mode](https://github.com/ybiquitous/rbs-mode)
13
+ * RubyMine: [It supports RBS by default](https://www.jetbrains.com/help/ruby/rbs.html)
14
+ * Sublime Text: [sublime-rbs-plugin](https://github.com/soutaro/sublime-rbs-plugin)
15
+ * Vim: [rbs.vim](https://github.com/pocke/rbs.vim)
16
+ * Visual Studio Code: [vscode-rbs-syntax](https://github.com/soutaro/vscode-rbs-syntax)