Bug #77628 [NEW]: Using const AND use in the same scope.

From: Date: Sun, 17 Feb 2019 10:10:05 +0000
Subject: Bug #77628 [NEW]: Using const AND use in the same scope.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219608@lists.php.net to get a copy of this message
From: dams Operating system: Irrelevant PHP version: 7.3.2 Package: *Programming Data Structures Bug Type: Bug Bug description:Using const AND use in the same scope. Description: ------------ Using an import alias and defining the constant in the same scope leads to inconsistent error message : Undefined constant 'C' C is aliased into D first. Then it is created. Its creation is validated by 'echo C', which yields the right value. 'echo D' fails, mentioning that 'C' doesn't exists. Extra note : + splitting the namespace A in two (one with const, one with use) raise the same issue. + use and const may be in any order (use first, const first), still raise the same issue. Test script: --------------- <?php namespace A { use const C as D; const C = 2; echo C; echo D; } Expected result: ---------------- 22 Actual result: -------------- 2PHP Fatal error: Uncaught Error: Undefined constant 'C' in test.php:8 Stack trace: #0 {main} thrown in test.php on line 8 -- Edit bug report at https://bugs.php.net/bug.php?id=77628&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77628&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77628&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77628&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77628&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77628&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77628&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77628&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77628&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77628&r=support Expected behavior: https://bugs.php.net/fix.php?id=77628&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77628&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77628&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77628&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77628&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77628&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77628&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77628&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77628&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77628&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77628&r=mysqlcfg

« previous php.bugs (#219608) next »