|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-06-09 15:51 UTC] cmb@php.net
-Status: Open
+Status: Verified
-PHP Version: master-Git-2021-06-09 (Git)
+PHP Version: PHP 8.0
[2021-06-09 15:51 UTC] cmb@php.net
[2021-06-10 12:33 UTC] nikic@php.net
-Assigned To:
+Assigned To: nikic
[2021-06-10 12:48 UTC] git@php.net
[2021-06-10 12:48 UTC] git@php.net
-Status: Verified
+Status: Closed
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 05:00:01 2025 UTC |
Description: ------------ When using GMP class operators such as + or < with an invalid second value (such as non-numeric string or array), the exception picks up parameter name from the outer scope. Operator parameter probably doesn't have any meaningful name. The bad messages come from ext/gmp/gmp.c, function convert_to_gmp, lines 623 and 632. Just run (gmp_init(1) < "x") inside a function, and you'll find the second function parameter name in the error message. Test script: --------------- <?php function test($f) { try { $f(); echo "No error?\n"; } catch (TypeError|ValueError $e) { if (strpos($e->getMessage(), '($WRONG_SCOPE_')) { echo "Bad error! ", $e->getMessage(), "\n"; } else { echo "Good error.\n"; } } } test(fn($WRONG_SCOPE_1 = 0, $WRONG_SCOPE_2 = 0) => gmp_init(1) < "x"); test(fn($WRONG_SCOPE_1 = 0, $WRONG_SCOPE_2 = 0) => gmp_init(1) < []); test(fn($WRONG_SCOPE_1 = 0, $WRONG_SCOPE_2 = 0) => gmp_init(1) + "x"); test(fn($WRONG_SCOPE_1 = 0, $WRONG_SCOPE_2 = 0) => gmp_init(1) + []); Expected result: ---------------- Good error. Good error. Good error. Good error. Actual result: -------------- Bad error! {closure}(): Argument #2 ($WRONG_SCOPE_2) is not an integer string Bad error! {closure}(): Argument #2 ($WRONG_SCOPE_2) must be of type GMP|string|int, array given Bad error! {closure}(): Argument #2 ($WRONG_SCOPE_2) is not an integer string Bad error! {closure}(): Argument #2 ($WRONG_SCOPE_2) must be of type GMP|string|int, array given