mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
f957e3e7f1
Fixes GH-7900 Closes GH-9103
27 lines
436 B
PHP
27 lines
436 B
PHP
--TEST--
|
|
GH-7900: Arrow function with never return type compile-time errors
|
|
--INI--
|
|
zend.assertions=1
|
|
assert.exception=1
|
|
--FILE--
|
|
<?php
|
|
|
|
$x = fn(): never => throw new \Exception('Here');
|
|
|
|
try {
|
|
var_dump($x());
|
|
} catch (\Exception $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
try {
|
|
assert((fn(): never => 42) && false);
|
|
} catch (\Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
Here
|
|
assert(fn(): never => 42 && false)
|