Bug #79989 [Nab]: new `match` keyword is inconsistant in syntax errors
| From: | call dot user dot func at gmail dot com | Date: | Tue, 18 Aug 2020 10:59:09 +0000 |
| Subject: | Bug #79989 [Nab]: new `match` keyword is inconsistant in syntax errors | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-228638@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79989&edit=1
ID: 79989
User updated by: call dot user dot func at gmail dot com
Reported by: call dot user dot func at gmail dot com
Summary: new
match keyword is inconsistant in syntax errors
Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: W10
PHP Version: 8.0.0beta1
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Perfect. Thanks for answering. Sure, define() is just a string, when defining. When try to
output/use it, is is now correctly a syntax error.
Didn't knew of the namespace special behaviour and i also mixed up the match RFC change with
the namespace RFC.
Thanks. Not a bug :)
Previous Comments:
------------------------------------------------------------------------
[2020-08-18 10:55:35] cmb@php.net
A string (like used in define()) is never an issue wrt. reserved
keywords. class Match and function match are errors now,
since match is a reserved keyword.
The namespace declarations are special cased in PHP 8, so using a
stand alone match or having Match as part of a namespace
declaration name is allowed now.
So everything behaves as expected; thus not a bug. :)
------------------------------------------------------------------------
[2020-08-18 10:43:53] call dot user dot func at gmail dot com
Ok i understand this new RFC. When you say it is implemented in beta1, why it does not throw a error
in this version when using namespace match{}?
Also what's with all the other cases i've mentioned?
Really not a bug?
------------------------------------------------------------------------
[2020-08-18 10:32:26] cmb@php.net
The behavioral change of the namespace declaration is due to
RFC: Treat namespaced names as single token[1], which only has been
implemented for 8.0.0beta1, and is mentioned in UPGRADING[2].
[1] <https://wiki.php.net/rfc/namespaced_names_as_token>
[2] <https://github.com/php/php-src/blob/php-8.0.0beta1/UPGRADING#L207-L210>>
------------------------------------------------------------------------
[2020-08-18 10:02:55] call dot user dot func at gmail dot com
Description:
------------
Stated in this RFC: https://wiki.php.net/rfc/match_expression_v2#backward_incompatible_changes
we have this new keyword match which now result in syntax errors when used as a
namespaces, class names, function names, global constants.
Well, this behaviour is not consistant with the RFC and also inconsistent between the alpha3 and all
other pre-release versions of php8.
My tests are in the attached test scripts.
Greetz Roland
Test script:
---------------
<?php
define("match", 1); // no error in php8.0.0beta1
class Match{} // error in php8.0.0beta1
function match(){} // error in php8.0.0beta1
namespace match{} // only error in php8.0.0alpha3
namespace Foo\Bar\Match; // only error in php8.0.0alpha3
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79989&edit=1