php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74302 yield from1251('dfd') ("from1251" is a valid function name) fails
Submitted: 2017-03-23 19:10 UTC Modified: 2017-03-23 23:49 UTC
From: xtpd17 at gmail dot com Assigned: pollita
Status: Closed Package: *General Issues
PHP Version: 7.1.3 OS: Windows 7
Private report: No CVE-ID:
 [2017-03-23 19:10 UTC] xtpd17 at gmail dot com
Description:
------------
Seems like parser thinks that is a "yield from generator" case, which is not.

Test script:
---------------
<?php

function from1251($a)
{
	return $a;
}

function foo()
{
	yield from1251('df');
}

// Parse error: syntax error, unexpected '(' in test.php on line 10


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-23 19:40 UTC] pollita@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: pollita
 [2017-03-23 19:40 UTC] pollita@php.net
Verified.  Fix should be simple enough.
 [2017-03-23 20:51 UTC] pollita@php.net
-Status: Assigned +Status: Closed
 [2017-03-23 23:49 UTC] pollita@php.net
btw, just for the record, you can work around this bug for now with the following:

yield (from1251('df'));

The extra parenthesis doesn't change the meaning, but it does force the lexer to not consume the "from" portion of the function name.
 [2017-03-24 06:56 UTC] xtpd17 at gmail dot com
> btw, just for the record, you can work around this bug

Yep, thanks, that was the way I fixed it at first almost automatically and calmed down ("well, it's just my migration from 5.6 and new stricter parenthesis rules in 7.1"), but it looked strange enough to dig into it a bit just out of curiosity )).
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC