Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avoid creating too many type variables in expand_type_and_narrow
Summary: This diff is all about using Typing_union.simplify_unions instead of get_union_elements. Why does it make things better ? Suppose you have type variables like: ``` vec<int> <: #1 <: #2 ``` Since we transitively close, we'll get a constraint graph like: ``` vec<int> <: #1 vec<int>, #1 <: #2 ``` get_union_elements was implemented in such a way that calling in on #2 would get vec<int> twice, resulting in the widened type being (vec<#3> | vec<#4). You can see how this causes a explosion of type variables for bigger, transitively closed, constraint graphs. Reviewed By: andrewjkennedy Differential Revision: D15149670 fbshipit-source-id: d74e3f0cc35de755025da087bda7606376206531
- Loading branch information
1 parent
4613cf5
commit 81a4c17
Showing
4 changed files
with
61 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?hh // strict | ||
// Copyright 2004-present Facebook. All Rights Reserved. | ||
|
||
function test2(int $id): void { | ||
$res = Map {}; | ||
$res[$id] = vec[1]; | ||
$res[$id][0] += 0; | ||
$res[$id][1] += 0; | ||
$res[$id][2] += 0; | ||
$res[$id][3] += 0; | ||
$res[$id][4] += 0; | ||
$res[$id][5] += 0; | ||
hh_force_solve(); | ||
hh_show($res); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
File "append_blow.php", line 14, characters 3-15: | ||
Map<int, vec<(int | int)>> | ||
No errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
File "append_blow.php", line 14, characters 3-15: | ||
Map<int, vec<int>> | ||
No errors |