mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 20:44:20 +00:00
[Bug #21819] Data objects without members should also be frozen
This commit is contained in:
parent
a8a989b6f6
commit
d7a6ff8224
Notes:
git
2026-01-03 06:45:26 +00:00
1
struct.c
1
struct.c
@ -1809,6 +1809,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)) {
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user