Skip to content

Commit fd486f7

Browse files
gldubcsabiwara
andauthored
Sort map_union to preserve invariant
Co-authored-by: Jean Klingler <[email protected]>
1 parent 8664e7f commit fd486f7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/elixir/lib/module/types/descr.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2494,7 +2494,11 @@ defmodule Module.Types.Descr do
24942494
def map_union(map_literal(tag1, fields1), map_literal(tag2, fields2)) do
24952495
case maybe_optimize_map_union({tag1, fields1, []}, {tag2, fields2, []}) do
24962496
{tag, fields, []} -> map_literal(tag, fields)
2497-
nil -> {{tag1, fields1}, :bdd_top, {{tag2, fields2}, :bdd_top, :bdd_bot}}
2497+
nil ->
2498+
case {{tag1, fields1}, {tag2, fields2}} do
2499+
{r, l} when l < r -> {l, :bdd_top, {r, :bdd_top, :bdd_bot}}
2500+
{l, r} -> {l, :bdd_top, {r, :bdd_top, :bdd_bot}}
2501+
end
24982502
end
24992503
end
25002504

0 commit comments

Comments
 (0)