merge revision(s) d7a6ff8224519005d2deeb3f4e98689a8a0835ad: [Backport #21819]

[Bug #21819] Data objects without members should also be frozen
This commit is contained in:
Hiroshi SHIBATA 2026-03-24 14:27:16 +09:00
parent 930edc12d7
commit 3cd6323fbb
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2
3 changed files with 3 additions and 1 deletions

View File

@ -1785,6 +1785,7 @@ rb_data_initialize_m(int argc, const VALUE *argv, VALUE self)
if (num_members > 0) {
rb_exc_raise(rb_keyword_error_new("missing", members));
}
OBJ_FREEZE(self);
return Qnil;
}
if (argc > 1 || !RB_TYPE_P(argv[0], T_HASH)) {

View File

@ -262,6 +262,7 @@ class TestData < Test::Unit::TestCase
assert_equal('#<data >', test.inspect)
assert_equal([], test.members)
assert_equal({}, test.to_h)
assert_predicate(test, :frozen?)
end
def test_dup

View File

@ -11,7 +11,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 10
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
#define RUBY_PATCHLEVEL 202
#define RUBY_PATCHLEVEL 203
#include "ruby/version.h"
#include "ruby/internal/abi.h"