rbs 3.8.0 → 3.9.0.dev.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.
- checksums.yaml +4 -4
- data/.github/workflows/comments.yml +3 -3
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/ruby.yml +7 -7
- data/.github/workflows/typecheck.yml +2 -0
- data/.github/workflows/windows.yml +15 -0
- data/.rubocop.yml +20 -1
- data/CHANGELOG.md +14 -0
- data/Rakefile +5 -2
- data/config.yml +6 -0
- data/core/data.rbs +1 -1
- data/core/enumerator.rbs +14 -2
- data/core/exception.rbs +148 -39
- data/core/gc.rbs +2 -2
- data/core/io.rbs +7 -3
- data/core/kernel.rbs +58 -16
- data/core/method.rbs +2 -2
- data/core/module.rbs +3 -3
- data/core/proc.rbs +2 -2
- data/core/ractor.rbs +4 -1
- data/core/rbs/unnamed/argf.rbs +3 -3
- data/core/regexp.rbs +4 -2
- data/core/ruby_vm.rbs +8 -8
- data/core/rubygems/version.rbs +2 -2
- data/core/string.rbs +1 -1
- data/core/time.rbs +1 -1
- data/core/unbound_method.rbs +1 -1
- data/docs/syntax.md +10 -5
- data/ext/rbs_extension/extconf.rb +2 -1
- data/ext/rbs_extension/location.c +32 -10
- data/ext/rbs_extension/location.h +4 -3
- data/ext/rbs_extension/main.c +22 -1
- data/ext/rbs_extension/parser.c +144 -136
- data/ext/rbs_extension/parserstate.c +40 -9
- data/ext/rbs_extension/parserstate.h +6 -4
- data/include/rbs/ruby_objs.h +6 -6
- data/include/rbs/util/rbs_constant_pool.h +219 -0
- data/lib/rbs/ast/declarations.rb +9 -4
- data/lib/rbs/ast/directives.rb +10 -0
- data/lib/rbs/ast/members.rb +2 -0
- data/lib/rbs/ast/type_param.rb +2 -2
- data/lib/rbs/cli/validate.rb +1 -0
- data/lib/rbs/cli.rb +3 -3
- data/lib/rbs/collection/config/lockfile_generator.rb +28 -7
- data/lib/rbs/collection/sources/rubygems.rb +1 -1
- data/lib/rbs/definition.rb +46 -31
- data/lib/rbs/definition_builder/ancestor_builder.rb +2 -0
- data/lib/rbs/definition_builder.rb +86 -30
- data/lib/rbs/environment.rb +33 -18
- data/lib/rbs/errors.rb +23 -0
- data/lib/rbs/locator.rb +2 -0
- data/lib/rbs/method_type.rb +2 -0
- data/lib/rbs/parser_aux.rb +38 -1
- data/lib/rbs/subtractor.rb +3 -3
- data/lib/rbs/test/hook.rb +2 -2
- data/lib/rbs/test/type_check.rb +7 -5
- data/lib/rbs/types.rb +44 -5
- data/lib/rbs/unit_test/spy.rb +4 -2
- data/lib/rbs/unit_test/type_assertions.rb +17 -11
- data/lib/rbs/validator.rb +4 -0
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +10 -5
- data/lib/rbs.rb +1 -0
- data/rbs.gemspec +1 -1
- data/sig/collection/config/lockfile_generator.rbs +1 -1
- data/sig/declarations.rbs +10 -3
- data/sig/definition.rbs +67 -14
- data/sig/definition_builder.rbs +17 -3
- data/sig/directives.rbs +17 -1
- data/sig/environment.rbs +2 -0
- data/sig/errors.rbs +16 -0
- data/sig/parser.rbs +5 -1
- data/sig/subtractor.rbs +1 -1
- data/sig/test/type_check.rbs +2 -2
- data/sig/type_param.rbs +1 -1
- data/sig/types.rbs +3 -0
- data/sig/unit_test/spy.rbs +2 -0
- data/sig/unit_test/type_assertions.rbs +2 -0
- data/sig/validator.rbs +4 -0
- data/sig/writer.rbs +1 -1
- data/src/ruby_objs.c +12 -6
- data/src/util/rbs_constant_pool.c +342 -0
- data/stdlib/cgi/0/core.rbs +10 -0
- data/stdlib/json/0/json.rbs +52 -50
- data/stdlib/monitor/0/monitor.rbs +13 -4
- data/stdlib/net-http/0/net-http.rbs +2 -2
- data/stdlib/openssl/0/openssl.rbs +73 -73
- data/stdlib/resolv/0/resolv.rbs +8 -8
- data/stdlib/socket/0/addrinfo.rbs +1 -1
- data/stdlib/socket/0/unix_socket.rbs +4 -2
- data/stdlib/stringio/0/stringio.rbs +1 -1
- data/stdlib/uri/0/common.rbs +17 -0
- metadata +4 -7
- data/templates/include/rbs/constants.h.erb +0 -20
- data/templates/include/rbs/ruby_objs.h.erb +0 -10
- data/templates/src/constants.c.erb +0 -36
- data/templates/src/ruby_objs.c.erb +0 -27
- data/templates/template.rb +0 -122
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 311aed14b7b84b6b21cb187b72c1ddd87a427b6ec02805017f83b5fbcbfaac7b
         | 
| 4 | 
            +
              data.tar.gz: 4fc2e119368352b2fbded9355834757399cde34f3912c24ae82e91db67042762
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 6c9b1a6188ac4585b3ea5b9dd72432f12ea13ee4c8311a15a86f0cee5595acef46901e04105e40a84703ea51e036efb645a53cacaa1517d213420b2251f3f506
         | 
| 7 | 
            +
              data.tar.gz: 4061149d53166bbe1a6029cebbacc54117eccf5d414c1859b50c5049d2898245a27ccf8f558b9c11d5edaa0b276ba88c111b8c80505a5b911664e77b5351dc2a
         | 
| @@ -10,13 +10,13 @@ on: | |
| 10 10 | 
             
            jobs:
         | 
| 11 11 | 
             
              comments:
         | 
| 12 12 | 
             
                runs-on: "ubuntu-latest"
         | 
| 13 | 
            -
                env:
         | 
| 14 | 
            -
             | 
| 13 | 
            +
                # env:
         | 
| 14 | 
            +
                #   RUBY_COMMIT: 1b0c46daed9186b82ab4fef1a4ab225afe582ee6
         | 
| 15 15 | 
             
                steps:
         | 
| 16 16 | 
             
                  - uses: actions/checkout@v4
         | 
| 17 17 | 
             
                  - uses: ruby/setup-ruby@v1
         | 
| 18 18 | 
             
                    with:
         | 
| 19 | 
            -
                      ruby-version: "3.4. | 
| 19 | 
            +
                      ruby-version: "3.4.1"
         | 
| 20 20 | 
             
                      bundler: none
         | 
| 21 21 | 
             
                  - name: Install dependencies
         | 
| 22 22 | 
             
                    run: |
         | 
| @@ -14,7 +14,7 @@ jobs: | |
| 14 14 | 
             
                if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
         | 
| 15 15 | 
             
                steps:
         | 
| 16 16 | 
             
                  - name: Dependabot metadata
         | 
| 17 | 
            -
                    uses: dependabot/fetch-metadata@ | 
| 17 | 
            +
                    uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7 # v2.3.0
         | 
| 18 18 | 
             
                    id: metadata
         | 
| 19 19 | 
             
                  - name: Checkout repository
         | 
| 20 20 | 
             
                    uses: actions/checkout@v4
         | 
    
        data/.github/workflows/ruby.yml
    CHANGED
    
    | @@ -13,26 +13,26 @@ jobs: | |
| 13 13 | 
             
                strategy:
         | 
| 14 14 | 
             
                  fail-fast: false
         | 
| 15 15 | 
             
                  matrix:
         | 
| 16 | 
            -
                    ruby: ['3.1', '3.2', '3.3', '3.4 | 
| 16 | 
            +
                    ruby: ['3.1', '3.2', '3.3', '3.4', head]
         | 
| 17 17 | 
             
                    rubyopt: [""]
         | 
| 18 18 | 
             
                    job:
         | 
| 19 19 | 
             
                      - test
         | 
| 20 20 | 
             
                    include:
         | 
| 21 21 | 
             
                      - ruby: head
         | 
| 22 22 | 
             
                        job: stdlib_test rubocop
         | 
| 23 | 
            -
                      - ruby: "3.4 | 
| 23 | 
            +
                      - ruby: "3.4"
         | 
| 24 24 | 
             
                        job: stdlib_test
         | 
| 25 | 
            -
                      - ruby: "3.4 | 
| 25 | 
            +
                      - ruby: "3.4"
         | 
| 26 26 | 
             
                        job: test
         | 
| 27 27 | 
             
                        rubyopt: "--enable-frozen-string-literal"
         | 
| 28 | 
            -
                      - ruby: "3.4 | 
| 28 | 
            +
                      - ruby: "3.4"
         | 
| 29 29 | 
             
                        job: stdlib_test
         | 
| 30 30 | 
             
                        rubyopt: "--enable-frozen-string-literal"
         | 
| 31 | 
            -
                      - ruby: "3.4 | 
| 31 | 
            +
                      - ruby: "3.4"
         | 
| 32 32 | 
             
                        job: lexer templates compile confirm_lexer confirm_templates
         | 
| 33 | 
            -
                      - ruby: "3.4 | 
| 33 | 
            +
                      - ruby: "3.4"
         | 
| 34 34 | 
             
                        job: rubocop validate test_doc build test_generate_stdlib raap
         | 
| 35 | 
            -
                      - ruby: "3.4 | 
| 35 | 
            +
                      - ruby: "3.4"
         | 
| 36 36 | 
             
                        job: typecheck_test
         | 
| 37 37 | 
             
                env:
         | 
| 38 38 | 
             
                  RANDOMIZE_STDLIB_TEST_ORDER: "true"
         | 
| @@ -20,6 +20,8 @@ jobs: | |
| 20 20 | 
             
                      bundler: none
         | 
| 21 21 | 
             
                  - name: Set working directory as safe
         | 
| 22 22 | 
             
                    run: git config --global --add safe.directory $(pwd)
         | 
| 23 | 
            +
                  - name: Set up permission
         | 
| 24 | 
            +
                    run: chmod -R o-w /opt/hostedtoolcache/Ruby
         | 
| 23 25 | 
             
                  - name: Install dependencies
         | 
| 24 26 | 
             
                    run: |
         | 
| 25 27 | 
             
                      sudo apt-get update
         | 
| @@ -20,6 +20,21 @@ jobs: | |
| 20 20 | 
             
                    uses: ruby/setup-ruby@v1
         | 
| 21 21 | 
             
                    with:
         | 
| 22 22 | 
             
                      ruby-version: ${{ matrix.ruby }}
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  # ucrt and mswin have the dev version Ruby.
         | 
| 25 | 
            +
                  # It introduce checksum mismatches for bundled gems. So remove them before `bundle install`
         | 
| 26 | 
            +
                  - name: Purge gem caches
         | 
| 27 | 
            +
                    run: |
         | 
| 28 | 
            +
                      ruby -e '
         | 
| 29 | 
            +
                        exit if "${{ matrix.ruby }}" != "ucrt" && "${{ matrix.ruby }}" != "mswin"
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                        require "open-uri"
         | 
| 32 | 
            +
                        require "json"
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                        res = URI.parse("https://stdgems.org/bundled_gems.json").read
         | 
| 35 | 
            +
                        bundled_gems = JSON.parse(res)["gems"].map{_1["gem"]}
         | 
| 36 | 
            +
                        system "gem uninstall #{bundled_gems.join(" ")}", exception: true
         | 
| 37 | 
            +
                      '
         | 
| 23 38 | 
             
                  - name: bundle install
         | 
| 24 39 | 
             
                    run: |
         | 
| 25 40 | 
             
                      bundle config set without profilers libs
         | 
    
        data/.rubocop.yml
    CHANGED
    
    | @@ -3,7 +3,7 @@ require: | |
| 3 3 | 
             
              - rubocop-on-rbs
         | 
| 4 4 |  | 
| 5 5 | 
             
            AllCops:
         | 
| 6 | 
            -
              TargetRubyVersion: 3. | 
| 6 | 
            +
              TargetRubyVersion: 3.1
         | 
| 7 7 | 
             
              DisabledByDefault: true
         | 
| 8 8 | 
             
              Exclude:
         | 
| 9 9 | 
             
                - 'vendor/bundle/**/*'
         | 
| @@ -15,6 +15,7 @@ Rubycw/Rubycw: | |
| 15 15 |  | 
| 16 16 | 
             
            RBS:
         | 
| 17 17 | 
             
              Enabled: true
         | 
| 18 | 
            +
             | 
| 18 19 | 
             
            RBS/Layout:
         | 
| 19 20 | 
             
              Enabled: true
         | 
| 20 21 | 
             
              Exclude:
         | 
| @@ -23,6 +24,7 @@ RBS/Layout: | |
| 23 24 | 
             
            RBS/Layout/CommentIndentation:
         | 
| 24 25 | 
             
              Exclude:
         | 
| 25 26 | 
             
                - core/string.rbs
         | 
| 27 | 
            +
             | 
| 26 28 | 
             
            RBS/Lint:
         | 
| 27 29 | 
             
              Enabled: true
         | 
| 28 30 | 
             
              Exclude:
         | 
| @@ -32,15 +34,32 @@ RBS/Lint/TopLevelInterface: | |
| 32 34 | 
             
              Enabled: false
         | 
| 33 35 | 
             
            RBS/Lint/TopLevelTypeAlias:
         | 
| 34 36 | 
             
              Enabled: false
         | 
| 37 | 
            +
            RBS/Lint/AmbiguousKeywordArgumentKey:
         | 
| 38 | 
            +
              Exclude:
         | 
| 39 | 
            +
                # OpenSSL::KDF.scrypt
         | 
| 40 | 
            +
                - 'stdlib/openssl/0/openssl.rbs'
         | 
| 41 | 
            +
             | 
| 35 42 | 
             
            RBS/Style:
         | 
| 36 43 | 
             
              Enabled: false
         | 
| 37 44 | 
             
              Exclude:
         | 
| 38 45 | 
             
                - 'sig/**/*'
         | 
| 39 46 | 
             
                - 'test/**/*'
         | 
| 47 | 
            +
            RBS/Style/BlockReturnBoolish:
         | 
| 48 | 
            +
              Enabled: true
         | 
| 49 | 
            +
            RBS/Style/ClassWithSingleton:
         | 
| 50 | 
            +
              Enabled: true
         | 
| 51 | 
            +
            RBS/Style/DuplicatedType:
         | 
| 52 | 
            +
              Enabled: true
         | 
| 40 53 | 
             
            RBS/Style/EmptyArgument:
         | 
| 41 54 | 
             
              Enabled: true
         | 
| 42 55 | 
             
            RBS/Style/InitializeReturnType:
         | 
| 43 56 | 
             
              Enabled: true
         | 
| 57 | 
            +
            RBS/Style/InstanceWithInstance:
         | 
| 58 | 
            +
              Enabled: true
         | 
| 59 | 
            +
            RBS/Style/OptionalNil:
         | 
| 60 | 
            +
              Enabled: true
         | 
| 61 | 
            +
            RBS/Style/RedundantParentheses:
         | 
| 62 | 
            +
              Enabled: true
         | 
| 44 63 |  | 
| 45 64 | 
             
            Lint/DuplicateMethods:
         | 
| 46 65 | 
             
              Enabled: true
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,5 +1,19 @@ | |
| 1 1 | 
             
            # CHANGELOG
         | 
| 2 2 |  | 
| 3 | 
            +
            ## 3.8.1 (2024-12-27)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ### Signature updates
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            * `Ractor.store_if_absent` ([#2206](https://github.com/ruby/rbs/pull/2206))
         | 
| 8 | 
            +
            * `Time#iso860t1` ([#2207](https://github.com/ruby/rbs/pull/2207))
         | 
| 9 | 
            +
            * `Time#xmlschema` ([#2207](https://github.com/ruby/rbs/pull/2207))
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            ### Miscellaneous
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            * Update rubocop-on-rbs ([#2200](https://github.com/ruby/rbs/pull/2200))
         | 
| 14 | 
            +
            * Update docs based on Ruby 3.4.1 ([#2208](https://github.com/ruby/rbs/pull/2208))
         | 
| 15 | 
            +
            * Ruby 3.4.1 ([#2206](https://github.com/ruby/rbs/pull/2206))
         | 
| 16 | 
            +
             | 
| 3 17 | 
             
            ## 3.8.0 (2024-12-24)
         | 
| 4 18 |  | 
| 5 19 | 
             
            ### Signature updates
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -112,7 +112,7 @@ end | |
| 112 112 |  | 
| 113 113 | 
             
            task :stdlib_test => :compile do
         | 
| 114 114 | 
             
              test_files = FileList["test/stdlib/**/*_test.rb"].reject do |path|
         | 
| 115 | 
            -
                path =~ %r{Ractor} || path =~ %r{Encoding}
         | 
| 115 | 
            +
                path =~ %r{Ractor} || path =~ %r{Encoding} || path =~ %r{CGI_test}
         | 
| 116 116 | 
             
              end
         | 
| 117 117 |  | 
| 118 118 | 
             
              if ENV["RANDOMIZE_STDLIB_TEST_ORDER"] == "true"
         | 
| @@ -121,6 +121,7 @@ task :stdlib_test => :compile do | |
| 121 121 |  | 
| 122 122 | 
             
              sh "#{ruby} -Ilib #{bin}/test_runner.rb #{test_files.join(' ')}"
         | 
| 123 123 | 
             
              # TODO: Ractor tests need to be run in a separate process
         | 
| 124 | 
            +
              sh "#{ruby} -Ilib #{bin}/test_runner.rb test/stdlib/CGI_test.rb"
         | 
| 124 125 | 
             
              sh "#{ruby} -Ilib #{bin}/test_runner.rb test/stdlib/Ractor_test.rb"
         | 
| 125 126 | 
             
              sh "#{ruby} -Ilib #{bin}/test_runner.rb test/stdlib/Encoding_test.rb"
         | 
| 126 127 | 
             
            end
         | 
| @@ -139,7 +140,9 @@ task :typecheck_test => :compile do | |
| 139 140 | 
             
            end
         | 
| 140 141 |  | 
| 141 142 | 
             
            task :raap => :compile do
         | 
| 142 | 
            -
              sh  | 
| 143 | 
            +
              sh "ruby test/raap/core.rb"
         | 
| 144 | 
            +
              sh "ruby test/raap/digest.rb"
         | 
| 145 | 
            +
              sh "ruby test/raap/openssl.rb"
         | 
| 143 146 | 
             
            end
         | 
| 144 147 |  | 
| 145 148 | 
             
            task :rubocop do
         | 
    
        data/config.yml
    CHANGED
    
    | @@ -27,18 +27,21 @@ nodes: | |
| 27 27 | 
             
                  - name: old_name
         | 
| 28 28 | 
             
                  - name: location
         | 
| 29 29 | 
             
                  - name: comment
         | 
| 30 | 
            +
                  - name: annotations
         | 
| 30 31 | 
             
              - name: RBS::AST::Declarations::Constant
         | 
| 31 32 | 
             
                fields:
         | 
| 32 33 | 
             
                  - name: name
         | 
| 33 34 | 
             
                  - name: type
         | 
| 34 35 | 
             
                  - name: location
         | 
| 35 36 | 
             
                  - name: comment
         | 
| 37 | 
            +
                  - name: annotations
         | 
| 36 38 | 
             
              - name: RBS::AST::Declarations::Global
         | 
| 37 39 | 
             
                fields:
         | 
| 38 40 | 
             
                  - name: name
         | 
| 39 41 | 
             
                  - name: type
         | 
| 40 42 | 
             
                  - name: location
         | 
| 41 43 | 
             
                  - name: comment
         | 
| 44 | 
            +
                  - name: annotations
         | 
| 42 45 | 
             
              - name: RBS::AST::Declarations::Interface
         | 
| 43 46 | 
             
                fields:
         | 
| 44 47 | 
             
                  - name: name
         | 
| @@ -67,6 +70,7 @@ nodes: | |
| 67 70 | 
             
                  - name: old_name
         | 
| 68 71 | 
             
                  - name: location
         | 
| 69 72 | 
             
                  - name: comment
         | 
| 73 | 
            +
                  - name: annotations
         | 
| 70 74 | 
             
              - name: RBS::AST::Declarations::TypeAlias
         | 
| 71 75 | 
             
                fields:
         | 
| 72 76 | 
             
                  - name: name
         | 
| @@ -191,6 +195,7 @@ nodes: | |
| 191 195 | 
             
                  - name: variance
         | 
| 192 196 | 
             
                  - name: upper_bound
         | 
| 193 197 | 
             
                  - name: default_type
         | 
| 198 | 
            +
                  - name: unchecked
         | 
| 194 199 | 
             
                  - name: location
         | 
| 195 200 | 
             
              - name: RBS::MethodType
         | 
| 196 201 | 
             
                fields:
         | 
| @@ -213,6 +218,7 @@ nodes: | |
| 213 218 | 
             
                  - name: location
         | 
| 214 219 | 
             
              - name: RBS::Types::Bases::Any
         | 
| 215 220 | 
             
                fields:
         | 
| 221 | 
            +
                  - name: todo
         | 
| 216 222 | 
             
                  - name: location
         | 
| 217 223 | 
             
              - name: RBS::Types::Bases::Bool
         | 
| 218 224 | 
             
                fields:
         | 
    
        data/core/data.rbs
    CHANGED
    
    | @@ -411,5 +411,5 @@ class Data | |
| 411 411 | 
             
              #     out = origin.with(z: 1) # ArgumentError: unknown keyword: :z
         | 
| 412 412 | 
             
              #     some_point = origin.with(1, 2) # ArgumentError: expected keyword arguments, got positional arguments
         | 
| 413 413 | 
             
              #
         | 
| 414 | 
            -
              def with: (**untyped) ->  | 
| 414 | 
            +
              def with: (**untyped) -> self
         | 
| 415 415 | 
             
            end
         | 
    
        data/core/enumerator.rbs
    CHANGED
    
    | @@ -613,7 +613,18 @@ end | |
| 613 613 | 
             
            # This type of objects can be created by Enumerable#chain and Enumerator#+.
         | 
| 614 614 | 
             
            #
         | 
| 615 615 | 
             
            class Enumerator::Chain[out Elem] < Enumerator[Elem, void]
         | 
| 616 | 
            -
               | 
| 616 | 
            +
              # <!--
         | 
| 617 | 
            +
              #   rdoc-file=enumerator.c
         | 
| 618 | 
            +
              #   - Enumerator::Chain.new(*enums) -> enum
         | 
| 619 | 
            +
              # -->
         | 
| 620 | 
            +
              # Generates a new enumerator object that iterates over the elements of given
         | 
| 621 | 
            +
              # enumerable objects in sequence.
         | 
| 622 | 
            +
              #
         | 
| 623 | 
            +
              #     e = Enumerator::Chain.new(1..3, [4, 5])
         | 
| 624 | 
            +
              #     e.to_a #=> [1, 2, 3, 4, 5]
         | 
| 625 | 
            +
              #     e.size #=> 5
         | 
| 626 | 
            +
              #
         | 
| 627 | 
            +
              def initialize: (*_Each[Elem] enums) -> void
         | 
| 617 628 |  | 
| 618 629 | 
             
              # <!--
         | 
| 619 630 | 
             
              #   rdoc-file=enumerator.c
         | 
| @@ -626,5 +637,6 @@ class Enumerator::Chain[out Elem] < Enumerator[Elem, void] | |
| 626 637 | 
             
              #
         | 
| 627 638 | 
             
              # If no block is given, returns an enumerator.
         | 
| 628 639 | 
             
              #
         | 
| 629 | 
            -
              def each: () { (Elem) -> void } ->  | 
| 640 | 
            +
              def each: () { (Elem) -> void } -> self
         | 
| 641 | 
            +
                      | () -> Enumerator[Elem, self]
         | 
| 630 642 | 
             
            end
         | 
    
        data/core/exception.rbs
    CHANGED
    
    | @@ -99,24 +99,31 @@ class Exception | |
| 99 99 | 
             
              #   rdoc-file=error.c
         | 
| 100 100 | 
             
              #   - backtrace -> array or nil
         | 
| 101 101 | 
             
              # -->
         | 
| 102 | 
            -
              # Returns  | 
| 103 | 
            -
              #  | 
| 102 | 
            +
              # Returns the backtrace (the list of code locations that led to the exception),
         | 
| 103 | 
            +
              # as an array of strings.
         | 
| 104 104 | 
             
              #
         | 
| 105 | 
            -
              #  | 
| 106 | 
            -
              #     given by `Exception#backtrace_locations.map {|loc| loc.to_s }`. This is
         | 
| 107 | 
            -
              #     the normal case, where the backtrace value was stored by Kernel#raise.
         | 
| 108 | 
            -
              # *   Array of strings: returns that array. This is the unusual case, where the
         | 
| 109 | 
            -
              #     backtrace value was explicitly stored as an array of strings.
         | 
| 110 | 
            -
              # *   `nil`: returns `nil`.
         | 
| 105 | 
            +
              # Example (assuming the code is stored in the file named `t.rb`):
         | 
| 111 106 | 
             
              #
         | 
| 112 | 
            -
              #  | 
| 107 | 
            +
              #     def division(numerator, denominator)
         | 
| 108 | 
            +
              #       numerator / denominator
         | 
| 109 | 
            +
              #     end
         | 
| 113 110 | 
             
              #
         | 
| 114 111 | 
             
              #     begin
         | 
| 115 | 
            -
              #       1  | 
| 116 | 
            -
              #     rescue =>  | 
| 117 | 
            -
              #        | 
| 112 | 
            +
              #       division(1, 0)
         | 
| 113 | 
            +
              #     rescue => ex
         | 
| 114 | 
            +
              #       p ex.backtrace
         | 
| 115 | 
            +
              #       # ["t.rb:2:in 'Integer#/'", "t.rb:2:in 'Object#division'", "t.rb:6:in '<main>'"]
         | 
| 116 | 
            +
              #       loc = ex.backtrace.first
         | 
| 117 | 
            +
              #       p loc.class
         | 
| 118 | 
            +
              #       # String
         | 
| 118 119 | 
             
              #     end
         | 
| 119 | 
            -
              # | 
| 120 | 
            +
              #
         | 
| 121 | 
            +
              # The value returned by this method migth be adjusted when raising (see
         | 
| 122 | 
            +
              # Kernel#raise), or during intermediate handling by #set_backtrace.
         | 
| 123 | 
            +
              #
         | 
| 124 | 
            +
              # See also #backtrace_locations that provide the same value, as structured
         | 
| 125 | 
            +
              # objects. (Note though that two values might not be consistent with each other
         | 
| 126 | 
            +
              # when backtraces are manually adjusted.)
         | 
| 120 127 | 
             
              #
         | 
| 121 128 | 
             
              # see [Backtraces](rdoc-ref:exceptions.md@Backtraces).
         | 
| 122 129 | 
             
              #
         | 
| @@ -126,20 +133,37 @@ class Exception | |
| 126 133 | 
             
              #   rdoc-file=error.c
         | 
| 127 134 | 
             
              #   - backtrace_locations -> array or nil
         | 
| 128 135 | 
             
              # -->
         | 
| 129 | 
            -
              # Returns  | 
| 130 | 
            -
              #  | 
| 136 | 
            +
              # Returns the backtrace (the list of code locations that led to the exception),
         | 
| 137 | 
            +
              # as an array of Thread::Backtrace::Location instances.
         | 
| 131 138 | 
             
              #
         | 
| 132 | 
            -
              #  | 
| 133 | 
            -
              # *   Array of strings or `nil`: returns `nil`.
         | 
| 139 | 
            +
              # Example (assuming the code is stored in the file named `t.rb`):
         | 
| 134 140 | 
             
              #
         | 
| 135 | 
            -
              #  | 
| 141 | 
            +
              #     def division(numerator, denominator)
         | 
| 142 | 
            +
              #       numerator / denominator
         | 
| 143 | 
            +
              #     end
         | 
| 136 144 | 
             
              #
         | 
| 137 145 | 
             
              #     begin
         | 
| 138 | 
            -
              #       1  | 
| 139 | 
            -
              #     rescue =>  | 
| 140 | 
            -
              #        | 
| 146 | 
            +
              #       division(1, 0)
         | 
| 147 | 
            +
              #     rescue => ex
         | 
| 148 | 
            +
              #       p ex.backtrace_locations
         | 
| 149 | 
            +
              #       # ["t.rb:2:in 'Integer#/'", "t.rb:2:in 'Object#division'", "t.rb:6:in '<main>'"]
         | 
| 150 | 
            +
              #       loc = ex.backtrace_locations.first
         | 
| 151 | 
            +
              #       p loc.class
         | 
| 152 | 
            +
              #       # Thread::Backtrace::Location
         | 
| 153 | 
            +
              #       p loc.path
         | 
| 154 | 
            +
              #       # "t.rb"
         | 
| 155 | 
            +
              #       p loc.lineno
         | 
| 156 | 
            +
              #       # 2
         | 
| 157 | 
            +
              #       p loc.label
         | 
| 158 | 
            +
              #       # "Integer#/"
         | 
| 141 159 | 
             
              #     end
         | 
| 142 | 
            -
              # | 
| 160 | 
            +
              #
         | 
| 161 | 
            +
              # The value returned by this method might be adjusted when raising (see
         | 
| 162 | 
            +
              # Kernel#raise), or during intermediate handling by #set_backtrace.
         | 
| 163 | 
            +
              #
         | 
| 164 | 
            +
              # See also #backtrace that provide the same value as an array of strings. (Note
         | 
| 165 | 
            +
              # though that two values might not be consistent with each other when backtraces
         | 
| 166 | 
            +
              # are manually adjusted.)
         | 
| 143 167 | 
             
              #
         | 
| 144 168 | 
             
              # See [Backtraces](rdoc-ref:exceptions.md@Backtraces).
         | 
| 145 169 | 
             
              #
         | 
| @@ -246,7 +270,7 @@ class Exception | |
| 246 270 | 
             
              #     x0..equal?(x1)            # => false
         | 
| 247 271 | 
             
              #
         | 
| 248 272 | 
             
              def exception: (?self) -> self
         | 
| 249 | 
            -
                           | (string | _ToS message) ->  | 
| 273 | 
            +
                           | (string | _ToS message) -> self
         | 
| 250 274 |  | 
| 251 275 | 
             
              # <!--
         | 
| 252 276 | 
             
              #   rdoc-file=error.c
         | 
| @@ -294,15 +318,100 @@ class Exception | |
| 294 318 | 
             
              #   rdoc-file=error.c
         | 
| 295 319 | 
             
              #   - set_backtrace(value) -> value
         | 
| 296 320 | 
             
              # -->
         | 
| 297 | 
            -
              # Sets the backtrace value for `self`; returns the given  | 
| 321 | 
            +
              # Sets the backtrace value for `self`; returns the given `value`.
         | 
| 298 322 | 
             
              #
         | 
| 299 | 
            -
              # | 
| 300 | 
            -
              #     x.set_backtrace(%w[foo bar baz]) # => ["foo", "bar", "baz"]
         | 
| 301 | 
            -
              #     x.backtrace                      # => ["foo", "bar", "baz"]
         | 
| 323 | 
            +
              # The `value` might be:
         | 
| 302 324 | 
             
              #
         | 
| 303 | 
            -
              #  | 
| 325 | 
            +
              # *   an array of Thread::Backtrace::Location;
         | 
| 326 | 
            +
              # *   an array of String instances;
         | 
| 327 | 
            +
              # *   a single String instance; or
         | 
| 328 | 
            +
              # *   `nil`.
         | 
| 329 | 
            +
              #
         | 
| 330 | 
            +
              # Using array of Thread::Backtrace::Location is the most consistent option: it
         | 
| 331 | 
            +
              # sets both #backtrace and #backtrace_locations. It should be preferred when
         | 
| 332 | 
            +
              # possible. The suitable array of locations can be obtained from
         | 
| 333 | 
            +
              # Kernel#caller_locations, copied from another error, or just set to the
         | 
| 334 | 
            +
              # adjusted result of the current error's #backtrace_locations:
         | 
| 335 | 
            +
              #
         | 
| 336 | 
            +
              #     require 'json'
         | 
| 337 | 
            +
              #
         | 
| 338 | 
            +
              #     def parse_payload(text)
         | 
| 339 | 
            +
              #       JSON.parse(text)  # test.rb, line 4
         | 
| 340 | 
            +
              #     rescue JSON::ParserError => ex
         | 
| 341 | 
            +
              #       ex.set_backtrace(ex.backtrace_locations[2...])
         | 
| 342 | 
            +
              #       raise
         | 
| 343 | 
            +
              #     end
         | 
| 304 344 | 
             
              #
         | 
| 305 | 
            -
              #  | 
| 345 | 
            +
              #     parse_payload('{"wrong: "json"')
         | 
| 346 | 
            +
              #     # test.rb:4:in 'Object#parse_payload': unexpected token at '{"wrong: "json"' (JSON::ParserError)
         | 
| 347 | 
            +
              #     #
         | 
| 348 | 
            +
              #     # An error points to the body of parse_payload method,
         | 
| 349 | 
            +
              #     # hiding the parts of the backtrace related to the internals
         | 
| 350 | 
            +
              #     # of the "json" library
         | 
| 351 | 
            +
              #
         | 
| 352 | 
            +
              #     # The error has both #backtace and #backtrace_locations set
         | 
| 353 | 
            +
              #     # consistently:
         | 
| 354 | 
            +
              #     begin
         | 
| 355 | 
            +
              #       parse_payload('{"wrong: "json"')
         | 
| 356 | 
            +
              #     rescue => ex
         | 
| 357 | 
            +
              #       p ex.backtrace
         | 
| 358 | 
            +
              #       # ["test.rb:4:in 'Object#parse_payload'", "test.rb:20:in '<main>'"]
         | 
| 359 | 
            +
              #       p ex.backtrace_locations
         | 
| 360 | 
            +
              #       # ["test.rb:4:in 'Object#parse_payload'", "test.rb:20:in '<main>'"]
         | 
| 361 | 
            +
              #     end
         | 
| 362 | 
            +
              #
         | 
| 363 | 
            +
              # When the desired stack of locations is not available and should be constructed
         | 
| 364 | 
            +
              # from scratch, an array of strings or a singular string can be used. In this
         | 
| 365 | 
            +
              # case, only #backtrace is affected:
         | 
| 366 | 
            +
              #
         | 
| 367 | 
            +
              #     def parse_payload(text)
         | 
| 368 | 
            +
              #       JSON.parse(text)
         | 
| 369 | 
            +
              #     rescue JSON::ParserError => ex
         | 
| 370 | 
            +
              #       ex.set_backtrace(["dsl.rb:34", "framework.rb:1"])
         | 
| 371 | 
            +
              #       # The error have the new value in #backtrace:
         | 
| 372 | 
            +
              #       p ex.backtrace
         | 
| 373 | 
            +
              #       # ["dsl.rb:34", "framework.rb:1"]
         | 
| 374 | 
            +
              #
         | 
| 375 | 
            +
              #       # but the original one in #backtrace_locations
         | 
| 376 | 
            +
              #       p ex.backtrace_locations
         | 
| 377 | 
            +
              #       # [".../json/common.rb:221:in 'JSON::Ext::Parser.parse'", ...]
         | 
| 378 | 
            +
              #     end
         | 
| 379 | 
            +
              #
         | 
| 380 | 
            +
              #     parse_payload('{"wrong: "json"')
         | 
| 381 | 
            +
              #
         | 
| 382 | 
            +
              # Calling #set_backtrace with `nil` clears up #backtrace but doesn't affect
         | 
| 383 | 
            +
              # #backtrace_locations:
         | 
| 384 | 
            +
              #
         | 
| 385 | 
            +
              #     def parse_payload(text)
         | 
| 386 | 
            +
              #       JSON.parse(text)
         | 
| 387 | 
            +
              #     rescue JSON::ParserError => ex
         | 
| 388 | 
            +
              #       ex.set_backtrace(nil)
         | 
| 389 | 
            +
              #       p ex.backtrace
         | 
| 390 | 
            +
              #       # nil
         | 
| 391 | 
            +
              #       p ex.backtrace_locations
         | 
| 392 | 
            +
              #       # [".../json/common.rb:221:in 'JSON::Ext::Parser.parse'", ...]
         | 
| 393 | 
            +
              #     end
         | 
| 394 | 
            +
              #
         | 
| 395 | 
            +
              #     parse_payload('{"wrong: "json"')
         | 
| 396 | 
            +
              #
         | 
| 397 | 
            +
              # On reraising of such an exception, both #backtrace and #backtrace_locations is
         | 
| 398 | 
            +
              # set to the place of reraising:
         | 
| 399 | 
            +
              #
         | 
| 400 | 
            +
              #     def parse_payload(text)
         | 
| 401 | 
            +
              #       JSON.parse(text)
         | 
| 402 | 
            +
              #     rescue JSON::ParserError => ex
         | 
| 403 | 
            +
              #       ex.set_backtrace(nil)
         | 
| 404 | 
            +
              #       raise # test.rb, line 7
         | 
| 405 | 
            +
              #     end
         | 
| 406 | 
            +
              #
         | 
| 407 | 
            +
              #     begin
         | 
| 408 | 
            +
              #       parse_payload('{"wrong: "json"')
         | 
| 409 | 
            +
              #     rescue => ex
         | 
| 410 | 
            +
              #       p ex.backtrace
         | 
| 411 | 
            +
              #       # ["test.rb:7:in 'Object#parse_payload'", "test.rb:11:in '<main>'"]
         | 
| 412 | 
            +
              #       p ex.backtrace_locations
         | 
| 413 | 
            +
              #       # ["test.rb:7:in 'Object#parse_payload'", "test.rb:11:in '<main>'"]
         | 
| 414 | 
            +
              #     end
         | 
| 306 415 | 
             
              #
         | 
| 307 416 | 
             
              # See [Backtraces](rdoc-ref:exceptions.md@Backtraces).
         | 
| 308 417 | 
             
              #
         | 
| @@ -358,16 +467,16 @@ class Exception | |
| 358 467 | 
             
              # Output:
         | 
| 359 468 | 
             
              #
         | 
| 360 469 | 
             
              #     "divided by 0"
         | 
| 361 | 
            -
              #     ["t.rb:3:in  | 
| 362 | 
            -
              #      "\tfrom t.rb:3:in  | 
| 363 | 
            -
              #      "\tfrom t.rb:10:in  | 
| 364 | 
            -
              #      "\tfrom t.rb:11:in  | 
| 365 | 
            -
              #      "\tfrom t.rb:12:in  | 
| 366 | 
            -
              #     ["t.rb:3:in  | 
| 367 | 
            -
              #      "\tfrom t.rb:3:in  | 
| 368 | 
            -
              #      "\tfrom t.rb:10:in  | 
| 369 | 
            -
              #      "\tfrom t.rb:11:in  | 
| 370 | 
            -
              #      "\tfrom t.rb:12:in  | 
| 470 | 
            +
              #     ["t.rb:3:in 'Integer#/': divided by 0 (ZeroDivisionError)",
         | 
| 471 | 
            +
              #      "\tfrom t.rb:3:in 'Object#baz'",
         | 
| 472 | 
            +
              #      "\tfrom t.rb:10:in 'Object#bar'",
         | 
| 473 | 
            +
              #      "\tfrom t.rb:11:in 'Object#foo'",
         | 
| 474 | 
            +
              #      "\tfrom t.rb:12:in '<main>'"]
         | 
| 475 | 
            +
              #     ["t.rb:3:in 'Integer#/': \e[1mdivided by 0 (\e[1;4mZeroDivisionError\e[m\e[1m)\e[m",
         | 
| 476 | 
            +
              #      "\tfrom t.rb:3:in 'Object#baz'",
         | 
| 477 | 
            +
              #      "\tfrom t.rb:10:in 'Object#bar'",
         | 
| 478 | 
            +
              #      "\tfrom t.rb:11:in 'Object#foo'",
         | 
| 479 | 
            +
              #      "\tfrom t.rb:12:in '<main>'"]
         | 
| 371 480 | 
             
              #
         | 
| 372 481 | 
             
              # An overriding method should be careful with ANSI code enhancements; see
         | 
| 373 482 | 
             
              # [Messages](rdoc-ref:exceptions.md@Messages).
         | 
    
        data/core/gc.rbs
    CHANGED
    
    | @@ -111,7 +111,7 @@ module GC | |
| 111 111 | 
             
                # `:HAVE_FINALIZE`
         | 
| 112 112 | 
             
                # :
         | 
| 113 113 | 
             
                #
         | 
| 114 | 
            -
                def self.raw_data: () -> Array[Hash[Symbol, untyped]]
         | 
| 114 | 
            +
                def self.raw_data: () -> Array[Hash[Symbol, untyped]]?
         | 
| 115 115 |  | 
| 116 116 | 
             
                # <!--
         | 
| 117 117 | 
             
                #   rdoc-file=gc.c
         | 
| @@ -587,7 +587,7 @@ module GC | |
| 587 587 |  | 
| 588 588 | 
             
              # The type that `GC.compact` and related functions can return.
         | 
| 589 589 | 
             
              #
         | 
| 590 | 
            -
              type compact_info = Hash[:considered | :moved  | 
| 590 | 
            +
              type compact_info = Hash[:considered | :moved | :moved_up | :moved_down, Hash[Symbol, Integer]]
         | 
| 591 591 |  | 
| 592 592 | 
             
              # <!--
         | 
| 593 593 | 
             
              #   rdoc-file=gc.rb
         | 
    
        data/core/io.rbs
    CHANGED
    
    | @@ -2278,7 +2278,7 @@ class IO < Object | |
| 2278 2278 | 
             
              # potential security vulnerabilities if called with untrusted input; see
         | 
| 2279 2279 | 
             
              # [Command Injection](rdoc-ref:command_injection.rdoc).
         | 
| 2280 2280 | 
             
              #
         | 
| 2281 | 
            -
              def self.binread: (String name, ?Integer length, ?Integer offset) -> String
         | 
| 2281 | 
            +
              def self.binread: (String name, ?Integer? length, ?Integer offset) -> String
         | 
| 2282 2282 |  | 
| 2283 2283 | 
             
              # <!--
         | 
| 2284 2284 | 
             
              #   rdoc-file=io.c
         | 
| @@ -2343,7 +2343,7 @@ class IO < Object | |
| 2343 2343 | 
             
              #     IO.copy_stream('t.txt', 't.tmp', 11, 11) # => 11
         | 
| 2344 2344 | 
             
              #     IO.read('t.tmp')                         # => "Second line"
         | 
| 2345 2345 | 
             
              #
         | 
| 2346 | 
            -
              def self.copy_stream: (String | _Reader | _ReaderPartial src, String | _Writer dst, ?Integer copy_length, ?Integer src_offset) -> Integer
         | 
| 2346 | 
            +
              def self.copy_stream: (String | _Reader | _ReaderPartial src, String | _Writer dst, ?Integer? copy_length, ?Integer src_offset) -> Integer
         | 
| 2347 2347 |  | 
| 2348 2348 | 
             
              # <!--
         | 
| 2349 2349 | 
             
              #   rdoc-file=io.c
         | 
| @@ -2716,7 +2716,7 @@ class IO < Object | |
| 2716 2716 | 
             
              # *   [Open Options](rdoc-ref:IO@Open+Options).
         | 
| 2717 2717 | 
             
              # *   [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
         | 
| 2718 2718 | 
             
              #
         | 
| 2719 | 
            -
              def self.read: (String name, ?Integer length, ?Integer offset, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String) -> String
         | 
| 2719 | 
            +
              def self.read: (String name, ?Integer? length, ?Integer offset, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String) -> String
         | 
| 2720 2720 |  | 
| 2721 2721 | 
             
              # <!--
         | 
| 2722 2722 | 
             
              #   rdoc-file=io.c
         | 
| @@ -3251,6 +3251,10 @@ class IO < Object | |
| 3251 3251 | 
             
              #     f.close
         | 
| 3252 3252 | 
             
              #
         | 
| 3253 3253 | 
             
              alias to_i fileno
         | 
| 3254 | 
            +
             | 
| 3255 | 
            +
              interface _ForFd[RET]
         | 
| 3256 | 
            +
                def for_fd: (?) -> RET
         | 
| 3257 | 
            +
              end
         | 
| 3254 3258 | 
             
            end
         | 
| 3255 3259 |  | 
| 3256 3260 | 
             
            IO::APPEND: Integer
         |