Skip to content

Commit afac86e

Browse files
Wilfredfacebook-github-bot
authored andcommitted
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
1 parent 68b0b52 commit afac86e

File tree

104 files changed

+258
-258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+258
-258
lines changed

hphp/hack/src/typing/typing_print.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ module Full = struct
653653
if ISet.mem n' st then
654654
text "[rec]"
655655
else if !blank_tyvars then
656-
text "[unresolved]"
656+
text "_"
657657
else
658658
text ("#" ^ string_of_int n')
659659
in
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
File "yield_deeper.php", line 20, characters 3-45:
22
`await` can only operate on an `Awaitable` (Typing[4110])
33
File "yield_deeper.php", line 20, characters 3-45:
4-
Expected `Awaitable<[unresolved]>`
4+
Expected `Awaitable<_>`
55
File "yield_deeper.php", line 20, characters 9-45:
66
But got `AsyncGenerator<null, int, mixed>` (result of `async function` containing a `yield`)

hphp/hack/test/error_formatting_highlighted/position_within_position.php.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Typing[4110] await can only operate on an Awaitable [1]
2-
-> Expected Awaitable<[unresolved]> [1]
2+
-> Expected Awaitable<_> [1]
33
-> But got int [2]
44

55
position_within_position.php:4:3

hphp/hack/test/sound_dynamic/typing/generic_constraint_dynamic.bad.php.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Some type arguments violate their constraints (Typing[4323])
1313
File "generic_constraint_dynamic.bad.php", line 21, characters 14-20:
1414
Invalid argument (Typing[4110])
1515
File "generic_constraint_dynamic.bad.php", line 21, characters 12-12:
16-
Expected `~[unresolved]` because type parameter `T` of `C` could not be determined. Please add explicit type parameters to the invocation of `C`
16+
Expected `~_` because type parameter `T` of `C` could not be determined. Please add explicit type parameters to the invocation of `C`
1717
File "generic_constraint_dynamic.bad.php", line 6, characters 39-39:
1818
via this generic `T`
1919
File "generic_constraint_dynamic.bad.php", line 21, characters 18-18:

hphp/hack/test/sound_dynamic/typing/sound_dynamic_callable_1.bad.php.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Method `foo` in class `C` is not dynamically callable. (Typing[4110])
55
File "sound_dynamic_callable_1.bad.php", line 11, characters 27-34:
66
Expected `dynamic` because method must be callable in a dynamic context
77
File "sound_dynamic_callable_1.bad.php", line 12, characters 16-18:
8-
Type `Box<[unresolved]>` is not a subtype of `dynamic` under dynamic-aware subtyping
8+
Type `Box<_>` is not a subtype of `dynamic` under dynamic-aware subtyping

hphp/hack/test/sound_dynamic/typing/sound_dynamic_callable_1.bad.php.legacy_decl.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Method `foo` in class `C` is not dynamically callable. (Typing[4110])
55
File "sound_dynamic_callable_1.bad.php", line 11, characters 27-34:
66
Expected `dynamic` because method must be callable in a dynamic context
77
File "sound_dynamic_callable_1.bad.php", line 12, characters 16-18:
8-
Type `Box<[unresolved]>` is not a subtype of `dynamic` under dynamic-aware subtyping
8+
Type `Box<_>` is not a subtype of `dynamic` under dynamic-aware subtyping

hphp/hack/test/sound_dynamic/typing/sound_dynamic_callable_2.bad.php.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Method `foo` in class `C` is not dynamically callable. (Typing[4110])
55
File "sound_dynamic_callable_2.bad.php", line 10, characters 27-34:
66
Expected `dynamic` because method must be callable in a dynamic context
77
File "sound_dynamic_callable_2.bad.php", line 11, characters 16-18:
8-
Type `Box<[unresolved]>` is not a subtype of `dynamic` under dynamic-aware subtyping
8+
Type `Box<_>` is not a subtype of `dynamic` under dynamic-aware subtyping

hphp/hack/test/sound_dynamic/typing/sound_dynamic_callable_2.bad.php.legacy_decl.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Method `foo` in class `C` is not dynamically callable. (Typing[4110])
55
File "sound_dynamic_callable_2.bad.php", line 10, characters 27-34:
66
Expected `dynamic` because method must be callable in a dynamic context
77
File "sound_dynamic_callable_2.bad.php", line 11, characters 16-18:
8-
Type `Box<[unresolved]>` is not a subtype of `dynamic` under dynamic-aware subtyping
8+
Type `Box<_>` is not a subtype of `dynamic` under dynamic-aware subtyping

hphp/hack/test/sound_dynamic/typing/supportdyn.bad.php.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Invalid `foreach` (Typing[4110])
5555
File "supportdyn.bad.php", line 21, characters 3-11:
5656
`await` can only operate on an `Awaitable` (Typing[4110])
5757
File "supportdyn.bad.php", line 21, characters 3-11:
58-
Expected `Awaitable<[unresolved]>`
58+
Expected `Awaitable<_>`
5959
File "supportdyn.bad.php", line 18, characters 32-38:
6060
But got `nonnull`
6161
File "supportdynamic.hhi", line 6, characters 29-29:

hphp/hack/test/sound_dynamic/typing/supportdynamic.bad.php.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Invalid `foreach` (Typing[4110])
5555
File "supportdynamic.bad.php", line 18, characters 3-11:
5656
`await` can only operate on an `Awaitable` (Typing[4110])
5757
File "supportdynamic.bad.php", line 18, characters 3-11:
58-
Expected `Awaitable<[unresolved]>`
58+
Expected `Awaitable<_>`
5959
File "supportdynamic.bad.php", line 15, characters 32-38:
6060
But got `nonnull`
6161
File "supportdynamic.hhi", line 6, characters 29-29:

0 commit comments

Comments
 (0)