|
|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2021-07-27 20:34 UTC] crell@php.net
[2021-08-02 15:32 UTC] git@php.net
[2021-08-02 15:32 UTC] git@php.net
-Status: Open
+Status: Closed
|
|||||||||||||||||||||||||||
|
All rights reserved. |
Last updated: Thu Nov 06 09:00:01 2025 UTC |
Description: ------------ When a match() statement finds no matching arm, it throws an exception. The exception's error message text, however, is very generic. Specifically, it reads "Unhandled match value of type $type_of_the_match_var". The type of the variable is rarely useful in that case. The *value* of the variable is what didn't match, so that's what should be in the message. However, it's not even in the thrown object at all. Test script: --------------- try { $v = match('float') { 'string' => 's', 'int' => 'i', }; var_dump($v); } catch (UnhandledMatchError $e) { var_dump($e); } Expected result: ---------------- An exception thrown with a less misleading error message string, including the value of the variable, not its type. Actual result: -------------- object(UnhandledMatchError)#1 (7) { ["message":protected]=> string(36) "Unhandled match value of type string" ["string":"Error":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/U4Ns2" ["line":protected]=> int(4) ["trace":"Error":private]=> array(0) { } ["previous":"Error":private]=> NULL }