HHVM 25.7.0
Previous release 25.6.0
Typechecker Improvements
-
Commit by mheiber: correct handling of parent:: and self
This applies to the method attribute
<<__NeedsConcrete>>
. If you mark a method
on an abstract type with this attribute, all calls to this method
must originate from a non-abstract type. This is useful when you
need to call other methods your declared as abstract on yourself.
This change makes some false positive errors go away.
-
Commit by Michael Thomas : Fix bug which disallows all wildcard
hints in poly lambda
It is now possible to use
$x is vec<_>
in a
lambda with a generic. You can write generic lambdas like so
$refl = function<T>(T $t): T { return $t; };
This is new in hhvm@next. HHVM tried to prevent you from writing
taking a parameter of type vec<_>
, since an
underscore in a generic parameter does not make sense. This check
accidentally banned the use of underscored generics everywhere in
the lambda, including the body, where as
and
is
expressions can be used.
-
Commit by mheiber: reified check: be more careful leaking type
params through this
You are not allowed to reify a type parameter with an erased inner
generic. You are sometimes allowed to reify the
this
type. This commit adds a check to make sure that
the this
type you are reifying does not include an
erased type parameter.
This code
now raises a type error.
-
Commit by vassilmladenov: Kill the old class_pointer_levels
flags, simplify errors
The following new typechecker options have been introduced:
class_pointer_ban_classname_new
,
class_pointer_ban_classname_type_structure
,
class_pointer_ban_classname_static_prop
,
class_pointer_ban_classname_static_meth
,
class_pointer_ban_classname_class_const
,
class_pointer_ban_class_array_key
It is now an error to use a classname<T>
in
places where a string
is expected. You will see this
typechecker error:
Using `SomeType::class` in this position will trigger an implicit
runtime conversion to string, please use `nameof SomeType`. nameof
is not valid in the HHVM 4 series.
-
Commit by viratyosin: Add error for recursive dependencies in
where clauses of case types
This only affects
case type X = Y
, not the classic
type X = Y
or newtype X = Y
type aliases.
The typechecker will now report an error if a where clause depends
on its own type.
This code
now reports an error.
-
Commit by Mistral Contrastin: Warn on calling static methods on
traits
The typechecker will now issue warnings when calling a private
static method on the name of a trait from within the body of the
trait. This will promote to a typechecker error in a future release.
-
Commit by Mistral Contrastin: Ban accessing static properties on
traits
Similarly to the methods case above, but this is a hard typechecker
error, rather than a warning.
-
Commit by Mistral Contrastin : Warn against static property
redeclaration
The typechecker will now warn on static property declarations which
repeat a static property from a base class. These properties were
not harmless redeclarations but actually created a second property
with the same name. This led to strange behavior where methods would
operate on the static property of the superclass or the subclass
depending on the late static bound type.
Breaking Changes
-
Commit by Niharika Devanathan: Add a runtime check that a
non-async method cannot override an async method
The runtime now enforces the belief of the typechecker that
public async function fooAsync(): Awaitable<int>
may not be overriden by a method without the
async
keyword. The reason being, the inner type of the
awaitable is enforced at runtime if your method is an async method.
Whereas an overriding non-async method returning an awaitable will
not enforce its inner type. This meant that code that suppressed
Hack errors could return an awaitable with a
string
inside instead of an int
.
-
Commit by vassilmladenov: Expand function pointer check, unify
with special_function emitter, refactor a bit
You are no longer allowed to create a function reference, using the
function_name<>
syntax to some special built-in
functions: HH\classname_to_class
, exit
,
HH\ReifiedGenerics\get_class_from_type
,
HH\global_get
, HH\global_set
,
HH\global_unset
, HH\tag_provenance_here
,
HH\FIXME\UNSAFE_CAST
,
HH\FIXME\UNSAFE_NONNULL_CAST
-
Commit by vassilmladenov: Update Facts sub/supertypes HHI
The functions
HH\Facts\subtypes
,
HH\Facts\transitive_subtypes
, and
HH\Facts\supertypes
now return
class<T>
instead of string
.
Changes to Experimental Features