Bug #70241 [Asn]: Skipped assertions affect Generator returns

From: Date: Tue, 11 Aug 2015 19:47:51 +0000
Subject: Bug #70241 [Asn]: Skipped assertions affect Generator returns
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195143@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70241&edit=1 ID: 70241 Updated by: bwoebi@php.net Reported by: me at kelunik dot com Summary: Skipped assertions affect Generator returns Status: Assigned Type: Bug Package: Scripting Engine problem PHP Version: 7.0.0beta3 Assigned To: bwoebi Block user comment: N Private report: N New Comment: While I agree with you that the current behavior with zend.assertions=0 is not perfect, it's not fixable without major changes in the implementation. As we need to be able to dynamically toggle assertions off and on. Hence I'd like to make zend.assertions=0 & assertions=off behave the same than zend.assertions=-1. All what would need to be fixed is actually walking the AST of the assert expression and checking for ZEND_AST_YIELD. (What I'm going to do.) Previous Comments: ------------------------------------------------------------------------ [2015-08-11 19:45:55] nikic@php.net To make sure everyone is on the same page: The bug here is not that the yield does not get evaluated (that's correct). The bug is that the function is not marked as a generator at all. So zend.assertions=-1 not only skips the assertion, but also influences the behavior of the function as a whole -- which it shouldn't do. ------------------------------------------------------------------------ [2015-08-11 19:39:28] cmb@php.net > It doesn't mean ignore all the side-effects caused by the > content of assert(). It just means ignoring the code generated > by it. Turning off assertions would not make much sense, if only the overhead of checking the value of the expression would be skipped. What actually may be very costly is the evaluation the expression itself (consider checking each element of a large array for some condition). AFAIK, "no" programming language does evaluate the expression, if assertion checking is disabled. At least this is so with PHP 5, cf. <http://3v4l.org/YLofr> and <http://3v4l.org/RRp6m>. > Additional note: zend.assertions=0 and zend.assertions=-1 > *should* IMHO behave the same. ACK. However, IMHO, the current behavior with zend.assertions=0 is in error. ------------------------------------------------------------------------ [2015-08-11 18:20:09] bwoebi@php.net Additional note: zend.assertions=0 and zend.assertions=-1 *should* IMHO behave the same. Which would imply that it definitely should return a Generator in both cases. ------------------------------------------------------------------------ [2015-08-11 18:20:04] bwoebi@php.net Additional note: zend.assertions=0 and zend.assertions=-1 *should* IMHO behave the same. Which would imply that it definitely should return a Generator in both cases. ------------------------------------------------------------------------ [2015-08-11 18:16:19] bwoebi@php.net Precisely, it means not producing any code. "-1 - don't generate any code (zero-cost, production mode)" from the RFC. It doesn't mean ignore all the side-effects caused by the content of assert(). It just means ignoring the code generated by it. So, the reporter is right. Either it's a mistake in the RFC or a bug. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=70241 -- Edit this bug report at https://bugs.php.net/bug.php?id=70241&edit=1

« previous php.bugs (#195143) next »