Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compare function for identifiers and names. #926

Merged
merged 1 commit into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/base/Identifier.ml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ module GlobalName = struct
will be different from the error string where the name is used *)
let equal ((an, _) : t) ((bn, _) : t) : bool = [%equal: t_name] an bn

let compare ((an, _) : t) ((bn, _) : t) : int = [%compare : t_name] an bn

let as_string = function
| SimpleGlobal n, _ -> n
| QualifiedGlobal (ns, n), _ -> flatten_name ns n
Expand Down
4 changes: 1 addition & 3 deletions src/base/Recursion.ml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ module ScillaRecursion (SR : Rep) (ER : Rep) = struct
| Address fts -> (
match
List.find_a_dup fts ~compare:(fun (f1, _) (f2, _) ->
Bytes.compare
(Bytes.of_string (as_string f1))
(Bytes.of_string (as_string f2)))
RecIdentifier.compare f1 f2)
with
| Some (dup_field, _) ->
fail1
Expand Down
4 changes: 1 addition & 3 deletions src/base/TypeUtil.ml
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ functor
| Address fts ->
match List.find_a_dup fts
~compare:(fun (f1, _) (f2, _) ->
Bytes.compare
(Bytes.of_string (as_string f1))
(Bytes.of_string (as_string f2))) with
TIdentifier.compare f1 f2) with
| Some (dup_f, _) ->
(* No duplicate fields allowed *)
fail1
Expand Down