Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not consider envs from no_return clauses
Summary: When elaborating an expression with multiple clauses, we generate one refined environment per clause and use them to elaborate the clauses. We then join **all** resulting types **and** environments to produce the result of the elaboration. However, if a clause throws/exit/doesn't return, then its resulting environment can be ignored as it will never appear in the remainder of the code. Consider this example which currently errors: ``` -spec foo(L :: list() | map()) -> term(). case is_list(L) of true -> ok; false -> error(not_list) end, lists:nth(1, L). % error: L has type list() | map() ``` In clause `true -> ok` we have `L :: list()`, and in the other clause `L :: map()`. Since the second clause doesn't return, its environment can be ignored, making the `case` expression return the environment `L :: list()`, and making the example accepted. This diff achieves it by marking all types in the environment as being empty. Reviewed By: ilya-klyuchnikov Differential Revision: D68410835 fbshipit-source-id: 8bdd26e949673f0d915620738a50bb888a90dcd3
- Loading branch information