Skip to content

Commit 5743f65

Browse files
Mistral Contrastinfacebook-github-bot
Mistral Contrastin
authored andcommitted
Fix like nullable type treatment in the emitter
Summary: When like type support was implemented, we didn't correctly mark like types as not being "simple" types. This led to nullable part of the type being swallowed. This diff fixes that by adding an arm and also gets rid of the catch all arm of the match expression so that this doesn't happen again in the future. Reviewed By: mdko Differential Revision: D63980235 fbshipit-source-id: 54b5ab697452a1e761340380a054b93cc93a4e09
1 parent 2e34418 commit 5743f65

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

hphp/hack/src/hackc/emitter/emit_type_hint.rs

+21-2
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,14 @@ fn param_hint_to_type_info(
364364
) -> Result<TypeInfo> {
365365
let Hint(_, h) = hint;
366366
let is_simple_hint = match h.as_ref() {
367-
Hsoft(_) | Hoption(_) | Haccess(_, _) | Hfun(_) | Hdynamic | Hnonnull | Hmixed => false,
367+
Hlike(_)
368+
| Hsoft(_)
369+
| Hoption(_)
370+
| Haccess(_, _)
371+
| Hfun(_)
372+
| Hdynamic
373+
| Hnonnull
374+
| Hmixed => false,
368375
Happly(Id(_, s), hs) => {
369376
hs.is_empty()
370377
&& s != "\\HH\\dynamic"
@@ -373,7 +380,19 @@ fn param_hint_to_type_info(
373380
&& !tparams.contains(&s.as_str())
374381
}
375382
Habstr(s, hs) => hs.is_empty() && !tparams.contains(&s.as_str()),
376-
_ => true,
383+
Hprim(_)
384+
| Htuple(_)
385+
| HclassArgs(_)
386+
| Hshape(_)
387+
| Hrefinement(_, _)
388+
| Hwildcard
389+
| HvecOrDict(_, _)
390+
| Hthis
391+
| Hnothing
392+
| Hunion(_)
393+
| Hintersection(_)
394+
| HfunContext(_)
395+
| Hvar(_) => true,
377396
};
378397
let tc = hint_to_type_constraint(kind, tparams, skipawaitable, hint)?;
379398
make_type_info(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
NULL

hphp/test/slow/like_types/like_nullable.php.expectf

-2
This file was deleted.

0 commit comments

Comments
 (0)