Print unresolved types as _
commitafac86e51e7726b8d0c00baac8d105f62d86a81e
authorWilfred Hughes <wilfred@fb.com>
Mon, 29 Aug 2022 18:47:38 +0000 (29 11:47 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Mon, 29 Aug 2022 18:47:38 +0000 (29 11:47 -0700)
tree2b979dd0b0208d1a7b0353f92d085a8e9bdba291
parent68b0b52bf4518e7bc919e6e8f7befa8c1e4bbe89
Print unresolved types as _

Summary:
If we can't resolve a type variable, display it as "_" rather than "[unresolved]". This makes type errors easier to read.

For example, if a user writes `await 1` we used to show:

```
-> Expected Awaitable<[unresolved]>
-> But got int
```

The problem isn't that we couldn't find an inner type for `Awaitable`. The problem is that `1` isn't an awaitable value at all! We now show this:

```
-> Expected Awaitable<_>
-> But got int
```

This is much easier to read, especially in larger types. It's also consistent with `Terr`.

Reviewed By: hgoldstein

Differential Revision: D39067882

fbshipit-source-id: 0e758cf36fe9c73f3b6347d7f53572fabeadeca3
104 files changed:
hphp/hack/src/typing/typing_print.ml
hphp/hack/test/decl/yield_deeper.php.typecheck.exp
hphp/hack/test/error_formatting_highlighted/position_within_position.php.exp
hphp/hack/test/sound_dynamic/typing/generic_constraint_dynamic.bad.php.exp
hphp/hack/test/sound_dynamic/typing/sound_dynamic_callable_1.bad.php.exp
hphp/hack/test/sound_dynamic/typing/sound_dynamic_callable_1.bad.php.legacy_decl.exp
hphp/hack/test/sound_dynamic/typing/sound_dynamic_callable_2.bad.php.exp
hphp/hack/test/sound_dynamic/typing/sound_dynamic_callable_2.bad.php.legacy_decl.exp
hphp/hack/test/sound_dynamic/typing/supportdyn.bad.php.exp
hphp/hack/test/sound_dynamic/typing/supportdynamic.bad.php.exp
hphp/hack/test/typecheck/akempty/akempty_promotion_4.php.exp
hphp/hack/test/typecheck/anon13.php.pess_exp
hphp/hack/test/typecheck/anyarray_bad.php.exp
hphp/hack/test/typecheck/argument_unpacking/unpack_call1.php.exp
hphp/hack/test/typecheck/argument_unpacking/unpack_call3.php.exp
hphp/hack/test/typecheck/argument_unpacking/unpack_call6.php.exp
hphp/hack/test/typecheck/argument_unpacking/unpack_call_mixed.php.exp
hphp/hack/test/typecheck/arithmetic_any.php.exp
hphp/hack/test/typecheck/array/safe_vector_array/disallows_array_of_int_when_array_of_tk_to_tv_is_required.php.exp
hphp/hack/test/typecheck/array_append_set_bad.php.exp
hphp/hack/test/typecheck/array_sub.php.exp
hphp/hack/test/typecheck/array_sub2.php.exp
hphp/hack/test/typecheck/assign_unresolved_obj_get.php.tast_typecheck_exp
hphp/hack/test/typecheck/await_as_an_expression/error/await_as_an_expression_awaiting_non_awaitable.php.exp
hphp/hack/test/typecheck/await_on_illegal_value.php.exp
hphp/hack/test/typecheck/await_precedence/strong_precedence/await_new_precedence.php.exp
hphp/hack/test/typecheck/await_precedence/weak_precedence/await_old_precedence.php.exp
hphp/hack/test/typecheck/concurrent/error/concurrent_non_awaitable.php.exp
hphp/hack/test/typecheck/continuation_is_not_awaitable2.php.exp
hphp/hack/test/typecheck/control_flow/lambda.php.exp
hphp/hack/test/typecheck/dynamic/collections.php.exp
hphp/hack/test/typecheck/dynamic/foreach_union.php.exp
hphp/hack/test/typecheck/enum_class_label/xcont.php.pess_exp
hphp/hack/test/typecheck/erling_loop2.php.exp
hphp/hack/test/typecheck/explicit_type_collection/explicit_type_collection_wildcard_map1.php.exp
hphp/hack/test/typecheck/explicit_type_collection/explicit_type_collection_wildcard_map2.php.exp
hphp/hack/test/typecheck/explicit_type_collection/explicit_type_collection_wildcard_map3.php.exp
hphp/hack/test/typecheck/expression_trees/dict_error.php.exp
hphp/hack/test/typecheck/expression_trees/nested_splicing.php.exp
hphp/hack/test/typecheck/expression_trees/nested_splicing2.php.exp
hphp/hack/test/typecheck/expression_trees/pipe2.php.exp
hphp/hack/test/typecheck/expression_trees/pipe5.php.exp
hphp/hack/test/typecheck/expression_trees/splice_err1.php.exp [copied from hphp/hack/test/typecheck/expression_trees_not_virtualize_functions/splice_err1.php.exp with 68% similarity]
hphp/hack/test/typecheck/expression_trees/splice_err4.php.exp
hphp/hack/test/typecheck/expression_trees_not_virtualize_functions/dict_error.php.exp
hphp/hack/test/typecheck/expression_trees_not_virtualize_functions/nested_splicing.php.exp
hphp/hack/test/typecheck/expression_trees_not_virtualize_functions/nested_splicing2.php.exp
hphp/hack/test/typecheck/expression_trees_not_virtualize_functions/pipe2.php.exp
hphp/hack/test/typecheck/expression_trees_not_virtualize_functions/pipe5.php.exp
hphp/hack/test/typecheck/expression_trees_not_virtualize_functions/splice_err1.php.exp
hphp/hack/test/typecheck/expression_trees_not_virtualize_functions/splice_err4.php.exp [copied from hphp/hack/test/typecheck/expression_trees/splice_err4.php.exp with 68% similarity]
hphp/hack/test/typecheck/ffp/function_async_lambda_bad.php.exp
hphp/hack/test/typecheck/ffp/throw_yield.php.exp
hphp/hack/test/typecheck/ffp/yield_bad1.php.exp
hphp/hack/test/typecheck/ffp/yield_bad2.php.exp
hphp/hack/test/typecheck/functional_generator.php.exp
hphp/hack/test/typecheck/gen6.php.exp
hphp/hack/test/typecheck/hh_fixme_bug3.php.pess_exp
hphp/hack/test/typecheck/hhfixme_bug2.php.pess_exp
hphp/hack/test/typecheck/hhfixme_bug2.php.tgt_pess_exp
hphp/hack/test/typecheck/idx2_4.php.exp
hphp/hack/test/typecheck/idx3_5.php.exp
hphp/hack/test/typecheck/invalid_arraykey/invalid_arraykey.php.exp
hphp/hack/test/typecheck/keys.php.exp
hphp/hack/test/typecheck/lambda/async_lambda2.php.exp
hphp/hack/test/typecheck/lambda/variadics/lambda_unpacked_parameters.php.exp
hphp/hack/test/typecheck/list_generic_assign.php.exp
hphp/hack/test/typecheck/method_call_inference/expect_awaitable_in_await.php.exp
hphp/hack/test/typecheck/namespace_collections3.php.exp
hphp/hack/test/typecheck/new_inference/async_lambda.php.exp
hphp/hack/test/typecheck/new_inference/eager_solve/array_append_bad.php.exp
hphp/hack/test/typecheck/new_inference/eager_solve/function_apply_hard.php.tast_typecheck_exp
hphp/hack/test/typecheck/new_inference/eager_solve/nullable_array_append_hard.php.tast_typecheck_exp
hphp/hack/test/typecheck/new_inference/instance_of_refinement.php.exp
hphp/hack/test/typecheck/new_inference/oldtypehole/t21684610.php.exp
hphp/hack/test/typecheck/new_inference/typehole/t21684610.php.exp
hphp/hack/test/typecheck/new_inference/untypeable/closure.php.tast_typecheck_exp
hphp/hack/test/typecheck/nonnull/await_nonnull.php.exp
hphp/hack/test/typecheck/nonnull/option_is_not_subtype_of_nonnull1.php.exp
hphp/hack/test/typecheck/nonnull/option_is_not_subtype_of_nonnull2.php.exp
hphp/hack/test/typecheck/re_prefixed_string/re_prefixed_string.php.exp
hphp/hack/test/typecheck/recursive_non_null_4.php.exp
hphp/hack/test/typecheck/recursive_optional.php.exp
hphp/hack/test/typecheck/reified_generics/new_self_new_parent.php.exp
hphp/hack/test/typecheck/shape_idx4.php.exp
hphp/hack/test/typecheck/shapes_remove_key.php.pess_exp
hphp/hack/test/typecheck/shapes_remove_key.php.tgt_pess_exp
hphp/hack/test/typecheck/traversable_foreach3.php.exp
hphp/hack/test/typecheck/type_structure/type_structure1.php.exp
hphp/hack/test/typecheck/unify_unresolved.php.exp
hphp/hack/test/typecheck/union/generics.php.exp
hphp/hack/test/typecheck/union/map_corner_case.php.exp
hphp/hack/test/typecheck/union/map_corner_case.php.legacy_decl.exp
hphp/hack/test/typecheck/union/mixed.php.exp
hphp/hack/test/typecheck/variadic_args1.php.exp
hphp/hack/test/typecheck/yield/asyncgen11.php.exp
hphp/hack/test/typecheck/yield/asyncgen2.php.exp
hphp/hack/test/typecheck/yield/asyncgen3.php.exp
hphp/hack/test/typecheck/yield/asyncgen4.php.exp
hphp/hack/test/typecheck/yield/asyncgen5.php.exp
hphp/hack/test/typecheck/yield/asyncgen6.php.exp
hphp/hack/test/typecheck/yield/asyncgen9.php.exp
hphp/hack/test/typecheck/yield/yield_lambda_async.php.exp
hphp/hack/test/typecheck/yield_method.php.exp