Bug #78337 [Opn->Nab]: Typed properties references inconsistency due to gc

From: Date: Sat, 27 Jul 2019 13:28:41 +0000
Subject: Bug #78337 [Opn->Nab]: Typed properties references inconsistency due to gc
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221946@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78337&edit=1 ID: 78337 Updated by: nikic@php.net Reported by: jascha dot php at ja-s dot de Summary: Typed properties references inconsistency due to gc -Status: Open +Status: Not a bug Type: Bug -Package: PHP Language Specification +Package: Scripting Engine problem PHP Version: 7.4.0beta1 Block user comment: N Private report: N New Comment: This is by design and discussed extensively in the RFC. Previous Comments: ------------------------------------------------------------------------ [2019-07-27 12:52:48] jascha dot php at ja-s dot de Description: ------------ I've just looked into PHP 7.4s property typing. I'm a little disappointed, that this is currently limited to properties, and can not be applied to any variables. Luckily v2 supports references to properties. So I'm pretty sure somebody is gonna provide a little library to construct typed variables by linkin a variable to the reference set of a typed property. But what isn't mentioned in the typed_properties_v2 RFC, is how the garbage collector affects the typing due to reducing the reference set. This can produce unexpected behavior. Possible solutions: * Forbid references: https://wiki.php.net/rfc/typed_properties_v2#forbid_references * Add typed variables (seems unlikely, but i'm hoping for this) * Just document the behavior Test script: --------------- https://3v4l.org/ctEgn Expected result: ---------------- string(3) "123" string(3) "123" Actual result: -------------- int(123) string(3) "123" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78337&edit=1

« previous php.bugs (#221946) next »