File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -786,6 +786,7 @@ VALUE
786
786
rb_struct_initialize (VALUE self , VALUE values )
787
787
{
788
788
rb_struct_initialize_m (RARRAY_LENINT (values ), RARRAY_CONST_PTR (values ), self );
789
+ if (rb_obj_is_kind_of (self , rb_cData )) OBJ_FREEZE_RAW (self );
789
790
RB_GC_GUARD (values );
790
791
return Qnil ;
791
792
}
Original file line number Diff line number Diff line change @@ -177,4 +177,14 @@ def test_dup
177
177
assert_equal ( klass . new ( foo : 1 , bar : 2 ) , test . dup )
178
178
assert_predicate ( test . dup , :frozen? )
179
179
end
180
+
181
+ Klass = Data . define ( :foo , :bar )
182
+
183
+ def test_marshal
184
+ test = Klass . new ( foo : 1 , bar : 2 )
185
+ loaded = Marshal . load ( Marshal . dump ( test ) )
186
+ assert_equal ( test , loaded )
187
+ assert_not_same ( test , loaded )
188
+ assert_predicate ( loaded , :frozen? )
189
+ end
180
190
end
You can’t perform that action at this time.
0 commit comments