Skip to content

Commit

Permalink
Fix like nullable type treatment in the emitter
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Mistral Contrastin authored and facebook-github-bot committed Oct 7, 2024
1 parent 2e34418 commit 5743f65
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
23 changes: 21 additions & 2 deletions hphp/hack/src/hackc/emitter/emit_type_hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,14 @@ fn param_hint_to_type_info(
) -> Result<TypeInfo> {
let Hint(_, h) = hint;
let is_simple_hint = match h.as_ref() {
Hsoft(_) | Hoption(_) | Haccess(_, _) | Hfun(_) | Hdynamic | Hnonnull | Hmixed => false,
Hlike(_)
| Hsoft(_)
| Hoption(_)
| Haccess(_, _)
| Hfun(_)
| Hdynamic
| Hnonnull
| Hmixed => false,
Happly(Id(_, s), hs) => {
hs.is_empty()
&& s != "\\HH\\dynamic"
Expand All @@ -373,7 +380,19 @@ fn param_hint_to_type_info(
&& !tparams.contains(&s.as_str())
}
Habstr(s, hs) => hs.is_empty() && !tparams.contains(&s.as_str()),
_ => true,
Hprim(_)
| Htuple(_)
| HclassArgs(_)
| Hshape(_)
| Hrefinement(_, _)
| Hwildcard
| HvecOrDict(_, _)
| Hthis
| Hnothing
| Hunion(_)
| Hintersection(_)
| HfunContext(_)
| Hvar(_) => true,
};
let tc = hint_to_type_constraint(kind, tparams, skipawaitable, hint)?;
make_type_info(
Expand Down
1 change: 1 addition & 0 deletions hphp/test/slow/like_types/like_nullable.php.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NULL
2 changes: 0 additions & 2 deletions hphp/test/slow/like_types/like_nullable.php.expectf

This file was deleted.

0 comments on commit 5743f65

Please sign in to comment.