php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28118 'INT' constant produces parse error
Submitted: 2004-04-23 09:07 UTC Modified: 2004-04-23 13:57 UTC
From: foospam at wp dot pl Assigned:
Status: Not a bug Package: Compile Failure
PHP Version: * OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: foospam at wp dot pl
New email:
PHP Version: OS:

 

 [2004-04-23 09:07 UTC] foospam at wp dot pl
Description:
------------
seems, that "INT" string is some keyword for parser.

Reproduce code:
---------------
define('INT', 2);
$types = array(1 * INT);
foreach($types as $type) {
  echo $type . "<br />\n";
}
echo "<hr />\n";
$types = array(INT);
foreach($types as $type) {
  echo $type . "<br />\n";
}

Expected result:
----------------
2<br />
<hr />
2<br />


Actual result:
--------------
Parse error: parse error, expecting `'('' in X on line 7.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-23 09:31 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

int is a reserverd keyword (in the docs you\'ll find a list of all reserved keywords)
 [2004-04-23 09:57 UTC] foospam at wp dot pl
Hey, that IS bug, because I want to use NOT RESERVED WORD, and parser causes an error!
I have checked everything related with constants in PHP Manual (language -> constants, list of predefined constants, list of parser tokens, list of reserved words, EVEN LIST OF FUNCTIONS AND THEIR ALIASES), and there is no "INT" constant or anything related with it described!

BTW, "INT" constant name SHOULD WORK EVEN, if there is already registered function with that name - I've checked: constant "is_int" does work.

I know: there is a cast: `(int)', but:

array(int)

is different from

(int) $foo

parser should recognize, that my "INT" is user-defined constant, because I want to use it as the array element.
 [2004-04-23 10:04 UTC] helly@php.net
ok, changed to analyzed

the parser sees a int conversion "(int)" which has higher priority than the array initialization.
 [2004-04-23 13:57 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

yes, it is. Not a bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 05:01:30 2024 UTC