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
786786rb_struct_initialize (VALUE self , VALUE values )
787787{
788788 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 );
789790 RB_GC_GUARD (values );
790791 return Qnil ;
791792}
Original file line number Diff line number Diff line change @@ -177,4 +177,14 @@ def test_dup
177177 assert_equal ( klass . new ( foo : 1 , bar : 2 ) , test . dup )
178178 assert_predicate ( test . dup , :frozen? )
179179 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
180190end
You can’t perform that action at this time.
0 commit comments