|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-06-18 16:19 UTC] cmb@php.net
[2015-06-18 20:04 UTC] cmb@php.net
[2015-06-19 02:27 UTC] laruence@php.net
-Status: Open
+Status: Feedback
[2015-06-19 02:27 UTC] laruence@php.net
[2015-06-19 22:49 UTC] kalle@php.net
[2015-06-22 09:12 UTC] dams@php.net
[2015-07-05 04:22 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 18:00:01 2025 UTC |
Description: ------------ With the new scalar typehint, when providing a default value with another type, PHP crashes. function a(int $a = 1.2) {} $a is supposed to be an integer, and the provided default value is a float. I checked this on the last rev of php-src (d9d1948396285583a915018fe9310fad998876ca, Thu Jun 18 17:22:22 2015 +0200), both on Debian 8 and Osx 10.10 Test script: --------------- <?php function a(int $a = 1.2) {} // sh: line 1: 49762 Segmentation fault: 11 php70 -l sth.php 2>&1 // Will also crash with the following : /* function a(int $a = true) {} function a(int $a = "3") {} function a(int $a = array()) {} function a(string $a = 1.2) {} function a(string $a = true) {} function a(string $a = array()) {} function a(string $a = 4) {} function a(string $a = -1) {} function a(float $a = true) {} function a(float $a = "3") {} function a(float $a = array()) {} function a(float $a = 4) {} function a(float $a = -1) {} function a(bool $a = 1.2) {} function a(bool $a = "3") {} function a(bool $a = array()) {} function a(bool $a = 4) {} function a(bool $a = -1) {} */ ?> Expected result: ---------------- Don't crash. Emit an error message at linting time to prevent such error. Actual result: -------------- => sh: line 1: 49762 Segmentation fault: 11 php70 -l sth.php 2>&1