rbs 4.0.2 → 4.1.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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +2 -0
  3. data/.github/workflows/bundle-update.yml +4 -1
  4. data/.github/workflows/dependabot.yml +1 -1
  5. data/.github/workflows/milestone.yml +2 -2
  6. data/.github/workflows/ruby.yml +34 -0
  7. data/.github/workflows/rust.yml +93 -7
  8. data/.gitignore +4 -0
  9. data/Rakefile +209 -2
  10. data/config.yml +24 -0
  11. data/core/builtin.rbs +1 -0
  12. data/core/class.rbs +5 -3
  13. data/core/kernel.rbs +26 -11
  14. data/core/ruby_vm.rbs +40 -0
  15. data/docs/inline.md +29 -1
  16. data/docs/rust.md +96 -0
  17. data/ext/rbs_extension/ast_translation.c +21 -0
  18. data/ext/rbs_extension/class_constants.c +2 -0
  19. data/ext/rbs_extension/class_constants.h +1 -0
  20. data/ext/rbs_extension/extconf.rb +1 -0
  21. data/include/rbs/ast.h +314 -297
  22. data/include/rbs/defines.h +13 -0
  23. data/include/rbs/lexer.h +1 -0
  24. data/lib/rbs/annotate/rdoc_annotator.rb +27 -31
  25. data/lib/rbs/ast/ruby/annotations.rb +42 -0
  26. data/lib/rbs/ast/ruby/declarations.rb +11 -1
  27. data/lib/rbs/ast/ruby/members.rb +28 -0
  28. data/lib/rbs/cli.rb +3 -5
  29. data/lib/rbs/collection/config/lockfile_generator.rb +14 -1
  30. data/lib/rbs/environment.rb +6 -0
  31. data/lib/rbs/inline_parser.rb +49 -25
  32. data/lib/rbs/rewriter.rb +70 -0
  33. data/lib/rbs/test/type_check.rb +6 -1
  34. data/lib/rbs/version.rb +1 -1
  35. data/lib/rbs.rb +1 -0
  36. data/sig/annotate/rdoc_annotater.rbs +12 -9
  37. data/sig/ast/ruby/annotations.rbs +49 -0
  38. data/sig/ast/ruby/members.rbs +15 -0
  39. data/sig/collection/config/lockfile_generator.rbs +2 -0
  40. data/sig/inline_parser.rbs +2 -0
  41. data/sig/manifest.yaml +0 -1
  42. data/sig/rewriter.rbs +45 -0
  43. data/src/ast.c +109 -85
  44. data/src/lexer.c +137 -114
  45. data/src/lexer.re +1 -0
  46. data/src/lexstate.c +1 -0
  47. data/src/parser.c +55 -5
  48. data/stdlib/openssl/0/openssl.rbs +2 -2
  49. metadata +6 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1da4c0401b4c4e3d9227c23723bf0e3cc51f58e9c911f1534526a7fe750eae78
4
- data.tar.gz: 4e12069d325cdfca8da57b3acf1ccf422cafc7d2152dcb3e1c83ebb07f52f132
3
+ metadata.gz: ef0d5eb6481b99be0816dbcef78f1cc40371104f4ef3e82b40ffcbbc3e78dccc
4
+ data.tar.gz: a728bc39e8ef49146542b121956fc5555d8eecb066febe271bb04b0beaf56ea3
5
5
  SHA512:
6
- metadata.gz: 8db2b3a45fd8208c86b2273da9dbc3fd660692b33cd4a42dc7d821d07a00afb3508cf8bbec734de990a43dfc6eac485a76fd53efd763583f16a1704ddcc45f0c
7
- data.tar.gz: ef0b3baac7b77b777fc6741b3d0b12aec8b0d03a7a93a2188f872dd18f39fc77687dc106128c5765413c9daa18a998e456226271d6790d41b92f87a3937e17d4
6
+ metadata.gz: d0a018f3245ae90e747f649b1e306edf8084147a3db4138b929a74736b86fe8f404b3e0d4aef35b212bf8da149e4d7b0088d22b5c1bd27a006aed253dec82d88
7
+ data.tar.gz: 65a1efb7bc0484e7744c7df1ef70c193918f5a5d5690c00bdadcb5b29bbf8b5b18719643e31b6ea93b2a4ae56874965b5116f43de1569deb5ff24b96e221a7c7
@@ -20,3 +20,5 @@ updates:
20
20
  directory: '/'
21
21
  schedule:
22
22
  interval: 'weekly'
23
+ labels:
24
+ - 'no-milestone'
@@ -57,4 +57,7 @@ jobs:
57
57
  --title "bundle update ($(date +'%Y-%m-%d'))" \
58
58
  --body "Automated weekly bundle update" \
59
59
  --head "$(git rev-parse --abbrev-ref HEAD)" \
60
- --base "${{ github.event.repository.default_branch }}"
60
+ --base "${{ github.event.repository.default_branch }}" \
61
+ --label "no-milestone"
62
+
63
+ gh pr merge --auto --merge "$(git rev-parse --abbrev-ref HEAD)"
@@ -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@21025c705c08248db411dc16f3619e6b5f9ea21a # v2.5.0
17
+ uses: dependabot/fetch-metadata@ffa630c65fa7e0ecfa0625b5ceda64399aea1b36 # v3.0.0
18
18
  id: metadata
19
19
  - name: Checkout repository
20
20
  uses: actions/checkout@v6
@@ -9,7 +9,7 @@ jobs:
9
9
  runs-on: ubuntu-latest
10
10
 
11
11
  steps:
12
- - uses: actions/checkout@v4
12
+ - uses: actions/checkout@v6
13
13
 
14
14
  - name: Extract RBS::Version
15
15
  id: version
@@ -27,7 +27,7 @@ jobs:
27
27
  echo "RBS::VERSION = $version (major=$major, minor=$minor, patch=$patch)"
28
28
 
29
29
  - name: Check milestone
30
- uses: actions/github-script@v7
30
+ uses: actions/github-script@v8
31
31
  with:
32
32
  script: |
33
33
  const pr = context.payload.pull_request;
@@ -110,3 +110,37 @@ jobs:
110
110
  run: |
111
111
  bin/setup
112
112
  - run: bundle exec rake clean compile_c99
113
+
114
+ clang_compile:
115
+ runs-on: macos-latest
116
+ strategy:
117
+ fail-fast: false
118
+ matrix:
119
+ ruby: ['4.0', head]
120
+ steps:
121
+ - uses: actions/checkout@v6
122
+ - name: Install dependencies
123
+ run: |
124
+ brew install ruby-build
125
+ - uses: ruby/setup-ruby@v1
126
+ with:
127
+ ruby-version: ${{ matrix.ruby }}
128
+ bundler: none
129
+ - name: Set working directory as safe
130
+ run: git config --global --add safe.directory $(pwd)
131
+ - name: Update rubygems & bundler
132
+ run: |
133
+ ruby -v
134
+ gem update --system
135
+ - name: install erb
136
+ run: gem install erb
137
+ - name: clang version
138
+ run: clang --version
139
+ - name: bundle config set force_ruby_platform true if head
140
+ if: ${{ contains(matrix.ruby, 'head') }}
141
+ run: |
142
+ bundle config set force_ruby_platform true
143
+ - name: bin/setup
144
+ run: |
145
+ bin/setup
146
+ - run: bundle exec rake clean compile
@@ -8,8 +8,6 @@ on:
8
8
  paths:
9
9
  - ".github/workflows/rust.yml"
10
10
  - "rust/**"
11
- - "include/**"
12
- - "src/**"
13
11
 
14
12
  env:
15
13
  RUSTFLAGS: "-D warnings"
@@ -24,6 +22,20 @@ jobs:
24
22
  os: [ubuntu-latest, macos-latest, windows-latest]
25
23
  steps:
26
24
  - uses: actions/checkout@v6
25
+ - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
26
+ - name: Set up Ruby
27
+ uses: ruby/setup-ruby@v1
28
+ with:
29
+ ruby-version: ruby
30
+ bundler: none
31
+ - name: Update rubygems & bundler
32
+ run: gem update --system
33
+ - name: Install gems
34
+ run: |
35
+ bundle config set --local without libs:profilers
36
+ bundle install --jobs 4 --retry 3
37
+ - name: Set up vendored RBS source
38
+ run: bundle exec rake rust:rbs:sync
27
39
  - name: Install Rust tools
28
40
  run: |
29
41
  rustup update --no-self-update stable
@@ -42,12 +54,30 @@ jobs:
42
54
  cd rust
43
55
  cargo test --verbose
44
56
 
45
- publish-dry-run:
46
- name: cargo:publish-dry-run
57
+ publish-dry-run-ruby-rbs-sys:
58
+ name: rust:publish:ruby-rbs-sys
47
59
  runs-on: ubuntu-latest
48
60
  continue-on-error: true
49
61
  steps:
50
62
  - uses: actions/checkout@v6
63
+ - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
64
+ - name: Set up git identity
65
+ run: |
66
+ git config user.name "GitHub Actions"
67
+ git config user.email "actions@github.com"
68
+ - name: Set up Ruby
69
+ uses: ruby/setup-ruby@v1
70
+ with:
71
+ ruby-version: ruby
72
+ bundler: none
73
+ - name: Update rubygems & bundler
74
+ run: gem update --system
75
+ - name: Install gems
76
+ run: |
77
+ bundle config set --local without libs:profilers
78
+ bundle install --jobs 4 --retry 3
79
+ - name: Set up vendored RBS source
80
+ run: bundle exec rake rust:rbs:sync
51
81
  - name: Install Rust tools
52
82
  run: |
53
83
  rustup update --no-self-update stable
@@ -61,16 +91,72 @@ jobs:
61
91
  key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }}
62
92
  restore-keys: |
63
93
  ${{ runner.os }}-cargo-
64
- - name: Test publish crates
94
+ - name: Test publish ruby-rbs-sys
95
+ run: bundle exec rake rust:publish:ruby-rbs-sys
96
+ env:
97
+ RBS_RUST_PUBLISH_DRY_RUN: "1"
98
+
99
+ publish-dry-run-ruby-rbs:
100
+ name: rust:publish:ruby-rbs
101
+ runs-on: ubuntu-latest
102
+ continue-on-error: true
103
+ steps:
104
+ - uses: actions/checkout@v6
105
+ - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
106
+ - name: Set up git identity
65
107
  run: |
66
- cd rust
67
- cargo publish --dry-run
108
+ git config user.name "GitHub Actions"
109
+ git config user.email "actions@github.com"
110
+ - name: Set up Ruby
111
+ uses: ruby/setup-ruby@v1
112
+ with:
113
+ ruby-version: ruby
114
+ bundler: none
115
+ - name: Update rubygems & bundler
116
+ run: gem update --system
117
+ - name: Install gems
118
+ run: |
119
+ bundle config set --local without libs:profilers
120
+ bundle install --jobs 4 --retry 3
121
+ - name: Set up vendored RBS source
122
+ run: bundle exec rake rust:rbs:sync
123
+ - name: Install Rust tools
124
+ run: |
125
+ rustup update --no-self-update stable
126
+ rustup default stable
127
+ - uses: actions/cache@v5
128
+ with:
129
+ path: |
130
+ ~/.cargo/registry
131
+ ~/.cargo/git
132
+ rust/target
133
+ key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }}
134
+ restore-keys: |
135
+ ${{ runner.os }}-cargo-
136
+ - name: Test publish ruby-rbs
137
+ run: bundle exec rake rust:publish:ruby-rbs
138
+ env:
139
+ RBS_RUST_PUBLISH_DRY_RUN: "1"
68
140
 
69
141
  lint:
70
142
  name: cargo:lint
71
143
  runs-on: ubuntu-latest
72
144
  steps:
73
145
  - uses: actions/checkout@v6
146
+ - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
147
+ - name: Set up Ruby
148
+ uses: ruby/setup-ruby@v1
149
+ with:
150
+ ruby-version: ruby
151
+ bundler: none
152
+ - name: Update rubygems & bundler
153
+ run: gem update --system
154
+ - name: Install gems
155
+ run: |
156
+ bundle config set --local without libs:profilers
157
+ bundle install --jobs 4 --retry 3
158
+ - name: Set up vendored RBS source
159
+ run: bundle exec rake rust:rbs:sync
74
160
  - name: Install Rust tools
75
161
  run: |
76
162
  rustup update --no-self-update stable
data/.gitignore CHANGED
@@ -25,3 +25,7 @@ doc/
25
25
  # For clangd's editor integration
26
26
  ext/rbs_extension/compile_commands.json
27
27
  ext/rbs_extension/.cache
28
+
29
+ # Rust crate vendored RBS source (managed by rake rust:rbs:sync or rust:rbs:symlink)
30
+ rust/ruby-rbs-sys/vendor/rbs/
31
+ rust/ruby-rbs/vendor/rbs/
data/Rakefile CHANGED
@@ -199,12 +199,15 @@ task :validate => :compile do
199
199
  libs << "rbs"
200
200
  end
201
201
 
202
+ libs.delete("bigdecimal-math") or raise
203
+ libs.delete("bigdecimal") or raise
204
+
202
205
  libs.each do |lib|
203
206
  args = ["-r", lib]
204
207
 
205
208
  if lib == "rbs"
206
- args << "-r"
207
- args << "prism"
209
+ args << "-r" << "prism"
210
+ args << "-r" << "logger"
208
211
  end
209
212
 
210
213
  sh "#{ruby} #{rbs} #{args.join(' ')} validate"
@@ -545,3 +548,207 @@ task :prepare_profiling do
545
548
  Rake::Task[:"templates"].invoke
546
549
  Rake::Task[:"compile"].invoke
547
550
  end
551
+
552
+ namespace :rust do
553
+ namespace :rbs do
554
+ RUST_DIR = File.expand_path("rust", __dir__)
555
+ RBS_VERSION_FILE = File.join(RUST_DIR, "rbs_version")
556
+
557
+ VENDOR_TARGETS = {
558
+ "ruby-rbs-sys" => %w[include src],
559
+ "ruby-rbs" => %w[config.yml],
560
+ }
561
+
562
+ desc "Sync vendored RBS source from the pinned version"
563
+ task :sync do
564
+ unless File.exist?(RBS_VERSION_FILE)
565
+ raise "#{RBS_VERSION_FILE} not found. Run `rake rust:rbs:pin[VERSION]` first."
566
+ end
567
+
568
+ version = File.read(RBS_VERSION_FILE).strip
569
+ raise "#{RBS_VERSION_FILE} is empty" if version.empty?
570
+
571
+ puts "Syncing vendor/rbs/ from #{version}..."
572
+
573
+ VENDOR_TARGETS.each do |crate, entries|
574
+ vendor_dir = File.join(RUST_DIR, crate, "vendor", "rbs")
575
+
576
+ puts " Copying files for #{crate}:"
577
+ chmod_R "u+w", vendor_dir, verbose: false if File.exist?(vendor_dir)
578
+ rm_rf vendor_dir, verbose: false
579
+ mkdir_p vendor_dir, verbose: false
580
+
581
+ entries.each do |entry|
582
+ target = File.join(vendor_dir, entry)
583
+
584
+ # Extract the entry from the pinned git tag using git archive
585
+ IO.popen(["git", "archive", "--format=tar", version, "--", entry], "rb") do |tar|
586
+ IO.popen(["tar", "xf", "-", "-C", vendor_dir], "wb") do |extract|
587
+ IO.copy_stream(tar, extract)
588
+ end
589
+ end
590
+
591
+ raise "Failed to extract #{entry} from #{version}" unless File.exist?(target)
592
+ puts " #{entry}"
593
+ end
594
+
595
+ # Make files read-only to prevent accidental edits
596
+ chmod_R "a-w", vendor_dir, verbose: false
597
+ end
598
+
599
+ puts "📦 Synced vendor/rbs/ from #{version} (read-only)"
600
+ end
601
+
602
+ desc "Pin a specific RBS version for Rust crates (e.g., rake rust:rbs:pin[v4.0.3])"
603
+ task :pin, [:version] do |_t, args|
604
+ version = args[:version] or raise "Usage: rake rust:rbs:pin[VERSION]"
605
+
606
+ # Verify the tag exists
607
+ unless system("git", "rev-parse", "--verify", "#{version}^{commit}", out: File::NULL, err: File::NULL)
608
+ raise "Tag #{version} not found"
609
+ end
610
+
611
+ File.write(RBS_VERSION_FILE, "#{version}\n")
612
+ puts "📌 Pinned RBS version to #{version}"
613
+
614
+ Rake::Task["rust:rbs:sync"].invoke
615
+ end
616
+
617
+ desc "Create symlinks from vendor/rbs/ to the repository root (for development/CI)"
618
+ task :symlink do
619
+ VENDOR_TARGETS.each do |crate, entries|
620
+ vendor_dir = File.join(RUST_DIR, crate, "vendor", "rbs")
621
+
622
+ puts "Setting up symlinks for #{crate}..."
623
+ entries.each do |entry|
624
+ puts " #{entry} -> repository root"
625
+ end
626
+
627
+ chmod_R "u+w", vendor_dir, verbose: false if File.exist?(vendor_dir)
628
+ rm_rf vendor_dir, verbose: false
629
+ mkdir_p vendor_dir, verbose: false
630
+
631
+ entries.each do |entry|
632
+ ln_s File.join("..", "..", "..", "..", entry), File.join(vendor_dir, entry), verbose: false
633
+ end
634
+ end
635
+
636
+ puts "🔗 Symlinked vendor/rbs/ to repository root"
637
+ end
638
+ end
639
+
640
+ namespace :publish do
641
+ def self.prepare_publish_branch(crate_name)
642
+ dry_run = ENV["RBS_RUST_PUBLISH_DRY_RUN"]
643
+
644
+ version_file = File.join(RUST_DIR, "rbs_version")
645
+
646
+ unless File.exist?(version_file)
647
+ raise "#{version_file} not found. Run `rake rust:rbs:pin[VERSION]` first."
648
+ end
649
+
650
+ rbs_version = File.read(version_file).strip
651
+ raise "#{version_file} is empty" if rbs_version.empty?
652
+
653
+ crate_version = File.read(File.join(RUST_DIR, crate_name, "Cargo.toml"))[/^version\s*=\s*"(.+)"/, 1]
654
+ release_branch = "rust/release-#{crate_name}-#{Time.now.strftime('%Y%m%d%H%M%S')}"
655
+
656
+ puts "=" * 60
657
+ puts "Rust crate publish: #{crate_name}#{dry_run ? " (DRY RUN)" : ""}"
658
+ puts "=" * 60
659
+ puts " RBS source version: #{rbs_version}"
660
+ puts " #{crate_name}: #{crate_version} (tag: #{crate_name}-v#{crate_version})"
661
+ puts " Release branch: #{release_branch}"
662
+ puts "=" * 60
663
+
664
+ # Check that vendor dirs contain real files, not symlinks
665
+ entries = VENDOR_TARGETS.fetch(crate_name)
666
+ entries.each do |entry|
667
+ path = File.join(RUST_DIR, crate_name, "vendor", "rbs", entry)
668
+ if File.symlink?(path)
669
+ raise "#{path} is a symlink. Run `rake rust:rbs:sync` first."
670
+ end
671
+ unless File.exist?(path)
672
+ raise "#{path} does not exist. Run `rake rust:rbs:sync` first."
673
+ end
674
+ end
675
+
676
+ # Ensure working tree is clean before publishing
677
+ unless `git status --porcelain`.strip.empty?
678
+ raise "💢 Working tree is dirty. Please commit or stash your changes before publishing."
679
+ end
680
+
681
+ # Create a release branch with vendor files committed
682
+ original_branch = `git rev-parse --abbrev-ref HEAD`.strip
683
+
684
+ sh "git", "checkout", "-b", release_branch, verbose: false
685
+ vendor_path = File.join("rust", crate_name, "vendor", "rbs")
686
+ sh "git", "add", "-f", vendor_path, verbose: false
687
+ sh "git", "commit", "-m", "Publish #{crate_name} (RBS #{rbs_version})", verbose: false
688
+
689
+ [dry_run, crate_version, original_branch]
690
+ end
691
+
692
+ desc "Publish ruby-rbs-sys crate to crates.io (set RBS_RUST_PUBLISH_DRY_RUN=1 for dry-run only)"
693
+ task :"ruby-rbs-sys" do
694
+ crate_name = "ruby-rbs-sys"
695
+ dry_run, crate_version, original_branch = prepare_publish_branch(crate_name)
696
+
697
+ begin
698
+ puts "🔰 Dry-run publishing..."
699
+
700
+ Dir.chdir(File.join(RUST_DIR, crate_name)) do
701
+ sh "cargo", "publish", "--dry-run"
702
+ end
703
+
704
+ puts "✅ Dry-run succeeded!"
705
+
706
+ unless dry_run
707
+ puts "💪 Publishing #{crate_name} for real..."
708
+
709
+ Dir.chdir(File.join(RUST_DIR, crate_name)) do
710
+ sh "cargo", "publish"
711
+ end
712
+
713
+ sh "git", "tag", "#{crate_name}-v#{crate_version}"
714
+ sh "git", "push", "origin", "#{crate_name}-v#{crate_version}"
715
+
716
+ puts "🎉 Published #{crate_name} successfully!"
717
+ end
718
+ ensure
719
+ sh "git", "checkout", original_branch, verbose: false
720
+ end
721
+ end
722
+
723
+ desc "Publish ruby-rbs crate to crates.io (set RBS_RUST_PUBLISH_DRY_RUN=1 for dry-run only)"
724
+ task :"ruby-rbs" do
725
+ crate_name = "ruby-rbs"
726
+ dry_run, crate_version, original_branch = prepare_publish_branch(crate_name)
727
+
728
+ begin
729
+ puts "🔰 Dry-run publishing..."
730
+
731
+ Dir.chdir(File.join(RUST_DIR, crate_name)) do
732
+ sh "cargo", "publish", "--dry-run", "--no-verify"
733
+ end
734
+
735
+ puts "✅ Dry-run succeeded!"
736
+
737
+ unless dry_run
738
+ puts "💪 Publishing #{crate_name} for real..."
739
+
740
+ Dir.chdir(File.join(RUST_DIR, crate_name)) do
741
+ sh "cargo", "publish"
742
+ end
743
+
744
+ sh "git", "tag", "#{crate_name}-v#{crate_version}"
745
+ sh "git", "push", "origin", "#{crate_name}-v#{crate_version}"
746
+
747
+ puts "🎉 Published #{crate_name} successfully!"
748
+ end
749
+ ensure
750
+ sh "git", "checkout", original_branch, verbose: false
751
+ end
752
+ end
753
+ end
754
+ end
data/config.yml CHANGED
@@ -784,6 +784,30 @@ nodes:
784
784
  - name: type_name_location
785
785
  c_type: rbs_location_range
786
786
  optional: true
787
+ - name: RBS::AST::Ruby::Annotations::ModuleSelfAnnotation
788
+ rust_name: ModuleSelfAnnotationNode
789
+ fields:
790
+ - name: prefix_location
791
+ c_type: rbs_location_range
792
+ - name: keyword_location
793
+ c_type: rbs_location_range
794
+ - name: colon_location
795
+ c_type: rbs_location_range
796
+ - name: name
797
+ c_type: rbs_type_name
798
+ - name: args
799
+ c_type: rbs_node_list
800
+ - name: open_bracket_location
801
+ c_type: rbs_location_range
802
+ optional: true
803
+ - name: close_bracket_location
804
+ c_type: rbs_location_range
805
+ optional: true
806
+ - name: args_comma_locations
807
+ c_type: rbs_location_range_list
808
+ - name: comment_location
809
+ c_type: rbs_location_range
810
+ optional: true
787
811
  - name: RBS::AST::Ruby::Annotations::ParamTypeAnnotation
788
812
  rust_name: ParamTypeAnnotationNode
789
813
  fields:
data/core/builtin.rbs CHANGED
@@ -225,6 +225,7 @@ type int = Integer | _ToInt
225
225
 
226
226
  # Represents a `Float`, or a type convertible to it (via `.to_f`).
227
227
  #
228
+ %a{deprecated: Use `_ToF` directly}
228
229
  type float = Float | _ToF
229
230
 
230
231
  # Represents a `Range[T]`, or a type that acts like it (via `.begin`, `.end`, and `.exclude_end?`).
data/core/class.rbs CHANGED
@@ -83,7 +83,7 @@ class Class < Module
83
83
  # Assign the class to a constant (name starting uppercase) if you want to treat
84
84
  # it like a regular class.
85
85
  #
86
- def initialize: (?Class superclass) ?{ (Class newclass) -> void } -> void
86
+ def initialize: (?Class superclass) ?{ (Class newclass) [self: Class] -> void } -> void
87
87
 
88
88
  # <!--
89
89
  # rdoc-file=object.c
@@ -107,6 +107,8 @@ class Class < Module
107
107
  #
108
108
  def allocate: () -> untyped
109
109
 
110
+ def self.allocate: () -> untyped
111
+
110
112
  # <!--
111
113
  # rdoc-file=object.c
112
114
  # - attached_object -> object
@@ -150,7 +152,7 @@ class Class < Module
150
152
  # New subclass: Bar
151
153
  # New subclass: Baz
152
154
  #
153
- def inherited: (Class arg0) -> untyped
155
+ private def inherited: (Class subclass) -> void
154
156
 
155
157
  # <!--
156
158
  # rdoc-file=object.c
@@ -160,7 +162,7 @@ class Class < Module
160
162
  # object's #initialize method, passing it *args*. This is the method that ends
161
163
  # up getting called whenever an object is constructed using <code>.new</code>.
162
164
  #
163
- def new: () -> untyped
165
+ def new: (*untyped, **untyped) ?{ (?) -> untyped } -> untyped
164
166
 
165
167
  # <!--
166
168
  # rdoc-file=object.c
data/core/kernel.rbs CHANGED
@@ -182,9 +182,9 @@ module Kernel : BasicObject
182
182
  # c(4) #=> []
183
183
  # c(5) #=> nil
184
184
  #
185
- def self?.caller: (Integer start_or_range, ?Integer length) -> ::Array[String]?
186
- | (::Range[Integer] start_or_range) -> ::Array[String]?
187
- | () -> ::Array[String]
185
+ def self?.caller: () -> Array[String]
186
+ | (int start, ?int? length) -> Array[String]?
187
+ | (range[int] range) -> Array[String]?
188
188
 
189
189
  # <!--
190
190
  # rdoc-file=vm_backtrace.c
@@ -207,9 +207,9 @@ module Kernel : BasicObject
207
207
  # Optionally you can pass a range, which will return an array containing the
208
208
  # entries within the specified range.
209
209
  #
210
- def self?.caller_locations: (Integer start_or_range, ?Integer length) -> ::Array[Thread::Backtrace::Location]?
211
- | (::Range[Integer] start_or_range) -> ::Array[Thread::Backtrace::Location]?
212
- | () -> ::Array[Thread::Backtrace::Location]
210
+ def self?.caller_locations: () -> Array[Thread::Backtrace::Location]
211
+ | (int start, ?int? length) -> Array[Thread::Backtrace::Location]?
212
+ | (range[int] range) -> Array[Thread::Backtrace::Location]?
213
213
 
214
214
  # <!--
215
215
  # rdoc-file=vm_eval.c
@@ -314,6 +314,16 @@ module Kernel : BasicObject
314
314
  #
315
315
  def self?.block_given?: () -> bool
316
316
 
317
+ alias self.iterator? self.block_given?
318
+
319
+ # <!--
320
+ # rdoc-file=vm_eval.c
321
+ # - iterator? -> true or false
322
+ # -->
323
+ # Deprecated. Use block_given? instead.
324
+ #
325
+ alias iterator? block_given?
326
+
317
327
  # <!--
318
328
  # rdoc-file=vm_eval.c
319
329
  # - local_variables -> array
@@ -326,7 +336,7 @@ module Kernel : BasicObject
326
336
  # end
327
337
  # local_variables #=> [:fred, :i]
328
338
  #
329
- def self?.local_variables: () -> ::Array[Symbol]
339
+ def self?.local_variables: () -> Array[Symbol]
330
340
 
331
341
  # <!--
332
342
  # rdoc-file=random.c
@@ -788,7 +798,7 @@ module Kernel : BasicObject
788
798
  #
789
799
  # Files that are currently being loaded must not be registered for autoload.
790
800
  #
791
- def self?.autoload: (interned _module, String filename) -> NilClass
801
+ def self?.autoload: (interned const, path filename) -> nil
792
802
 
793
803
  # <!--
794
804
  # rdoc-file=load.c
@@ -812,7 +822,7 @@ module Kernel : BasicObject
812
822
  # autoload?(:B) #=> "b"
813
823
  # end
814
824
  #
815
- def self?.autoload?: (interned name) -> String?
825
+ def self?.autoload?: (interned name, ?boolish inherit) -> String?
816
826
 
817
827
  # <!--
818
828
  # rdoc-file=proc.c
@@ -1193,7 +1203,7 @@ module Kernel : BasicObject
1193
1203
  #
1194
1204
  # global_variables.grep /std/ #=> [:$stdin, :$stdout, :$stderr]
1195
1205
  #
1196
- def self?.global_variables: () -> ::Array[Symbol]
1206
+ def self?.global_variables: () -> Array[Symbol]
1197
1207
 
1198
1208
  # <!--
1199
1209
  # rdoc-file=load.c
@@ -1843,7 +1853,12 @@ module Kernel : BasicObject
1843
1853
  # ----------------|---------------------------------------------
1844
1854
  # <code>'-'</code>|Whether the entities exist and are identical.
1845
1855
  #
1846
- def self?.test: (String | Integer cmd, String | IO file1, ?String | IO file2) -> (TrueClass | FalseClass | Time | nil | Integer)
1856
+ def self?.test: ('b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'G' | 'k' | 'l' | 'o' | 'O' | 'p' | 'r' | 'R' | 'S' | 'u' | 'w' | 'W' | 'x' | 'X' | 'z' |
1857
+ 98 | 99 | 100 | 101 | 102 | 103 | 71 | 107 | 108 | 111 | 79 | 112 | 114 | 82 | 83 | 117 | 119 | 87 | 120 | 88 | 122, path filepath) -> bool
1858
+ | ('s' | 115, path filepath) -> Integer?
1859
+ | ('A' | 'M' | 'C' | 65 | 77 | 67, path filepath) -> Time
1860
+ | ('<' | '=' | '>' | '-' | 60 | 61 | 62 | 45, path filepath1, path filepath2) -> bool
1861
+ | (String | int cmd, path filepath1, ?path filepath2) -> (bool | Time | Integer | nil)
1847
1862
 
1848
1863
  # <!--
1849
1864
  # rdoc-file=vm_eval.c
data/core/ruby_vm.rbs CHANGED
@@ -371,6 +371,46 @@ class RubyVM::InstructionSequence < Object
371
371
  # event_symbol] pair.
372
372
  #
373
373
  def trace_points: () -> Array[untyped]
374
+
375
+ # <!--
376
+ # rdoc-file=iseq.c
377
+ # - of(p1)
378
+ # -->
379
+ # Returns the instruction sequence containing the given proc or method.
380
+ #
381
+ # For example, using irb:
382
+ #
383
+ # # a proc
384
+ # > p = proc { num = 1 + 2 }
385
+ # > RubyVM::InstructionSequence.of(p)
386
+ # > #=> <RubyVM::InstructionSequence:block in irb_binding@(irb)>
387
+ #
388
+ # # for a method
389
+ # > def foo(bar); puts bar; end
390
+ # > RubyVM::InstructionSequence.of(method(:foo))
391
+ # > #=> <RubyVM::InstructionSequence:foo@(irb)>
392
+ #
393
+ # Using ::compile_file:
394
+ #
395
+ # # /tmp/iseq_of.rb
396
+ # def hello
397
+ # puts "hello, world"
398
+ # end
399
+ #
400
+ # $a_global_proc = proc { str = 'a' + 'b' }
401
+ #
402
+ # # in irb
403
+ # > require '/tmp/iseq_of.rb'
404
+ #
405
+ # # first the method hello
406
+ # > RubyVM::InstructionSequence.of(method(:hello))
407
+ # > #=> #<RubyVM::InstructionSequence:0x007fb73d7cb1d0>
408
+ #
409
+ # # then the global proc
410
+ # > RubyVM::InstructionSequence.of($a_global_proc)
411
+ # > #=> #<RubyVM::InstructionSequence:0x007fb73d7caf78>
412
+ #
413
+ def self.of: (Proc | Method | UnboundMethod body) -> RubyVM::InstructionSequence?
374
414
  end
375
415
 
376
416
  # <!-- rdoc-file=ast.rb -->