rbs 3.3.2 → 3.4.0.pre.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 (128) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +2 -5
  3. data/.github/workflows/ruby.yml +7 -8
  4. data/.github/workflows/typecheck.yml +37 -0
  5. data/CHANGELOG.md +50 -0
  6. data/Gemfile +1 -1
  7. data/Gemfile.lock +11 -11
  8. data/Steepfile +2 -2
  9. data/core/array.rbs +19 -49
  10. data/core/basic_object.rbs +2 -2
  11. data/core/comparable.rbs +17 -8
  12. data/core/complex.rbs +82 -43
  13. data/core/data.rbs +2 -4
  14. data/core/dir.rbs +635 -295
  15. data/core/enumerable.rbs +11 -18
  16. data/core/enumerator.rbs +37 -31
  17. data/core/errors.rbs +4 -0
  18. data/core/false_class.rbs +34 -15
  19. data/core/fiber.rbs +23 -0
  20. data/core/file.rbs +329 -120
  21. data/core/float.rbs +17 -32
  22. data/core/gc.rbs +17 -11
  23. data/core/hash.rbs +22 -44
  24. data/core/integer.rbs +82 -113
  25. data/core/io/buffer.rbs +90 -47
  26. data/core/io.rbs +39 -116
  27. data/core/kernel.rbs +442 -489
  28. data/core/match_data.rbs +55 -56
  29. data/core/module.rbs +45 -1
  30. data/core/nil_class.rbs +98 -35
  31. data/core/numeric.rbs +22 -32
  32. data/core/object_space/weak_key_map.rbs +102 -0
  33. data/core/process.rbs +1242 -655
  34. data/core/ractor.rbs +139 -120
  35. data/core/range.rbs +100 -4
  36. data/core/rational.rbs +0 -4
  37. data/core/rbs/unnamed/argf.rbs +16 -8
  38. data/core/rbs/unnamed/env_class.rbs +0 -24
  39. data/core/refinement.rbs +8 -0
  40. data/core/regexp.rbs +1149 -598
  41. data/core/ruby_vm.rbs +126 -12
  42. data/core/rubygems/platform.rbs +9 -0
  43. data/core/rubygems/rubygems.rbs +1 -1
  44. data/core/rubygems/version.rbs +5 -1
  45. data/core/set.rbs +20 -22
  46. data/core/signal.rbs +4 -4
  47. data/core/string.rbs +283 -230
  48. data/core/string_io.rbs +2 -14
  49. data/core/struct.rbs +404 -24
  50. data/core/symbol.rbs +1 -19
  51. data/core/thread.rbs +29 -12
  52. data/core/time.rbs +227 -104
  53. data/core/trace_point.rbs +2 -5
  54. data/core/true_class.rbs +54 -21
  55. data/core/warning.rbs +14 -11
  56. data/docs/data_and_struct.md +29 -0
  57. data/docs/syntax.md +3 -5
  58. data/docs/tools.md +1 -0
  59. data/ext/rbs_extension/lexer.c +643 -559
  60. data/ext/rbs_extension/lexer.re +5 -1
  61. data/ext/rbs_extension/parser.c +12 -3
  62. data/ext/rbs_extension/unescape.c +7 -47
  63. data/lib/rbs/cli/diff.rb +4 -1
  64. data/lib/rbs/cli/validate.rb +280 -0
  65. data/lib/rbs/cli.rb +2 -194
  66. data/lib/rbs/collection/config.rb +5 -6
  67. data/lib/rbs/collection/sources/git.rb +1 -1
  68. data/lib/rbs/collection.rb +1 -0
  69. data/lib/rbs/diff.rb +7 -4
  70. data/lib/rbs/errors.rb +11 -0
  71. data/lib/rbs/test/errors.rb +4 -1
  72. data/lib/rbs/test/guaranteed.rb +2 -3
  73. data/lib/rbs/test/type_check.rb +15 -10
  74. data/lib/rbs/test.rb +3 -3
  75. data/lib/rbs/types.rb +29 -0
  76. data/lib/rbs/unit_test/convertibles.rb +176 -0
  77. data/lib/rbs/unit_test/spy.rb +136 -0
  78. data/lib/rbs/unit_test/type_assertions.rb +341 -0
  79. data/lib/rbs/unit_test/with_aliases.rb +143 -0
  80. data/lib/rbs/unit_test.rb +6 -0
  81. data/lib/rbs/version.rb +1 -1
  82. data/sig/cli/validate.rbs +43 -0
  83. data/sig/diff.rbs +3 -1
  84. data/sig/errors.rbs +8 -0
  85. data/sig/rbs.rbs +1 -1
  86. data/sig/test/errors.rbs +52 -0
  87. data/sig/test/guranteed.rbs +9 -0
  88. data/sig/test/type_check.rbs +19 -0
  89. data/sig/test.rbs +82 -0
  90. data/sig/types.rbs +6 -1
  91. data/sig/unit_test/convertibles.rbs +154 -0
  92. data/sig/unit_test/spy.rbs +28 -0
  93. data/sig/unit_test/type_assertions.rbs +194 -0
  94. data/sig/unit_test/with_aliases.rbs +136 -0
  95. data/stdlib/base64/0/base64.rbs +307 -45
  96. data/stdlib/bigdecimal/0/big_decimal.rbs +35 -15
  97. data/stdlib/coverage/0/coverage.rbs +2 -2
  98. data/stdlib/csv/0/csv.rbs +25 -55
  99. data/stdlib/date/0/date.rbs +1 -43
  100. data/stdlib/date/0/date_time.rbs +1 -13
  101. data/stdlib/delegate/0/delegator.rbs +186 -0
  102. data/stdlib/delegate/0/kernel.rbs +47 -0
  103. data/stdlib/delegate/0/simple_delegator.rbs +98 -0
  104. data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -1
  105. data/stdlib/erb/0/erb.rbs +2 -2
  106. data/stdlib/fileutils/0/fileutils.rbs +0 -19
  107. data/stdlib/io-console/0/io-console.rbs +12 -1
  108. data/stdlib/ipaddr/0/ipaddr.rbs +2 -1
  109. data/stdlib/json/0/json.rbs +320 -81
  110. data/stdlib/logger/0/logger.rbs +9 -5
  111. data/stdlib/monitor/0/monitor.rbs +78 -0
  112. data/stdlib/net-http/0/net-http.rbs +1880 -543
  113. data/stdlib/objspace/0/objspace.rbs +19 -13
  114. data/stdlib/openssl/0/openssl.rbs +508 -127
  115. data/stdlib/optparse/0/optparse.rbs +25 -11
  116. data/stdlib/pathname/0/pathname.rbs +1 -1
  117. data/stdlib/pp/0/pp.rbs +2 -5
  118. data/stdlib/prettyprint/0/prettyprint.rbs +2 -2
  119. data/stdlib/pstore/0/pstore.rbs +2 -4
  120. data/stdlib/rdoc/0/comment.rbs +1 -2
  121. data/stdlib/resolv/0/resolv.rbs +4 -2
  122. data/stdlib/socket/0/socket.rbs +2 -2
  123. data/stdlib/socket/0/unix_socket.rbs +2 -2
  124. data/stdlib/strscan/0/string_scanner.rbs +3 -2
  125. data/stdlib/tempfile/0/tempfile.rbs +1 -1
  126. data/stdlib/uri/0/common.rbs +245 -123
  127. metadata +23 -4
  128. data/lib/rbs/test/spy.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27004297e5bb976aba56b115d26288536b31acd15a38ea42841a0efd4dae6fe8
4
- data.tar.gz: 4772b6936d87c79bc7b450f636389346be60c86eb8ec9827c2dcacacaf0056ae
3
+ metadata.gz: 48c814d4cbaac5fe01ca09ff353a0fdde62a95b37a677e398925e0f1905b5a4f
4
+ data.tar.gz: 3e8ff356790ab3879392996f26db15d0c0e01686a7e496ee4c6e26f9b326b9b2
5
5
  SHA512:
6
- metadata.gz: '01394e99526697c6285db28bbacf32a787308e98b885c41b41ebeb49776cbe3e3a2dbd81d566634c46b4ba16ad3b4013fbe3e776cf1e608b253bba50932d844a'
7
- data.tar.gz: cebafcc273581a42e7784468b8a00ca29ddd17be0d287b981ca6f1cb211c3f85cb22d73152955532f7e94e7dd2ab4e003ed05c3606aa6426ea9a622d98dc8f8b
6
+ metadata.gz: a14fdcafb7e142a4685fd31325900e24aceee40c17b453e87800bebcc1958e02d9ade0ff912ef711650a8e1ca8adae62c150ccd8377a6859d687be55ba999440
7
+ data.tar.gz: 8c69b1dafc7738fb35c6da0a12c33ac7fdc7bcd75f7fcefaf4dc68383b85fb3717fc21ca632d151ec9182633ebea115160edf44324681275de8dbfd945e7ba02
@@ -12,6 +12,8 @@ jobs:
12
12
  runs-on: "ubuntu-latest"
13
13
  container:
14
14
  image: rubylang/ruby:3.2-dev-focal
15
+ env:
16
+ RUBY_COMMIT: v3_3_0_rc1
15
17
  steps:
16
18
  - uses: actions/checkout@v4
17
19
  - name: Install dependencies
@@ -22,11 +24,6 @@ jobs:
22
24
  run: |
23
25
  ruby -v
24
26
  gem update --system
25
- - name: bundle config set with
26
- run: |
27
- echo "NO_MINITEST=true" >> $GITHUB_ENV
28
- bundle config set --local without 'minitest'
29
- if: "contains(matrix.container_tag, 'master-nightly')"
30
27
  - name: bin/setup
31
28
  run: |
32
29
  bin/setup
@@ -31,9 +31,8 @@ jobs:
31
31
  job: stdlib_test
32
32
  - container_tag: 3.1-dev-focal
33
33
  job: stdlib_test
34
- include:
35
- - container_tag: master-nightly-focal
36
- allow_failures: "true"
34
+ - container_tag: 3.2-dev-focal
35
+ job: stdlib_test
37
36
  container:
38
37
  image: rubylang/ruby:${{ matrix.container_tag }}
39
38
  steps:
@@ -43,14 +42,14 @@ jobs:
43
42
  - name: Install dependencies
44
43
  run: |
45
44
  apt-get update
46
- apt-get install -y libdb-dev curl autoconf automake m4 libtool
45
+ apt-get install -y libdb-dev curl autoconf automake m4 libtool python3
47
46
  - name: Install Re2c
48
47
  if: contains(matrix.job, 'lexer')
49
48
  run: |
50
49
  cd /tmp
51
- curl -L https://github.com/skvadrik/re2c/archive/refs/tags/3.0.tar.gz > re2c-3.0.tar.gz
52
- tar xf re2c-3.0.tar.gz
53
- cd re2c-3.0
50
+ curl -L https://github.com/skvadrik/re2c/archive/refs/tags/3.1.tar.gz > re2c-3.1.tar.gz
51
+ tar xf re2c-3.1.tar.gz
52
+ cd re2c-3.1
54
53
  autoreconf -i -W all
55
54
  ./configure
56
55
  make
@@ -63,7 +62,7 @@ jobs:
63
62
  run: |
64
63
  echo "NO_MINITEST=true" >> $GITHUB_ENV
65
64
  bundle config set --local without 'minitest'
66
- if: "contains(matrix.container_tag, 'master-nightly')"
65
+ if: ${{ contains(matrix.container_tag, 'master-nightly') }}
67
66
  - name: bin/setup
68
67
  run: |
69
68
  bin/setup
@@ -0,0 +1,37 @@
1
+ name: Type check
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request: {}
8
+ merge_group: {}
9
+
10
+ jobs:
11
+ test:
12
+ runs-on: "ubuntu-latest"
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ container_tag:
17
+ - 3.2-dev-focal
18
+ container:
19
+ image: rubylang/ruby:${{ matrix.container_tag }}
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - name: Set working directory as safe
23
+ run: git config --global --add safe.directory $(pwd)
24
+ - name: Install dependencies
25
+ run: |
26
+ apt-get update
27
+ apt-get install -y libdb-dev curl autoconf automake m4 libtool
28
+ - name: Update rubygems & bundler
29
+ run: |
30
+ ruby -v
31
+ gem update --system
32
+ - name: bin/setup
33
+ run: |
34
+ bin/setup
35
+ - name: Run steep check
36
+ run: |
37
+ bin/steep check -j 2
data/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 3.4.0.pre.1 (2023-12-19)
6
+
7
+ ### Signature updates
8
+
9
+ * Changes in ruby-3.3 ([#1684](https://github.com/ruby/rbs/pull/1684), [#1674](https://github.com/ruby/rbs/pull/1674))
10
+ * Embedded docs update ([#1689](https://github.com/ruby/rbs/pull/1689), [#1676](https://github.com/ruby/rbs/pull/1676))
11
+ * delegate ([#1677](https://github.com/ruby/rbs/pull/1677))
12
+ * `MatchData` ([#1651](https://github.com/ruby/rbs/pull/1651))
13
+ * `String` ([#1672](https://github.com/ruby/rbs/pull/1672), [#1641](https://github.com/ruby/rbs/pull/1641))
14
+ * `Struct` ([#1621](https://github.com/ruby/rbs/pull/1621))
15
+ * `Warning` categories ([#1576](https://github.com/ruby/rbs/pull/1576))
16
+ * `ConditionVariable#wait` ([#1670](https://github.com/ruby/rbs/pull/1670))
17
+ * `Date.parse` ([#1653](https://github.com/ruby/rbs/pull/1653))
18
+ * `IO#gets` ([#1620](https://github.com/ruby/rbs/pull/1620))
19
+ * `Kernel.Pathname` ([#1681](https://github.com/ruby/rbs/pull/1681))
20
+ * `Resolv::DNS::Resource::Generic.create` ([#1655](https://github.com/ruby/rbs/pull/1655))
21
+ * `Thread#raise` ([#1668](https://github.com/ruby/rbs/pull/1668))
22
+ * Builtin types ([#1680](https://github.com/ruby/rbs/pull/1680), [#1644](https://github.com/ruby/rbs/pull/1644))
23
+
24
+ ### Library changes
25
+
26
+ * Add more details error message for `UnresolvedOverloadingError` ([#1688](https://github.com/ruby/rbs/pull/1688))
27
+ * Add `with_***` helpers ([#1687](https://github.com/ruby/rbs/pull/1687))
28
+ * Fix lexer ([#1685](https://github.com/ruby/rbs/pull/1685))
29
+ * Support `Delegator` object ([#1682](https://github.com/ruby/rbs/pull/1682))
30
+ * Should raise `ParsingError` instead of NoMethodError ([#1675](https://github.com/ruby/rbs/pull/1675))
31
+ * Implement multiple validate ([#1648](https://github.com/ruby/rbs/pull/1648))
32
+ * Add `RBS::UnitTest` modules ([#1660](https://github.com/ruby/rbs/pull/1660))
33
+ * Not cached as it may be replaced ([#1656](https://github.com/ruby/rbs/pull/1656))
34
+ * Should raise `ParsingError` instead of ArgumentError ([#1652](https://github.com/ruby/rbs/pull/1652))
35
+ * Added `WithEnum#but` and `with_range` ([#1649](https://github.com/ruby/rbs/pull/1649))
36
+ * Bugfix; `.respond_to` is no longer used in `Rbs::Test::Errors#inspect_` ([#1650](https://github.com/ruby/rbs/pull/1650))
37
+ * Add `--detail` option to rbs diff ([#1623](https://github.com/ruby/rbs/pull/1623))
38
+ * Fix parse error when quoted required keywords ([#1627](https://github.com/ruby/rbs/pull/1627))
39
+
40
+ #### rbs collection
41
+
42
+ * Fix order for collection sources ([#1659](https://github.com/ruby/rbs/pull/1659))
43
+ * [collection] Ignore directory starting with `_` as version from git source ([#1657](https://github.com/ruby/rbs/pull/1657))
44
+
45
+ ### Miscellaneous
46
+
47
+ * Fix token names in comments ([#1658](https://github.com/ruby/rbs/pull/1658))
48
+ * Small bugfix to have guaranteed print out instance variables ([#1642](https://github.com/ruby/rbs/pull/1642))
49
+ * Fix flaky test ([#1616](https://github.com/ruby/rbs/pull/1616))
50
+ * Update syntax.md ([#1634](https://github.com/ruby/rbs/pull/1634))
51
+ * Add steep typecheck workflow ([#1632](https://github.com/ruby/rbs/pull/1632))
52
+ * Add doc for Generating RBS ([#1617](https://github.com/ruby/rbs/pull/1617))
53
+ * updated test harness utils ([#1600](https://github.com/ruby/rbs/pull/1600))
54
+
5
55
  ## 3.3.2 (2023-11-21)
6
56
 
7
57
  ### Miscellaneous
data/Gemfile CHANGED
@@ -17,7 +17,7 @@ gem "goodcheck"
17
17
  gem "dbm"
18
18
  gem 'digest'
19
19
  gem 'tempfile'
20
- gem "rdoc", "~> 6.4.0"
20
+ gem "rdoc"
21
21
 
22
22
  # Test gems
23
23
  gem "rbs-amber", path: "test/assets/test-gem"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbs (3.3.2)
4
+ rbs (3.4.0.pre.1)
5
5
  abbrev
6
6
 
7
7
  PATH
@@ -12,7 +12,7 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- abbrev (0.1.1)
15
+ abbrev (0.1.2)
16
16
  addressable (2.8.5)
17
17
  public_suffix (>= 2.0.2, < 6.0)
18
18
  ast (2.4.2)
@@ -24,7 +24,7 @@ GEM
24
24
  psych (>= 3.1, < 5.0)
25
25
  rainbow (>= 3.0, < 4.0)
26
26
  strong_json (>= 1.1, < 2.2)
27
- json (2.6.3)
27
+ json (2.7.1)
28
28
  json-schema (4.1.1)
29
29
  addressable (>= 2.8)
30
30
  language_server-protocol (3.17.0.3)
@@ -42,14 +42,14 @@ GEM
42
42
  psych (4.0.6)
43
43
  stringio
44
44
  public_suffix (5.0.3)
45
- racc (1.7.1)
45
+ racc (1.7.3)
46
46
  rainbow (3.1.1)
47
47
  rake (13.1.0)
48
48
  rake-compiler (1.2.5)
49
49
  rake
50
- rdoc (6.4.0)
50
+ rdoc (6.6.2)
51
51
  psych (>= 4.0.0)
52
- regexp_parser (2.8.2)
52
+ regexp_parser (2.8.3)
53
53
  rexml (3.2.6)
54
54
  rspec (3.12.0)
55
55
  rspec-core (~> 3.12.0)
@@ -64,7 +64,7 @@ GEM
64
64
  diff-lcs (>= 1.2.0, < 2.0)
65
65
  rspec-support (~> 3.12.0)
66
66
  rspec-support (3.12.0)
67
- rubocop (1.57.2)
67
+ rubocop (1.59.0)
68
68
  json (~> 2.3)
69
69
  language_server-protocol (>= 3.17.0)
70
70
  parallel (~> 1.10)
@@ -72,7 +72,7 @@ GEM
72
72
  rainbow (>= 2.2.2, < 4.0)
73
73
  regexp_parser (>= 1.8, < 3.0)
74
74
  rexml (>= 3.2.5, < 4.0)
75
- rubocop-ast (>= 1.28.1, < 2.0)
75
+ rubocop-ast (>= 1.30.0, < 2.0)
76
76
  ruby-progressbar (~> 1.7)
77
77
  unicode-display_width (>= 2.4.0, < 3.0)
78
78
  rubocop-ast (1.30.0)
@@ -81,9 +81,9 @@ GEM
81
81
  rubocop (~> 1.0)
82
82
  ruby-progressbar (1.13.0)
83
83
  stackprof (0.2.25)
84
- stringio (3.0.7)
84
+ stringio (3.1.0)
85
85
  strong_json (2.1.2)
86
- tempfile (0.2.0)
86
+ tempfile (0.2.1)
87
87
  test-unit (3.6.1)
88
88
  power_assert
89
89
  timeout (0.4.0)
@@ -105,7 +105,7 @@ DEPENDENCIES
105
105
  rake-compiler
106
106
  rbs!
107
107
  rbs-amber!
108
- rdoc (~> 6.4.0)
108
+ rdoc
109
109
  rspec
110
110
  rubocop
111
111
  rubocop-rubycw
data/Steepfile CHANGED
@@ -5,10 +5,10 @@ target :lib do
5
5
  check "lib"
6
6
  ignore(
7
7
  "lib/rbs/test",
8
- "lib/rbs/test.rb"
8
+ # "lib/rbs/test.rb"
9
9
  )
10
10
 
11
- library "pathname", "json", "logger", "monitor", "tsort", "uri", 'dbm', 'pstore', 'singleton', 'shellwords', 'fileutils', 'find', 'digest', 'abbrev', 'prettyprint', 'yaml'
11
+ library "pathname", "json", "logger", "monitor", "tsort", "uri", 'dbm', 'pstore', 'singleton', 'shellwords', 'fileutils', 'find', 'digest', 'abbrev', 'prettyprint', 'yaml', "psych", "securerandom"
12
12
  signature "stdlib/strscan/0/"
13
13
  signature "stdlib/optparse/0/"
14
14
  signature "stdlib/rdoc/0/"
data/core/array.rbs CHANGED
@@ -607,7 +607,8 @@ class Array[unchecked out Elem] < Object
607
607
  # - array & other_array -> new_array
608
608
  # -->
609
609
  # Returns a new Array containing each element found in both `array` and Array
610
- # `other_array`; duplicates are omitted; items are compared using `eql?`:
610
+ # `other_array`; duplicates are omitted; items are compared using `eql?` (items
611
+ # must also implement `hash` correctly):
611
612
  #
612
613
  # [0, 1, 2, 3] & [1, 2] # => [1, 2]
613
614
  # [0, 1, 0, 1] & [0, 1] # => [0, 1]
@@ -837,8 +838,6 @@ class Array[unchecked out Elem] < Object
837
838
  # # Raises TypeError (no implicit conversion of Symbol into Integer):
838
839
  # a[:foo]
839
840
  #
840
- # Array#slice is an alias for Array#[].
841
- #
842
841
  def []: %a{implicitly-returns-nil} (int index) -> Elem
843
842
  | (int start, int length) -> ::Array[Elem]?
844
843
  | (::Range[::Integer?] range) -> ::Array[Elem]?
@@ -972,6 +971,8 @@ class Array[unchecked out Elem] < Object
972
971
  # -->
973
972
  # Returns `true` if all elements of `self` meet a given criterion.
974
973
  #
974
+ # If `self` has no element, returns `true` and argument or block are not used.
975
+ #
975
976
  # With no block given and no argument, returns `true` if `self` contains only
976
977
  # truthy elements, `false` otherwise:
977
978
  #
@@ -1009,6 +1010,8 @@ class Array[unchecked out Elem] < Object
1009
1010
  # -->
1010
1011
  # Returns `true` if any element of `self` meets a given criterion.
1011
1012
  #
1013
+ # If `self` has no element, returns `false` and argument or block are not used.
1014
+ #
1012
1015
  # With no block given and no argument, returns `true` if `self` has any truthy
1013
1016
  # element, `false` otherwise:
1014
1017
  #
@@ -1050,8 +1053,6 @@ class Array[unchecked out Elem] < Object
1050
1053
  # a1 = a.push([:baz, :bat], [:bam, :bad])
1051
1054
  # a1 # => [:foo, "bar", 2, [:baz, :bat], [:bam, :bad]]
1052
1055
  #
1053
- # Array#append is an alias for Array#push.
1054
- #
1055
1056
  # Related: #pop, #shift, #unshift.
1056
1057
  #
1057
1058
  alias append push
@@ -1135,8 +1136,6 @@ class Array[unchecked out Elem] < Object
1135
1136
  # a1 = a.map
1136
1137
  # a1 # => #<Enumerator: [:foo, "bar", 2]:map>
1137
1138
  #
1138
- # Array#collect is an alias for Array#map.
1139
- #
1140
1139
  def collect: [U] () { (Elem item) -> U } -> ::Array[U]
1141
1140
  | () -> ::Enumerator[Elem, ::Array[untyped]]
1142
1141
 
@@ -1157,8 +1156,6 @@ class Array[unchecked out Elem] < Object
1157
1156
  # a1 = a.map!
1158
1157
  # a1 # => #<Enumerator: [:foo, "bar", 2]:map!>
1159
1158
  #
1160
- # Array#collect! is an alias for Array#map!.
1161
- #
1162
1159
  def collect!: () { (Elem item) -> Elem } -> self
1163
1160
  | () -> ::Enumerator[Elem, self]
1164
1161
 
@@ -1388,18 +1385,16 @@ class Array[unchecked out Elem] < Object
1388
1385
  # - array.delete_if {|element| ... } -> self
1389
1386
  # - array.delete_if -> Enumerator
1390
1387
  # -->
1391
- # Removes each element in +self+ for which the block returns a truthy value;
1392
- # returns +self+:
1393
- #
1394
- # a = [:foo, 'bar', 2, 'bat']
1395
- # a.delete_if {|element| element.to_s.start_with?('b') } # => [:foo, 2]
1388
+ # Removes each element in `self` for which the block returns a truthy value;
1389
+ # returns `self`:
1396
1390
  #
1397
- # Returns a new \Enumerator if no block given:
1391
+ # a = [:foo, 'bar', 2, 'bat']
1392
+ # a.delete_if {|element| element.to_s.start_with?('b') } # => [:foo, 2]
1398
1393
  #
1399
- # a = [:foo, 'bar', 2]
1400
- # a.delete_if # => #<Enumerator: [:foo, "bar", 2]:delete_if>
1394
+ # Returns a new Enumerator if no block given:
1401
1395
  #
1402
- # 3
1396
+ # a = [:foo, 'bar', 2]
1397
+ # a.delete_if # => #<Enumerator: [:foo, "bar", 2]:delete_if>
1403
1398
  #
1404
1399
  def delete_if: () { (Elem item) -> boolish } -> self
1405
1400
  | () -> ::Enumerator[Elem, self]
@@ -1854,8 +1849,6 @@ class Array[unchecked out Elem] < Object
1854
1849
  # a = [:foo, 'bar', 2, :bam]
1855
1850
  # a.select # => #<Enumerator: [:foo, "bar", 2, :bam]:select>
1856
1851
  #
1857
- # Array#filter is an alias for Array#select.
1858
- #
1859
1852
  def filter: () { (Elem item) -> boolish } -> ::Array[Elem]
1860
1853
  | () -> ::Enumerator[Elem, ::Array[Elem]]
1861
1854
 
@@ -1875,8 +1868,6 @@ class Array[unchecked out Elem] < Object
1875
1868
  # a = [:foo, 'bar', 2, :bam]
1876
1869
  # a.select! # => #<Enumerator: [:foo, "bar", 2, :bam]:select!>
1877
1870
  #
1878
- # Array#filter! is an alias for Array#select!.
1879
- #
1880
1871
  def filter!: () { (Elem item) -> boolish } -> self?
1881
1872
  | () -> ::Enumerator[Elem, self?]
1882
1873
 
@@ -1912,8 +1903,6 @@ class Array[unchecked out Elem] < Object
1912
1903
  # e # => #<Enumerator: [:foo, "bar", 2]:index>
1913
1904
  # e.each {|element| element == 'bar' } # => 1
1914
1905
  #
1915
- # Array#find_index is an alias for Array#index.
1916
- #
1917
1906
  # Related: #rindex.
1918
1907
  #
1919
1908
  def find_index: (untyped obj) -> ::Integer?
@@ -1921,7 +1910,7 @@ class Array[unchecked out Elem] < Object
1921
1910
  | () -> ::Enumerator[Elem, ::Integer?]
1922
1911
 
1923
1912
  # <!--
1924
- # rdoc-file=array.c
1913
+ # rdoc-file=array.rb
1925
1914
  # - array.first -> object or nil
1926
1915
  # - array.first(n) -> new_array
1927
1916
  # -->
@@ -2078,8 +2067,6 @@ class Array[unchecked out Elem] < Object
2078
2067
  # e # => #<Enumerator: [:foo, "bar", 2]:index>
2079
2068
  # e.each {|element| element == 'bar' } # => 1
2080
2069
  #
2081
- # Array#find_index is an alias for Array#index.
2082
- #
2083
2070
  # Related: #rindex.
2084
2071
  #
2085
2072
  alias index find_index
@@ -2130,8 +2117,6 @@ class Array[unchecked out Elem] < Object
2130
2117
  # a = [:foo, 'bar', 2]
2131
2118
  # a.inspect # => "[:foo, \"bar\", 2]"
2132
2119
  #
2133
- # Array#to_s is an alias for Array#inspect.
2134
- #
2135
2120
  def inspect: () -> String
2136
2121
 
2137
2122
  # <!--
@@ -2147,6 +2132,9 @@ class Array[unchecked out Elem] < Object
2147
2132
  # a.intersect?(b) #=> true
2148
2133
  # a.intersect?(c) #=> false
2149
2134
  #
2135
+ # Array elements are compared using `eql?` (items must also implement `hash`
2136
+ # correctly).
2137
+ #
2150
2138
  def intersect?: (_ToAry[untyped]) -> bool
2151
2139
 
2152
2140
  # <!--
@@ -2155,7 +2143,7 @@ class Array[unchecked out Elem] < Object
2155
2143
  # -->
2156
2144
  # Returns a new Array containing each element found both in `self` and in all of
2157
2145
  # the given Arrays `other_arrays`; duplicates are omitted; items are compared
2158
- # using `eql?`:
2146
+ # using `eql?` (items must also implement `hash` correctly):
2159
2147
  #
2160
2148
  # [0, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1]
2161
2149
  # [0, 0, 1, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1]
@@ -2221,7 +2209,7 @@ class Array[unchecked out Elem] < Object
2221
2209
  | () -> ::Enumerator[Elem, self]
2222
2210
 
2223
2211
  # <!--
2224
- # rdoc-file=array.c
2212
+ # rdoc-file=array.rb
2225
2213
  # - array.last -> object or nil
2226
2214
  # - array.last(n) -> new_array
2227
2215
  # -->
@@ -2277,8 +2265,6 @@ class Array[unchecked out Elem] < Object
2277
2265
  # a1 = a.map
2278
2266
  # a1 # => #<Enumerator: [:foo, "bar", 2]:map>
2279
2267
  #
2280
- # Array#collect is an alias for Array#map.
2281
- #
2282
2268
  alias map collect
2283
2269
 
2284
2270
  # <!-- rdoc-file=array.c -->
@@ -2294,8 +2280,6 @@ class Array[unchecked out Elem] < Object
2294
2280
  # a1 = a.map!
2295
2281
  # a1 # => #<Enumerator: [:foo, "bar", 2]:map!>
2296
2282
  #
2297
- # Array#collect! is an alias for Array#map!.
2298
- #
2299
2283
  alias map! collect!
2300
2284
 
2301
2285
  # <!--
@@ -2608,8 +2592,6 @@ class Array[unchecked out Elem] < Object
2608
2592
  # a = [:foo, 'bar', 2]
2609
2593
  # a.unshift(:bam, :bat) # => [:bam, :bat, :foo, "bar", 2]
2610
2594
  #
2611
- # Array#prepend is an alias for Array#unshift.
2612
- #
2613
2595
  # Related: #push, #pop, #shift.
2614
2596
  #
2615
2597
  alias prepend unshift
@@ -2695,8 +2677,6 @@ class Array[unchecked out Elem] < Object
2695
2677
  # a1 = a.push([:baz, :bat], [:bam, :bad])
2696
2678
  # a1 # => [:foo, "bar", 2, [:baz, :bat], [:bam, :bad]]
2697
2679
  #
2698
- # Array#append is an alias for Array#push.
2699
- #
2700
2680
  # Related: #pop, #shift, #unshift.
2701
2681
  #
2702
2682
  def push: (*Elem obj) -> self
@@ -3159,8 +3139,6 @@ class Array[unchecked out Elem] < Object
3159
3139
  # a = [:foo, 'bar', 2, :bam]
3160
3140
  # a.select # => #<Enumerator: [:foo, "bar", 2, :bam]:select>
3161
3141
  #
3162
- # Array#filter is an alias for Array#select.
3163
- #
3164
3142
  def select: () { (Elem item) -> boolish } -> ::Array[Elem]
3165
3143
  | () -> ::Enumerator[Elem, ::Array[Elem]]
3166
3144
 
@@ -3184,8 +3162,6 @@ class Array[unchecked out Elem] < Object
3184
3162
  # a = [:foo, 'bar', 2, :bam]
3185
3163
  # a.select! # => #<Enumerator: [:foo, "bar", 2, :bam]:select!>
3186
3164
  #
3187
- # Array#filter! is an alias for Array#select!.
3188
- #
3189
3165
  def select!: () { (Elem item) -> boolish } -> self?
3190
3166
  | () -> ::Enumerator[Elem, self?]
3191
3167
 
@@ -3347,8 +3323,6 @@ class Array[unchecked out Elem] < Object
3347
3323
  # # Raises TypeError (no implicit conversion of Symbol into Integer):
3348
3324
  # a[:foo]
3349
3325
  #
3350
- # Array#slice is an alias for Array#[].
3351
- #
3352
3326
  def slice: (int index) -> Elem?
3353
3327
  | (int start, int length) -> ::Array[Elem]?
3354
3328
  | (::Range[::Integer] range) -> ::Array[Elem]?
@@ -3682,8 +3656,6 @@ class Array[unchecked out Elem] < Object
3682
3656
  # a = [:foo, 'bar', 2]
3683
3657
  # a.inspect # => "[:foo, \"bar\", 2]"
3684
3658
  #
3685
- # Array#to_s is an alias for Array#inspect.
3686
- #
3687
3659
  alias to_s inspect
3688
3660
 
3689
3661
  # <!--
@@ -3780,8 +3752,6 @@ class Array[unchecked out Elem] < Object
3780
3752
  # a = [:foo, 'bar', 2]
3781
3753
  # a.unshift(:bam, :bat) # => [:bam, :bat, :foo, "bar", 2]
3782
3754
  #
3783
- # Array#prepend is an alias for Array#unshift.
3784
- #
3785
3755
  # Related: #push, #pop, #shift.
3786
3756
  #
3787
3757
  def unshift: (*Elem obj) -> self
@@ -128,7 +128,7 @@ class BasicObject
128
128
  # Note: that some objects of builtin classes are reused for optimization. This
129
129
  # is the case for immediate values and frozen string literals.
130
130
  #
131
- # BasicObject implements +__id__+, Kernel implements `object_id`.
131
+ # BasicObject implements `__id__`, Kernel implements `object_id`.
132
132
  #
133
133
  # Immediate values are not passed by reference but are passed by value: `nil`,
134
134
  # `true`, `false`, Fixnums, Symbols, and some Floats.
@@ -151,7 +151,7 @@ class BasicObject
151
151
  # When the method is identified by a string, the string is converted to a
152
152
  # symbol.
153
153
  #
154
- # BasicObject implements +__send__+, Kernel implements `send`. `__send__` is
154
+ # BasicObject implements `__send__`, Kernel implements `send`. `__send__` is
155
155
  # safer than `send` when *obj* has the same method name like `Socket`. See also
156
156
  # `public_send`.
157
157
  #
data/core/comparable.rbs CHANGED
@@ -8,25 +8,28 @@
8
8
  # implement the conventional comparison operators (`<`, `<=`, `==`, `>=`, and
9
9
  # `>`) and the method `between?`.
10
10
  #
11
- # class SizeMatters
11
+ # class StringSorter
12
12
  # include Comparable
13
+ #
13
14
  # attr :str
14
15
  # def <=>(other)
15
16
  # str.size <=> other.str.size
16
17
  # end
18
+ #
17
19
  # def initialize(str)
18
20
  # @str = str
19
21
  # end
22
+ #
20
23
  # def inspect
21
24
  # @str
22
25
  # end
23
26
  # end
24
27
  #
25
- # s1 = SizeMatters.new("Z")
26
- # s2 = SizeMatters.new("YY")
27
- # s3 = SizeMatters.new("XXX")
28
- # s4 = SizeMatters.new("WWWW")
29
- # s5 = SizeMatters.new("VVVVV")
28
+ # s1 = StringSorter.new("Z")
29
+ # s2 = StringSorter.new("YY")
30
+ # s3 = StringSorter.new("XXX")
31
+ # s4 = StringSorter.new("WWWW")
32
+ # s5 = StringSorter.new("VVVVV")
30
33
  #
31
34
  # s1 < s2 #=> true
32
35
  # s4.between?(s1, s3) #=> false
@@ -40,8 +43,8 @@
40
43
  # * #<: Returns whether `self` is less than the given object.
41
44
  # * #<=: Returns whether `self` is less than or equal to the given object.
42
45
  # * #==: Returns whether `self` is equal to the given object.
43
- # * #>: Returns whether `self` is greater than or equal to the given object.
44
- # * #>=: Returns whether `self` is greater than the given object.
46
+ # * #>: Returns whether `self` is greater than the given object.
47
+ # * #>=: Returns whether `self` is greater than or equal to the given object.
45
48
  # * #between?: Returns `true` if `self` is between two given objects.
46
49
  # * #clamp: For given objects `min` and `max`, or range `(min..max)`, returns:
47
50
  #
@@ -124,6 +127,12 @@ module Comparable : _WithSpaceshipOperator
124
127
  # 'd'.clamp('a', 'f') #=> 'd'
125
128
  # 'z'.clamp('a', 'f') #=> 'f'
126
129
  #
130
+ # If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`,
131
+ # it is considered greater than *obj*.
132
+ #
133
+ # -20.clamp(0, nil) #=> 0
134
+ # 523.clamp(nil, 100) #=> 100
135
+ #
127
136
  # In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less
128
137
  # than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and
129
138
  # *obj* otherwise.