forked from facebook/flow
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix error handling for nested unions and intersections
Union and intersection errors are handled using a speculative match process, where an error on one side of the match raises an exception, which is caught by the speculative match code, which then tries the otehr side of the match. If, however, there are nested speculative matches in a given flow, the innermost one would raise an error too early. This can happen if a type alias is a union containing union types. To fix, instead of using a boolean to track whether to log the error or raise, we use an integer representing the "depth" of the speculative match. Before, there was some code to "flatten" unions of unions during the convertion of annotations to types, but this doesn't work for the case where the unions are themselves type aliases. Unfortunately, this change affects error messages around union types, and in my opinion, the new messages are worse and less helpful than they used to be. Any ideas how to make this change without making error messages worse? Fixes facebook#582
- Loading branch information
1 parent
151759d
commit ff5cc74
Showing
5 changed files
with
27 additions
and
25 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
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
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