Bug #79517 [NEW]: Cannot specify "void" as return type of arrow function
| From: | pinkumohikan+phpbugs at gmail dot com | Date: | Fri, 24 Apr 2020 08:40:57 +0000 |
| Subject: | Bug #79517 [NEW]: Cannot specify "void" as return type of arrow function | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-226753@lists.php.net to get a copy of this message | ||
From: pinkumohikan+phpbugs at gmail dot com
Operating system: macOS Mojave
PHP version: 7.4.5
Package: Unknown/Other Function
Bug Type: Bug
Bug description:Cannot specify "void" as return type of arrow function
Description:
------------
When 'void' is specified as return type of arrow function, fatal error
will be caused.
Even if it returns void, it will not be fatal error if the return type
is not specified.
Test script:
---------------
function returnVoid(): void
{
}
var_dump(array_map(fn (int $n) => returnVoid(), [1, 2, 3]));
var_dump(array_map(fn (int $n): void => returnVoid(), [1, 2, 3]));
Expected result:
----------------
array(3) {
[0]=>
NULL
[1]=>
NULL
[2]=>
NULL
}
array(3) {
[0]=>
NULL
[1]=>
NULL
[2]=>
NULL
}
Actual result:
--------------
array(3) {
[0]=>
NULL
[1]=>
NULL
[2]=>
NULL
}
PHP Fatal error: A void function must not return a value in php shell
code on line 1
--
Edit bug report at https://bugs.php.net/bug.php?id=79517&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79517&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79517&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79517&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79517&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79517&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79517&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79517&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79517&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79517&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79517&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79517&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79517&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79517&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79517&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79517&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79517&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79517&r=mysqlcfg