diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index acd9bf63a..ede0364e1 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -44,8 +44,6 @@ jobs: bundler: none - name: Set working directory as safe run: git config --global --add safe.directory $(pwd) - - name: Set up permission - run: chmod -R o-w /opt/hostedtoolcache/Ruby - name: Install dependencies run: | sudo apt-get update @@ -90,8 +88,6 @@ jobs: bundler-cache: none - name: Set working directory as safe run: git config --global --add safe.directory $(pwd) - - name: Set up permission - run: chmod -R o-w /opt/hostedtoolcache/Ruby - name: Install dependencies run: | sudo apt-get update diff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.yml index 0afc49b99..5f737028a 100644 --- a/.github/workflows/typecheck.yml +++ b/.github/workflows/typecheck.yml @@ -20,8 +20,6 @@ jobs: bundler: none - name: Set working directory as safe run: git config --global --add safe.directory $(pwd) - - name: Set up permission - run: chmod -R o-w /opt/hostedtoolcache/Ruby - name: Install dependencies run: | sudo apt-get update diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index e93adf27e..75aa8a716 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -33,7 +33,7 @@ jobs: res = URI.parse("https://stdgems.org/bundled_gems.json").read bundled_gems = JSON.parse(res)["gems"].map{_1["gem"]} - system "gem uninstall #{bundled_gems.join(" ")}", exception: true + system "gem uninstall --force #{bundled_gems.join(" ")}", exception: true ' - name: bundle install run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index a674f168a..14ba68d78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,44 @@ # CHANGELOG +## 3.9.5 (2025-09-08) + +### Signature updates + +* Merge pull request #2655 from ruby/silence-string-deprecation ([#2656](https://github.com/ruby/rbs/pull/2656)) + +### Miscellaneous + +* Allows the use of a path list as RBS_SKIP_TESTS ([#2641](https://github.com/ruby/rbs/pull/2641)) +* Suppress to GCC warning with multi-line comment ([#2646](https://github.com/ruby/rbs/pull/2646)) +* Backport to 3.9 ([#2487](https://github.com/ruby/rbs/pull/2487)) +* Use erb instead of set for load path testing ([#2468](https://github.com/ruby/rbs/pull/2468)) + +## 3.9.4 (2025-05-15) + +### Miscellaneous + +* Backport test/CI fixes to 3.9 ([#2487](https://github.com/ruby/rbs/pull/2487)) +* Use erb instead of set for load path testing ([#2468](https://github.com/ruby/rbs/pull/2468)) + +## 3.9.3 (2025-05-09) + +### Miscellaneous + +* Use erb instead of set for load path testing ([#2468](https://github.com/ruby/rbs/pull/2468)) + +## 3.9.2 (2025-03-31) + +### Library changes + +* Change `{}` to `{ 0 }` ([#2354](https://github.com/ruby/rbs/pull/2354)) + +## 3.9.1 (2025-03-24) + +### Miscellaneous + +* `did_you_mean` is a default gem ([#2348](https://github.com/ruby/rbs/pull/2348)) +* Skip loading ruby_memcheck ([#2347](https://github.com/ruby/rbs/pull/2347)) + ## 3.9.0 (2025-03-18) ### Miscellaneous diff --git a/Gemfile b/Gemfile index 095664ffa..9c08849cc 100644 --- a/Gemfile +++ b/Gemfile @@ -11,12 +11,12 @@ gem "rspec" gem "rubocop" gem "rubocop-rubycw" gem "rubocop-on-rbs" -gem "json" +gem "json", "~> 2.10.2" gem "json-schema" gem "goodcheck" gem 'digest' gem 'tempfile' -gem "rdoc" +gem "rdoc", "~> 6.11.0" gem "fileutils" gem "raap" gem "activesupport", "~> 7.0" diff --git a/Gemfile.lock b/Gemfile.lock index c51c96159..d43f828e8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - rbs (3.9.0) + rbs (3.9.5) logger PATH @@ -27,19 +27,19 @@ GEM tzinfo (~> 2.0, >= 2.0.5) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) - ast (2.4.2) + ast (2.4.3) base64 (0.2.0) benchmark (0.4.0) benchmark-ips (2.14.0) bigdecimal (3.1.9) concurrent-ruby (1.3.5) - connection_pool (2.5.0) - csv (3.3.2) + connection_pool (2.5.3) + csv (3.3.4) dbm (1.1.0) - diff-lcs (1.6.0) + diff-lcs (1.6.1) digest (3.2.0) drb (2.2.1) - ffi (1.17.1) + ffi (1.17.2) fileutils (1.7.3) goodcheck (3.1.0) marcel (>= 1.0, < 2.0) @@ -57,7 +57,7 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - logger (1.6.6) + logger (1.7.0) marcel (1.0.4) memory_profiler (1.1.0) mini_portile2 (2.8.8) @@ -68,27 +68,28 @@ GEM net-smtp (0.5.1) net-protocol nkf (0.2.0) - nokogiri (1.18.4) + nokogiri (1.18.8) mini_portile2 (~> 2.8.2) racc (~> 1.4) ostruct (0.6.1) - parallel (1.26.3) - parser (3.3.7.1) + parallel (1.27.0) + parser (3.3.8.0) ast (~> 2.4.1) racc pathname (0.4.0) power_assert (2.0.5) + prism (1.4.0) pstore (0.2.0) psych (4.0.6) stringio - public_suffix (6.0.1) + public_suffix (6.0.2) raap (1.2.0) rbs (~> 3.0) timeout (~> 0.4) racc (1.8.1) rainbow (3.1.1) rake (13.2.1) - rake-compiler (1.2.9) + rake-compiler (1.3.0) rake rb-fsevent (0.11.2) rb-inotify (0.11.1) @@ -102,14 +103,14 @@ GEM rspec-mocks (~> 3.13.0) rspec-core (3.13.3) rspec-support (~> 3.13.0) - rspec-expectations (3.13.3) + rspec-expectations (3.13.4) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.2) + rspec-mocks (3.13.4) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-support (3.13.2) - rubocop (1.74.0) + rspec-support (3.13.3) + rubocop (1.75.5) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -117,14 +118,16 @@ GEM parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.38.0, < 2.0) + rubocop-ast (>= 1.44.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.38.1) - parser (>= 3.3.1.0) - rubocop-on-rbs (1.4.2) + rubocop-ast (1.44.1) + parser (>= 3.3.7.2) + prism (~> 1.4) + rubocop-on-rbs (1.6.0) + lint_roller (~> 1.1) rbs (~> 3.5) - rubocop (~> 1.61) + rubocop (>= 1.72.1, < 2.0) zlib rubocop-rubycw (0.2.2) lint_roller (~> 1.1) @@ -134,34 +137,37 @@ GEM nokogiri securerandom (0.4.1) stackprof (0.2.27) - steep (1.9.4) + steep (1.10.0) activesupport (>= 5.1) concurrent-ruby (>= 1.1.10) csv (>= 3.0.9) fileutils (>= 1.1.0) json (>= 2.1.0) - language_server-protocol (>= 3.15, < 4.0) + language_server-protocol (>= 3.17.0.4, < 4.0) listen (~> 3.0) logger (>= 1.3.0) + mutex_m (>= 0.3.0) parser (>= 3.1) rainbow (>= 2.2.2, < 4.0) - rbs (~> 3.8) + rbs (~> 3.9) securerandom (>= 0.1) strscan (>= 1.0.0) - terminal-table (>= 2, < 4) + terminal-table (>= 2, < 5) uri (>= 0.12.0) - stringio (3.1.5) + stringio (3.1.7) strong_json (2.1.2) - strscan (3.1.2) + strscan (3.1.5) tempfile (0.3.1) - terminal-table (3.0.2) - unicode-display_width (>= 1.1.1, < 3) - test-unit (3.6.7) + terminal-table (4.0.0) + unicode-display_width (>= 1.1.1, < 4) + test-unit (3.6.8) power_assert timeout (0.4.3) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.6.0) + unicode-display_width (3.1.4) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) uri (1.0.3) zlib (3.2.1) @@ -179,7 +185,7 @@ DEPENDENCIES digest fileutils goodcheck - json + json (~> 2.10.2) json-schema memory_profiler minitest @@ -194,7 +200,7 @@ DEPENDENCIES rake-compiler rbs! rbs-amber! - rdoc + rdoc (~> 6.11.0) rspec rubocop rubocop-on-rbs diff --git a/Rakefile b/Rakefile index 77e9d6521..59f4b4bb7 100644 --- a/Rakefile +++ b/Rakefile @@ -22,10 +22,14 @@ end Rake::TestTask.new(test: :compile, &test_config) unless Gem.win_platform? - require "ruby_memcheck" + begin + require "ruby_memcheck" - namespace :test do - RubyMemcheck::TestTask.new(valgrind: :compile, &test_config) + namespace :test do + RubyMemcheck::TestTask.new(valgrind: :compile, &test_config) + end + rescue LoadError => exn + STDERR.puts "🚨🚨🚨🚨 Skipping RubyMemcheck: #{exn.inspect} 🚨🚨🚨🚨" end end diff --git a/core/string.rbs b/core/string.rbs index ffc70b85c..b28e1bb59 100644 --- a/core/string.rbs +++ b/core/string.rbs @@ -3580,4 +3580,15 @@ interface _ArefFromStringToString end %a{deprecated} -type String::encode_fallback = Hash[String, String] | Proc | Method | _ArefFromStringToString +type String::encode_fallback = Hash[String, String] | Proc | Method | String::_ArefFromStringToString + +# Don't use this interface directly +# +# This is a copy of `::_ArefFromStringToString` but without deprecated attribute. +# This is a workaround to avoid deprecation warnings in `String::encode_fallback` type. +# +# This type will be deprecated soon once `::_ArefFromStringToString` and `String::encode_fallback` are removed. +# +interface String::_ArefFromStringToString + def []: (String) -> String +end diff --git a/ext/rbs_extension/main.c b/ext/rbs_extension/main.c index 227ea3b5b..d0b4a3619 100644 --- a/ext/rbs_extension/main.c +++ b/ext/rbs_extension/main.c @@ -18,14 +18,15 @@ Init_rbs_extension(void) rbs__init_location(); rbs__init_parser(); - // Calculated based on the number of unique strings used with the `INTERN` macro in `parser.c`. - // - // ```bash - // grep -o 'INTERN("\([^"]*\)")' ext/rbs_extension/parser.c \ - // | sed 's/INTERN("\(.*\)")/\1/' \ - // | sort -u \ - // | wc -l - // ``` + /* Calculated based on the number of unique strings used with the `INTERN` macro in `parser.c`. + * + * ```bash + * grep -o 'INTERN("\([^"]*\)")' ext/rbs_extension/parser.c \ + * | sed 's/INTERN("\(.*\)")/\1/' \ + * | sort -u \ + * | wc -l + * ``` + */ const size_t num_uniquely_interned_strings = 26; rbs_constant_pool_init(RBS_GLOBAL_CONSTANT_POOL, num_uniquely_interned_strings); diff --git a/ext/rbs_extension/parserstate.c b/ext/rbs_extension/parserstate.c index 98e5773fc..d252eb54b 100644 --- a/ext/rbs_extension/parserstate.c +++ b/ext/rbs_extension/parserstate.c @@ -334,7 +334,7 @@ parserstate *alloc_parser(VALUE buffer, lexstate *lexer, int start_pos, int end_ .vars = NULL, .last_comment = NULL, - .constant_pool = {}, + .constant_pool = { 0 }, }; // The parser's constant pool is mainly used for storing the names of type variables, which usually aren't many. diff --git a/lib/rbs/collection.rb b/lib/rbs/collection.rb index f1a76bc39..1e00aeef5 100644 --- a/lib/rbs/collection.rb +++ b/lib/rbs/collection.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'yaml' +require 'fileutils' require_relative './cli/colored_io' require_relative './collection/sources' diff --git a/lib/rbs/version.rb b/lib/rbs/version.rb index 1b6c4459a..322a4e39a 100644 --- a/lib/rbs/version.rb +++ b/lib/rbs/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module RBS - VERSION = "3.9.0" + VERSION = "3.9.5" end diff --git a/src/util/rbs_constant_pool.c b/src/util/rbs_constant_pool.c index 406c36464..96f9246f3 100644 --- a/src/util/rbs_constant_pool.c +++ b/src/util/rbs_constant_pool.c @@ -169,7 +169,7 @@ rbs_constant_pool_resize(rbs_constant_pool_t *pool) { } // This storage is initialized by `Init_rbs_extension()` in `main.c`. -static rbs_constant_pool_t RBS_GLOBAL_CONSTANT_POOL_STORAGE = {}; +static rbs_constant_pool_t RBS_GLOBAL_CONSTANT_POOL_STORAGE = { 0 }; rbs_constant_pool_t *RBS_GLOBAL_CONSTANT_POOL = &RBS_GLOBAL_CONSTANT_POOL_STORAGE; /** diff --git a/steep/Gemfile.lock b/steep/Gemfile.lock index ee0fcae8a..4ca31fc47 100644 --- a/steep/Gemfile.lock +++ b/steep/Gemfile.lock @@ -14,27 +14,27 @@ GEM securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) uri (>= 0.13.1) - ast (2.4.2) + ast (2.4.3) base64 (0.2.0) benchmark (0.4.0) bigdecimal (3.1.9) concurrent-ruby (1.3.5) - connection_pool (2.5.0) - csv (3.3.2) + connection_pool (2.5.3) + csv (3.3.4) drb (2.2.1) - ffi (1.17.1) + ffi (1.17.2) fileutils (1.7.3) i18n (1.14.7) concurrent-ruby (~> 1.0) - json (2.10.2) + json (2.11.3) language_server-protocol (3.17.0.4) listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - logger (1.6.6) + logger (1.7.0) minitest (5.25.5) mutex_m (0.3.0) - parser (3.3.7.1) + parser (3.3.8.0) ast (~> 2.4.1) racc racc (1.8.1) @@ -42,10 +42,10 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) - rbs (3.9.0.pre.2) + rbs (3.9.2) logger securerandom (0.4.1) - steep (1.10.0.pre.3) + steep (1.10.0) activesupport (>= 5.1) concurrent-ruby (>= 1.1.10) csv (>= 3.0.9) @@ -57,12 +57,12 @@ GEM mutex_m (>= 0.3.0) parser (>= 3.1) rainbow (>= 2.2.2, < 4.0) - rbs (~> 3.9.pre) + rbs (~> 3.9) securerandom (>= 0.1) strscan (>= 1.0.0) terminal-table (>= 2, < 5) uri (>= 0.12.0) - strscan (3.1.2) + strscan (3.1.5) terminal-table (4.0.0) unicode-display_width (>= 1.1.1, < 4) tzinfo (2.0.6) diff --git a/test/stdlib/CGI_test.rb b/test/stdlib/CGI_test.rb index ddcfefc7b..c88b05b2c 100644 --- a/test/stdlib/CGI_test.rb +++ b/test/stdlib/CGI_test.rb @@ -68,6 +68,7 @@ class CGITest < Test::Unit::TestCase testing "::CGI" def setup + super ARGV.replace(%w(abc=001 def=002)) end diff --git a/test/stdlib/Forwardable_test.rb b/test/stdlib/Forwardable_test.rb index 755e8c843..e92e1f1e6 100644 --- a/test/stdlib/Forwardable_test.rb +++ b/test/stdlib/Forwardable_test.rb @@ -71,6 +71,7 @@ class SingleForwardableTest < Test::Unit::TestCase testing "::SingleForwardable" def setup + super @tested = Object.new @tested.extend SingleForwardable end diff --git a/test/stdlib/Minitest_test.rb b/test/stdlib/Minitest_test.rb index 34c2fc6c4..f8c1cb511 100644 --- a/test/stdlib/Minitest_test.rb +++ b/test/stdlib/Minitest_test.rb @@ -51,9 +51,10 @@ class MinitestTestLifecycleHooksTest < Test::Unit::TestCase class LifecycleSetup < Minitest::Test def setup + super @foo = 123 end - end + end def test_setup_return_type_void test = LifecycleSetup.new("setup") diff --git a/test/stdlib/Ractor_test.rb b/test/stdlib/Ractor_test.rb index 9ed177c17..f2d0897db 100644 --- a/test/stdlib/Ractor_test.rb +++ b/test/stdlib/Ractor_test.rb @@ -132,6 +132,8 @@ class RactorInstanceTest < Test::Unit::TestCase testing "::Ractor" def test_aref + omit "Accessing ractor local storage" if RUBY_VERSION >= "3.5" + r = Ractor.new {} r['foo'] = 'bar' assert_send_type "(String) -> untyped", @@ -141,6 +143,8 @@ def test_aref end def test_aset + omit "Accessing ractor local storage" if RUBY_VERSION >= "3.5" + r = Ractor.new {} assert_send_type "(String, String) -> String", r, :[]=, 'foo', 'bar' diff --git a/test/stdlib/global_variables_test.rb b/test/stdlib/global_variables_test.rb index 4b06824e4..da06ec531 100644 --- a/test/stdlib/global_variables_test.rb +++ b/test/stdlib/global_variables_test.rb @@ -262,7 +262,7 @@ def test_gvar_LOAD_PATH(gvar: :$LOAD_PATH) # is a singleton method), we can't use `assert_send_type` and must use `assert_type`. loadpath = eval(gvar.to_s) - with_path 'set' do |path| + with_path 'erb' do |path| assert_type '[:rb | :so, String]', loadpath.resolve_feature_path(path) end diff --git a/test/stdlib/uri/rfc2396_parser_test.rb b/test/stdlib/uri/rfc2396_parser_test.rb index 3e6f35a05..215eecd34 100644 --- a/test/stdlib/uri/rfc2396_parser_test.rb +++ b/test/stdlib/uri/rfc2396_parser_test.rb @@ -20,6 +20,7 @@ class URIRFC2396_ParserInstanceTest < Test::Unit::TestCase testing "::URI::RFC2396_Parser" def setup + super @instance = URI::RFC2396_Parser.new end diff --git a/test/test_skip.rb b/test/test_skip.rb index 2fbd7b92f..5fa96b562 100644 --- a/test/test_skip.rb +++ b/test/test_skip.rb @@ -15,15 +15,11 @@ # ``` # module TestSkip - env = ENV["RBS_SKIP_TESTS"] - SKIP_TESTS_FILE = - if env - Pathname(env) - end + SKIP_TESTS_FILES = ENV["RBS_SKIP_TESTS"]&.split(File::PATH_SEPARATOR) SKIP_TESTS = - if SKIP_TESTS_FILE - SKIP_TESTS_FILE.each_line.with_object({}) do |line, hash| + SKIP_TESTS_FILES&.each_with_object({}) do |file, hash| + File.foreach(file) do |line| line.chomp! line.gsub!(/#.*/, "") line.strip! @@ -32,7 +28,7 @@ module TestSkip name, message = line.split(/\s+/, 2) - hash[name] = message + hash[name] = [file, message] end end @@ -40,11 +36,12 @@ module TestSkip def setup super - if SKIP_TESTS.key?(name) || SKIP_TESTS.key?(self.class.name) - if message = SKIP_TESTS[name] || SKIP_TESTS[self.class.name] - omit "Skip test by RBS_SKIP_TESTS(#{SKIP_TESTS_FILE}): #{message}" + file, message = SKIP_TESTS[name] || SKIP_TESTS[self.class.name] + if file + if message + omit "Skip test by RBS_SKIP_TESTS(#{file}): #{message}" else - omit "Skip test by RBS_SKIP_TESTS(#{SKIP_TESTS_FILE})" + omit "Skip test by RBS_SKIP_TESTS(#{file})" end end end @@ -54,7 +51,7 @@ def teardown when passed? # nop else - puts "💡You can skip this test `#{name}` by adding the name to `#{SKIP_TESTS_FILE}`" + puts "💡You can skip this test `#{name}` by adding the name to `#{SKIP_TESTS_FILES.join('`, `')}`" end super