rbs 3.4.4 → 3.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +12 -4
  3. data/.github/workflows/dependabot.yml +26 -0
  4. data/.github/workflows/ruby.yml +14 -1
  5. data/CHANGELOG.md +87 -1
  6. data/README.md +5 -3
  7. data/Rakefile +20 -3
  8. data/Steepfile +1 -1
  9. data/core/enumerator.rbs +1 -1
  10. data/core/float.rbs +2 -1
  11. data/core/gc.rbs +272 -150
  12. data/core/integer.rbs +6 -4
  13. data/core/io/wait.rbs +4 -4
  14. data/core/io.rbs +10 -3
  15. data/core/kernel.rbs +8 -7
  16. data/core/module.rbs +17 -4
  17. data/core/proc.rbs +1 -1
  18. data/core/range.rbs +2 -2
  19. data/core/rational.rbs +2 -1
  20. data/core/regexp.rbs +101 -90
  21. data/core/ruby_vm.rbs +107 -103
  22. data/core/rubygems/rubygems.rbs +1 -1
  23. data/core/set.rbs +13 -7
  24. data/core/string.rbs +3 -3
  25. data/core/symbol.rbs +2 -1
  26. data/core/thread.rbs +1 -1
  27. data/core/time.rbs +24 -4
  28. data/docs/architecture.md +110 -0
  29. data/docs/gem.md +0 -1
  30. data/docs/syntax.md +5 -1
  31. data/ext/rbs_extension/constants.c +2 -0
  32. data/ext/rbs_extension/constants.h +1 -0
  33. data/ext/rbs_extension/lexer.c +1338 -1341
  34. data/ext/rbs_extension/lexer.h +2 -0
  35. data/ext/rbs_extension/lexer.re +2 -3
  36. data/ext/rbs_extension/lexstate.c +5 -1
  37. data/ext/rbs_extension/location.c +80 -70
  38. data/ext/rbs_extension/location.h +25 -5
  39. data/ext/rbs_extension/parser.c +149 -43
  40. data/ext/rbs_extension/parserstate.c +12 -1
  41. data/ext/rbs_extension/parserstate.h +9 -0
  42. data/ext/rbs_extension/ruby_objs.c +13 -3
  43. data/ext/rbs_extension/ruby_objs.h +1 -0
  44. data/lib/rbs/cli/validate.rb +2 -2
  45. data/lib/rbs/cli.rb +4 -6
  46. data/lib/rbs/collection/config.rb +1 -1
  47. data/lib/rbs/collection/sources/git.rb +1 -6
  48. data/lib/rbs/definition_builder/method_builder.rb +1 -1
  49. data/lib/rbs/definition_builder.rb +8 -8
  50. data/lib/rbs/diff.rb +1 -1
  51. data/lib/rbs/environment_loader.rb +2 -1
  52. data/lib/rbs/errors.rb +0 -14
  53. data/lib/rbs/location_aux.rb +6 -1
  54. data/lib/rbs/parser/lex_result.rb +15 -0
  55. data/lib/rbs/parser/token.rb +23 -0
  56. data/lib/rbs/parser_aux.rb +12 -5
  57. data/lib/rbs/prototype/helpers.rb +22 -12
  58. data/lib/rbs/prototype/rb.rb +38 -4
  59. data/lib/rbs/prototype/rbi.rb +30 -20
  60. data/lib/rbs/test/errors.rb +19 -14
  61. data/lib/rbs/test/tester.rb +1 -1
  62. data/lib/rbs/test/type_check.rb +95 -16
  63. data/lib/rbs/types.rb +112 -13
  64. data/lib/rbs/unit_test/spy.rb +1 -1
  65. data/lib/rbs/version.rb +1 -1
  66. data/rbs.gemspec +7 -2
  67. data/sig/environment_loader.rbs +1 -1
  68. data/sig/errors.rbs +1 -1
  69. data/sig/manifest.yaml +0 -1
  70. data/sig/method_types.rbs +3 -3
  71. data/sig/parser.rbs +28 -0
  72. data/sig/prototype/helpers.rbs +4 -0
  73. data/sig/prototype/rbi.rbs +2 -0
  74. data/sig/types.rbs +54 -4
  75. data/sig/variance_calculator.rbs +2 -2
  76. data/stdlib/csv/0/csv.rbs +4 -1
  77. data/stdlib/fileutils/0/fileutils.rbs +1 -1
  78. data/stdlib/net-http/0/net-http.rbs +29 -27
  79. data/stdlib/socket/0/socket.rbs +2 -2
  80. data/stdlib/timeout/0/timeout.rbs +6 -0
  81. data/stdlib/uri/0/generic.rbs +2 -2
  82. data/stdlib/uri/0/http.rbs +2 -2
  83. data/stdlib/uri/0/mailto.rbs +84 -0
  84. metadata +7 -9
  85. data/Gemfile +0 -30
  86. data/Gemfile.lock +0 -117
  87. data/lib/rbs/parser_compat/lexer_error.rb +0 -6
  88. data/lib/rbs/parser_compat/located_value.rb +0 -7
  89. data/lib/rbs/parser_compat/semantics_error.rb +0 -6
  90. data/lib/rbs/parser_compat/syntax_error.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1cb14174ab8984f446bae9472db5994cfd3f660101eb6ce33d53b1ce8d2c0871
4
- data.tar.gz: f91955d86a636a762d5894fdb0230024c05dda5c2957c70c126d5d1e8ebe21e6
3
+ metadata.gz: 3dc7a972ca885618f8bcb3beb35d5096ddd9cc3dc6880fb6ae6b06d4a1845be0
4
+ data.tar.gz: 3fd84cf6a4869385f16e98cb1319855fcc1fcc242e16731b6bbdd5d249f1df8a
5
5
  SHA512:
6
- metadata.gz: d26b8e953ca26fd82eb8c0a74718c9288ac0871de48b5ba4e968fe2ed00cbeb8396097b0b75c732227b2a7cb3eb59338ed3ca945a5051ff3f9d3c7293c37f5db
7
- data.tar.gz: fa9c674f1fb275fcb920beea62d731edf3f831c7d2c9d53bcdd3ee97fb8d213b974e24466eb9ebf11f1922f35ed85ec6afd3466b93404d17de49e4d3377249b6
6
+ metadata.gz: 0b79dcac9fa9f94eff95b2c098208784f45e8ee891b94202f8e82886d15e0af04bbb26acdff5428277470536cfef164f79b5a1f73ded288b320600bd15568500
7
+ data.tar.gz: c0c6f53213e0b0aac09747c2aef470548b2b872b8ace2647ebdedca292a55b8aa0dbbebfa5c3ff75c47d3f76e87643f23f75883cacc49726fd778f95e1c3ee9e
@@ -1,13 +1,21 @@
1
1
  version: 2
2
2
  updates:
3
- - package-ecosystem: "bundler"
3
+ - package-ecosystem: bundler
4
4
  directory: "/"
5
5
  schedule:
6
- interval: "daily"
7
- - package-ecosystem: "bundler"
6
+ interval: daily
7
+ open-pull-requests-limit: 3
8
+ allow:
9
+ - dependency-type: all
10
+
11
+ - package-ecosystem: bundler
8
12
  directory: "/steep"
9
13
  schedule:
10
- interval: "daily"
14
+ interval: daily
15
+ open-pull-requests-limit: 3
16
+ allow:
17
+ - dependency-type: all
18
+
11
19
  - package-ecosystem: 'github-actions'
12
20
  directory: '/'
13
21
  schedule:
@@ -0,0 +1,26 @@
1
+ name: Merge dependabot PRs automatically
2
+ on: pull_request_target
3
+
4
+ permissions:
5
+ pull-requests: write
6
+ contents: write
7
+
8
+ env:
9
+ blocker_files: rbs.gemspec Gemfile steep/Gemfile
10
+
11
+ jobs:
12
+ dependabot:
13
+ runs-on: ubuntu-latest
14
+ if: ${{ github.actor == 'dependabot[bot]' }}
15
+ steps:
16
+ - name: Checkout repository
17
+ uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 0
20
+ - name: Abort if blocker files are changed
21
+ run: git diff --exit-code ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} ${{ env.blocker_files }}
22
+ - name: Enable auto-merge for Dependabot PRs
23
+ run: gh pr merge --auto --merge "$PR_URL"
24
+ env:
25
+ PR_URL: ${{github.event.pull_request.html_url}}
26
+ GH_TOKEN: ${{secrets.DEPENDABOT_MERGE_GH_TOKEN}}
@@ -14,6 +14,7 @@ jobs:
14
14
  fail-fast: false
15
15
  matrix:
16
16
  ruby: ['3.0', '3.1', '3.2', '3.3', head]
17
+ rubyopt: [""]
17
18
  job:
18
19
  - test
19
20
  include:
@@ -21,10 +22,18 @@ jobs:
21
22
  job: stdlib_test rubocop
22
23
  - ruby: "3.3"
23
24
  job: stdlib_test
25
+ - ruby: "3.3"
26
+ job: test
27
+ rubyopt: "--enable-frozen-string-literal"
28
+ - ruby: "3.3"
29
+ job: stdlib_test
30
+ rubyopt: "--enable-frozen-string-literal"
24
31
  - ruby: "3.3"
25
32
  job: lexer compile confirm_lexer
26
33
  - ruby: "3.3"
27
- job: rubocop validate test_doc build test_generate_stdlib
34
+ job: rubocop validate test_doc build test_generate_stdlib raap
35
+ - ruby: "3.3"
36
+ job: typecheck_test
28
37
  steps:
29
38
  - uses: actions/checkout@v4
30
39
  - uses: ruby/setup-ruby@v1
@@ -57,6 +66,10 @@ jobs:
57
66
  echo "NO_MINITEST=true" >> $GITHUB_ENV
58
67
  bundle config set --local without 'minitest'
59
68
  if: ${{ contains(matrix.ruby, 'head') }}
69
+ - name: Skip installing type checkers
70
+ if: ${{ ! contains(matrix.job, 'typecheck_test') }}
71
+ run: |
72
+ bundle config set without 'typecheck_test'
60
73
  - name: bin/setup
61
74
  run: |
62
75
  bin/setup
data/CHANGELOG.md CHANGED
@@ -1,6 +1,92 @@
1
1
  # CHANGELOG
2
2
 
3
- ## master
3
+ ## 3.5.1 (2024-06-07)
4
+
5
+ ### Library changes
6
+
7
+ * Add explicit dependency on the `logger` gem ([#1865](https://github.com/ruby/rbs/pull/1865))
8
+ * Make c99, c23 compatible ([#1870](https://github.com/ruby/rbs/pull/1870))
9
+
10
+ ### Miscellaneous
11
+
12
+ * Don't try to sign git commits when running tests ([#1867](https://github.com/ruby/rbs/pull/1867))
13
+
14
+ ## 3.5.0 (2024-06-06)
15
+
16
+ ### Signature updates
17
+
18
+ * `net-http` headers ([#1750](https://github.com/ruby/rbs/pull/1750))
19
+ * `CSV.foreach` ([#1738](https://github.com/ruby/rbs/pull/1738))
20
+ * `Enumerator#initialize` ([#1801](https://github.com/ruby/rbs/pull/1801))
21
+ * `Float#divmod`, `Rational#divmod` ([#1868](https://github.com/ruby/rbs/pull/1868))
22
+ * `GC` ([#1530](https://github.com/ruby/rbs/pull/1530))
23
+ * `Integer#pow` ([#1706](https://github.com/ruby/rbs/pull/1706))
24
+ * `Kernel.rand` ([#1783](https://github.com/ruby/rbs/pull/1783))
25
+ * `Kernel#extend` ([#1769](https://github.com/ruby/rbs/pull/1769))
26
+ * `Module#include`, `Module#prepend` ([#1769](https://github.com/ruby/rbs/pull/1769))
27
+ * `Proc#parameters` ([#1819](https://github.com/ruby/rbs/pull/1819))
28
+ * `Range#step` ([#1709](https://github.com/ruby/rbs/pull/1709))
29
+ * `Regexp.union` ([#1809](https://github.com/ruby/rbs/pull/1809))
30
+ * `RubyVM::YJIT.enable` ([#1812](https://github.com/ruby/rbs/pull/1812))
31
+ * `RubyVM::YJIT`, `RubyVM::RJIT` ([#1746](https://github.com/ruby/rbs/pull/1746))
32
+ * `String#bytesplice` ([#1793](https://github.com/ruby/rbs/pull/1793))
33
+ * `String#gsub!` ([#1768](https://github.com/ruby/rbs/pull/1768))
34
+ * `Symbol#=~` ([#1704](https://github.com/ruby/rbs/pull/1704))
35
+ * `Time#initialize` ([#1771](https://github.com/ruby/rbs/pull/1771))
36
+ * `Time#zone` ([#1770](https://github.com/ruby/rbs/pull/1770))
37
+ * `Timeout::ExitException` ([#1803](https://github.com/ruby/rbs/pull/1803))
38
+ * `URI::MailTo` ([#1858](https://github.com/ruby/rbs/pull/1858))
39
+ * Update docs ([#1811](https://github.com/ruby/rbs/pull/1811), [#1699](https://github.com/ruby/rbs/pull/1699))
40
+
41
+ ### Language updates
42
+
43
+ * Fix proc type syntax ([#1807](https://github.com/ruby/rbs/pull/1807))
44
+ * Function types with untyped parameter ([#1806](https://github.com/ruby/rbs/pull/1806))
45
+ * Fix record type ([#1732](https://github.com/ruby/rbs/pull/1732))
46
+ * parser: enable record types with optional fields ([#1717](https://github.com/ruby/rbs/pull/1717))
47
+
48
+ ### Library changes
49
+
50
+ * Drop dependency on `abbrev` ([#1866](https://github.com/ruby/rbs/pull/1866))
51
+ * Fix source display ([#1832](https://github.com/ruby/rbs/pull/1832))
52
+ * Include trivia tokens to lex result ([#1831](https://github.com/ruby/rbs/pull/1831))
53
+ * Implement token list API ([#1829](https://github.com/ruby/rbs/pull/1829))
54
+ * Fix memory leak when ParsingError ([#1830](https://github.com/ruby/rbs/pull/1830))
55
+ * [rbs diff] Fix error when empty manifest.yaml ([#1762](https://github.com/ruby/rbs/pull/1762))
56
+ * Remove deprecated API since RBS v1 ([#1805](https://github.com/ruby/rbs/pull/1805))
57
+ * Use array instead of linked list for rbs location's child ([#1786](https://github.com/ruby/rbs/pull/1786))
58
+ * Fix SEGV with parse negative position ([#1790](https://github.com/ruby/rbs/pull/1790))
59
+ * Add location for attribute ([#1787](https://github.com/ruby/rbs/pull/1787))
60
+ * Always be private ([#1774](https://github.com/ruby/rbs/pull/1774))
61
+ * Prevent resource leak with type/method-type parser when reaching EOF. ([#1742](https://github.com/ruby/rbs/pull/1742))
62
+ * Allow loading RBS from different version of a gem ([#1731](https://github.com/ruby/rbs/pull/1731))
63
+ * Fix method name tag on assertion ([#1705](https://github.com/ruby/rbs/pull/1705))
64
+ * Improve interface check by method parameters ([#1698](https://github.com/ruby/rbs/pull/1698))
65
+
66
+ #### rbs prototype
67
+
68
+ * Fix prototype for ruby-3.4 ([#1760](https://github.com/ruby/rbs/pull/1760))
69
+ * Fix 3.4 `prototype rb` failure ([#1713](https://github.com/ruby/rbs/pull/1713))
70
+ * Add Numeric Node's check for parse rbs ([#1711](https://github.com/ruby/rbs/pull/1711))
71
+
72
+ #### rbs collection
73
+
74
+ * Fix RBS loading precedence ([#1720](https://github.com/ruby/rbs/pull/1720))
75
+ * Refactor Git source by using `git?` method ([#1701](https://github.com/ruby/rbs/pull/1701))
76
+
77
+ ### Miscellaneous
78
+
79
+ * Introduce RaaP for testing of signature ([#1810](https://github.com/ruby/rbs/pull/1810))
80
+ * Revise .gemspec to remove `Gemfile` and `Gemfile.lock` ([#1856](https://github.com/ruby/rbs/pull/1856))
81
+ * Add link to gem_rbs_collection to README ([#1827](https://github.com/ruby/rbs/pull/1827))
82
+ * Remove `Gemfile.lock` from the gem package ([#1823](https://github.com/ruby/rbs/pull/1823))
83
+ * Modify template to use TestHelper ([#1776](https://github.com/ruby/rbs/pull/1776))
84
+ * Should focus on `String.new` not `String#initialize`. ([#1789](https://github.com/ruby/rbs/pull/1789))
85
+ * Make the test suite compatible with `--enable-frozen-string-literal` ([#1767](https://github.com/ruby/rbs/pull/1767))
86
+ * Stop reusing `fd` ([#1752](https://github.com/ruby/rbs/pull/1752))
87
+ * Fix test failures on Ruby 3.4 ([#1734](https://github.com/ruby/rbs/pull/1734))
88
+ * Stop trace object allocations during test ([#1724](https://github.com/ruby/rbs/pull/1724))
89
+ * Fix head test fails ([#1719](https://github.com/ruby/rbs/pull/1719))
4
90
 
5
91
  ## 3.4.4 (2024-02-08)
6
92
 
data/README.md CHANGED
@@ -69,7 +69,7 @@ gem "rbs"
69
69
 
70
70
  The gem ships with the `rbs` command line tool to demonstrate what it can do and help develop RBS.
71
71
 
72
- ```bash
72
+ ```console
73
73
  $ rbs version
74
74
  $ rbs list
75
75
  $ rbs ancestors ::Object
@@ -98,7 +98,7 @@ end
98
98
 
99
99
  Running prototype on the above will automatically generate
100
100
 
101
- ```
101
+ ```console
102
102
  $ rbs prototype rb person.rb
103
103
  class Person
104
104
  @name: untyped
@@ -118,7 +118,7 @@ end
118
118
  It prints signatures for all methods, classes, instance variables, and constants.
119
119
  This is only a starting point, and you should edit the output to match your signature more accurately.
120
120
 
121
- `rbs prototpe` offers three options.
121
+ `rbs prototype` offers three options.
122
122
 
123
123
  - `rb` generates from just the available Ruby code
124
124
  - `rbi` generates from Sorbet RBI
@@ -174,6 +174,7 @@ puts singleton.methods[:gsub]
174
174
 
175
175
  ## Guides
176
176
 
177
+ - [Architecture](docs/architecture.md)
177
178
  - [Core and standard library signature contribution guide](docs/CONTRIBUTING.md)
178
179
  - [Writing signatures guide](docs/sigs.md)
179
180
  - [Stdlib signatures guide](docs/stdlib.md)
@@ -189,6 +190,7 @@ Here is a list of some places you can talk with active maintainers.
189
190
 
190
191
  - [Ruby Discord Server (invite link)](https://discord.gg/ad2acQFtkh) -- We have `rbs` channel in Ruby Discord server.
191
192
  - [ruby-jp Slack Workspace (in Japanese)](https://ruby-jp.github.io/) -- We have `types` channel in ruby-jp slack workspace.
193
+ - [gem_rbs_collection](https://github.com/ruby/gem_rbs_collection) -- We have a repository of third-party RBS type definitions, for the case your dependency doesn't ship with RBS files.
192
194
 
193
195
  ## Development
194
196
 
data/Rakefile CHANGED
@@ -19,7 +19,7 @@ Rake::TestTask.new(:test => :compile) do |t|
19
19
  end
20
20
  end
21
21
 
22
- multitask :default => [:test, :stdlib_test, :rubocop, :validate, :test_doc]
22
+ multitask :default => [:test, :stdlib_test, :typecheck_test, :rubocop, :validate, :test_doc]
23
23
 
24
24
  task :lexer do
25
25
  sh "re2c -W --no-generation-date -o ext/rbs_extension/lexer.c ext/rbs_extension/lexer.re"
@@ -92,6 +92,23 @@ task :stdlib_test => :compile do
92
92
  sh "#{ruby} -Ilib #{bin}/test_runner.rb test/stdlib/Encoding_test.rb"
93
93
  end
94
94
 
95
+ task :typecheck_test => :compile do
96
+ FileList["test/typecheck/*"].each do |test|
97
+ Dir.chdir(test) do
98
+ expectations = File.join(test, "steep_expectations.yml")
99
+ if File.exist?(expectations)
100
+ sh "steep check --with_expectations"
101
+ else
102
+ sh "steep check"
103
+ end
104
+ end
105
+ end
106
+ end
107
+
108
+ task :raap => :compile do
109
+ sh %q[cat test/raap.txt | egrep -v '^#|^$' | xargs bundle exec raap]
110
+ end
111
+
95
112
  task :rubocop do
96
113
  sh "rubocop --parallel"
97
114
  end
@@ -153,7 +170,7 @@ namespace :generate do
153
170
 
154
171
  <%- unless class_methods.empty? -%>
155
172
  class <%= target %>SingletonTest < Test::Unit::TestCase
156
- include TypeAssertions
173
+ include TestHelper
157
174
 
158
175
  # library "pathname", "securerandom" # Declare library signatures to load
159
176
  testing "singleton(::<%= target %>)"
@@ -172,7 +189,7 @@ namespace :generate do
172
189
 
173
190
  <%- unless instance_methods.empty? -%>
174
191
  class <%= target %>Test < Test::Unit::TestCase
175
- include TypeAssertions
192
+ include TestHelper
176
193
 
177
194
  # library "pathname", "securerandom" # Declare library signatures to load
178
195
  testing "::<%= target %>"
data/Steepfile CHANGED
@@ -8,7 +8,7 @@ target :lib do
8
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', "psych", "securerandom"
11
+ library "pathname", "json", "logger", "monitor", "tsort", "uri", 'dbm', 'pstore', 'singleton', 'shellwords', 'fileutils', 'find', 'digest', 'prettyprint', 'yaml', "psych", "securerandom"
12
12
  signature "stdlib/strscan/0/"
13
13
  signature "stdlib/optparse/0/"
14
14
  signature "stdlib/rdoc/0/"
data/core/enumerator.rbs CHANGED
@@ -293,7 +293,7 @@ class Enumerator[unchecked out Elem, out Return] < Object
293
293
  # lazy fashion (see Enumerator#size). It can either be a value or a callable
294
294
  # object.
295
295
  #
296
- def initialize: (?Integer arg0) { (Enumerator::Yielder arg0) -> void } -> void
296
+ def initialize: (?Integer arg0) { (Enumerator::Yielder arg0) -> Return } -> void
297
297
 
298
298
  # <!--
299
299
  # rdoc-file=enumerator.c
data/core/float.rbs CHANGED
@@ -442,7 +442,8 @@ class Float < Numeric
442
442
  # 13.0.divmod(4.0) # => [3, 1.0]
443
443
  # 13.0.divmod(Rational(4, 1)) # => [3, 1.0]
444
444
  #
445
- def divmod: (Numeric) -> [ Numeric, Numeric ]
445
+ def divmod: (Integer | Float | Rational) -> [ Integer, Float ]
446
+ | (Numeric) -> [ Numeric, Numeric ]
446
447
 
447
448
  def dup: () -> self
448
449