diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2026-01-12 17:13:00 -0800 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2026-01-12 17:13:00 -0800 |
| commit | 6273c59a6e1f8587e549d5a5f44fd9363e6eb018 (patch) | |
| tree | d54e6c9dbd300f2ac0ac65882abff4c1a9a70200 | |
| parent | 3601b6c2c1226482a001b98863fe6f79cd84ad35 (diff) | |
merge revision(s) d7a6ff8224519005d2deeb3f4e98689a8a0835ad: [Backport #21819]
[PATCH] [Bug #21819] Data objects without members should also be frozen
| -rw-r--r-- | struct.c | 1 | ||||
| -rw-r--r-- | test/ruby/test_data.rb | 1 |
2 files changed, 2 insertions, 0 deletions
@@ -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)) { diff --git a/test/ruby/test_data.rb b/test/ruby/test_data.rb index dd698fdcc4..5ac4c6b84b 100644 --- a/test/ruby/test_data.rb +++ b/test/ruby/test_data.rb @@ -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 |
