Bug #78301 [Opn->Nab]: exit -1 is valid but exit 1 is syntax error

From: Date: Wed, 17 Jul 2019 08:03:14 +0000
Subject: Bug #78301 [Opn->Nab]: exit -1 is valid but exit 1 is syntax error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221820@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78301&edit=1

 ID:                 78301
 Updated by:         nikic@php.net
 Reported by:        dams@php.net
 Summary:            exit -1 is valid but exit 1 is syntax error
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            *General Issues
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

exit -1 is (exit) - 1. The form without parentheses should probably be
deprecated to avoid this kind of confusion.


Previous Comments:
------------------------------------------------------------------------
[2019-07-17 07:44:13] dams@php.net

Description:
------------
Using a plus or minus sign allows exit to avoid parenthesis. 

The behavior should be consistent : either parenthesis are always needed, either they are optional. 

Either enforce parenthesis in both cases (suggested modification),
or relax parenthesis usage in both cases.

Same applies to die;

Test script:
---------------
exit  1;  <= syntax error
exit (1)  <= executable code
exit -1;  <= executable code
exit +1;  <= executable code

exit -+-1;  <= executable code

exit -$f;  <= executable code
exit $f;  <= syntax error
exit($f);  <= executable code


Expected result:
----------------
exit and die use parenthesis the same way, with or without minus and plus signs.


Actual result:
--------------
exit and die behaves differently parenthesis with or without minus and plus signs.



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=78301&edit=1


Thread (4 messages)

« previous php.bugs (#221820) next »