On Mon, 27 May 2024, Ilija Tovilo wrote:

> On Sun, May 26, 2024 at 11:47 PM Gina P. Banyard <intern...@gpb.moe> 
> wrote:
> >
> > On Wednesday, 8 May 2024 at 14:40, Gina P. Banyard 
> > <intern...@gpb.moe> wrote:
> >
> > > I would like to formally propose my idea for exit() as a function 
> > > brought up to the list on 2024-02-24 [1] with the following RFC: 
> > > https://wiki.php.net/rfc/exit-as-function
> >
> > As there haven't been any comments for nearly two weeks, I'm 
> > planning on opening the vote for the RFC on Tuesday.

Right now, I am not going to be in favour of this. Specfically because 
the Backward Incompatible Changes don't list some of the backward 
breaking changes, and no mitigations are provided. See below.

I also don't see the benefit from doing this in the first place. 
exit/die has always meant "bail straight out", without any function 
semantics (from https://www.php.net/exit):

        exit — Output a message and terminate the current script

        exit is a language construct and it can be called without 
        parentheses if no status is passed.

It's not that this a particularly new or novel behaviour.

I saw somewhere else in the thread that the exit construct could already 
throw a catchable exception. I consider that a bug.

> As mentioned early on in private, I don't see a convincing reason to 
> remove tokenizer/parser support for exit/die. I'd rather see this 
> handled in the parser directly, by converting the standalone keywords 
> to function calls. This avoids any backwards incompatibility, and 
> avoids special handling in zend_compile_const.
> 
> Another thing that's probably not too important: The PR likely breaks 
> dead code elimination for exit() and die().

I have just checked this for Xdebug, and you're definitely right with 
that. With the removal of the ZEND_EXIT opcode, it can not now detect a 
scope/function exit now.

It also breaks my "do tasks on ZEND_EXIT" with the profiler. It is used 
to always write the closing profiling footer to the files. Without me 
being able to overload thati opcode, data would not be complete.
I even have two bugs (with tests) for this:

- https://bugs.xdebug.org/68
- https://bugs.xdebug.org/631 

Xdebug has been overloading ZEND_EXIT for nearly 20 years now.

> This could be re-added by checking for the never return type instead.

I can't quite see a way on how to do that? The EXIT is replaced by an 
INIT_FCALL/DO_ICALL:

     4     0  E >   EXT_STMT    
           1        ECHO        '55'
     5     2        EXT_STMT    
-          3      > EXIT        
-    6     4*       EXT_STMT    
-          5*       ECHO        '675'
-    7     6*       EXT_STMT    
-          7*     > RETURN      null
+          3        INIT_FCALL  'exit'
+          4        DO_ICALL    
+    6     5        EXT_STMT    
+          6        ECHO        '675'
+    7     7        EXT_STMT    
+          8      > RETURN      null

The opcodes don't have direct access to the type mask structure as far 
as I know.

cheers,
Derick

Reply via email to