File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed
src/main/ruby/truffleruby/core Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ Bug fixes:
55
55
* Made ` Kernel#caller_locations ` accept a range argument, and return ` nil ` when appropriate.
56
56
* Made ` rb_respond_to ` work with primitives (#1869 , @chrisseaton ).
57
57
* Fixed issue with missing backtrace for ` rescue $ERROR_INFO ` (#1660 ).
58
+ * Fixed ` Struct#hash ` for ` keyword_init: true ` ` Struct ` .
58
59
59
60
Compatibility:
60
61
Original file line number Diff line number Diff line change 19
19
car . hash . should == similar_car . hash
20
20
end
21
21
22
+ it "returns different hashes for structs with different values" do
23
+ s1 = StructClasses ::Ruby . new ( '2.7.0' , 'linux' )
24
+ s2 = StructClasses ::Ruby . new ( '2.7.0' , 'macos' )
25
+ s1 . hash . should_not == s2 . hash
26
+ end
27
+
28
+ it "returns different hashes for structs with different values when using keyword_init: true" do
29
+ key = :"1 non symbol member"
30
+ struct_class = Struct . new ( key , keyword_init : true )
31
+ t1 = struct_class . new ( key => 1 )
32
+ t2 = struct_class . new ( key => 2 )
33
+ t1 . hash . should_not == t2 . hash
34
+ end
35
+
22
36
it "allows for overriding methods in an included module" do
23
37
mod = Module . new do
24
38
def hash
Original file line number Diff line number Diff line change @@ -309,7 +309,9 @@ def hash
309
309
val = TrufflePrimitive . vm_hash_start ( CLASS_SALT )
310
310
val = TrufflePrimitive . vm_hash_update ( val , size )
311
311
return val if Thread . detect_outermost_recursion self do
312
- _attrs . each { |var | TrufflePrimitive . vm_hash_update ( val , TrufflePrimitive . object_hidden_var_get ( self , var ) . hash ) }
312
+ _attrs . each do |var |
313
+ val = TrufflePrimitive . vm_hash_update ( val , TrufflePrimitive . object_hidden_var_get ( self , var ) . hash )
314
+ end
313
315
end
314
316
TrufflePrimitive . vm_hash_end ( val )
315
317
end
You can’t perform that action at this time.
0 commit comments