Skip to content

Commit 6273c59

Browse files
committed
merge revision(s) d7a6ff8: [Backport #21819]
[PATCH] [Bug #21819] Data objects without members should also be frozen
1 parent 3601b6c commit 6273c59

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

struct.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,6 +1809,7 @@ rb_data_initialize_m(int argc, const VALUE *argv, VALUE self)
18091809
if (num_members > 0) {
18101810
rb_exc_raise(rb_keyword_error_new("missing", members));
18111811
}
1812+
OBJ_FREEZE(self);
18121813
return Qnil;
18131814
}
18141815
if (argc > 1 || !RB_TYPE_P(argv[0], T_HASH)) {

test/ruby/test_data.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ def test_memberless
262262
assert_equal('#<data >', test.inspect)
263263
assert_equal([], test.members)
264264
assert_equal({}, test.to_h)
265+
assert_predicate(test, :frozen?)
265266
end
266267

267268
def test_dup

0 commit comments

Comments
 (0)