Skip to content

Commit

Permalink
Make record type #to_s deterministic
Browse files Browse the repository at this point in the history
  • Loading branch information
soutaro committed Aug 26, 2020
1 parent 15b1df9 commit e2adab5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/steep/ast/types/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ def subst(s)
end

def to_s
"{ #{elements.map {|key, value| "#{key.inspect} => #{value}" }.join(", ")} }"
strings = elements.keys.sort.map do |key|
"#{key.inspect} => #{elements[key]}"
end
"{ #{strings.join(", ")} }"
end

def free_variables()
Expand Down
2 changes: 1 addition & 1 deletion smoke/hash/d.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

params = { id: 30, name: "Matz" }

# !expects IncompatibleAssignment: lhs_type={ :name => ::String, :id => ::Integer }, rhs_type={ :id => ::String, :name => ::String, :email => ::String }
# !expects IncompatibleAssignment: lhs_type={ :id => ::Integer, :name => ::String }, rhs_type={ :email => ::String, :id => ::String, :name => ::String }
params = { id: "30", name: "foo", email: "[email protected]" }

0 comments on commit e2adab5

Please sign in to comment.