Skip to content

Commit e7153e8

Browse files
committed
Improve "narrowing" error message
By including the opcode name.
1 parent 33fa02e commit e7153e8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1927,7 +1927,10 @@ static void handle_type_narrowing(const zend_op_array *op_array, zend_ssa *ssa,
19271927
{
19281928
if (1) {
19291929
/* Right now, this is always a bug */
1930-
zend_error(E_WARNING, "Narrowing occurred during type inference. Please file a bug report on bugs.php.net");
1930+
int def_op_num = ssa->vars[var].definition;
1931+
const zend_op *def_opline = def_op_num >= 0 ? &op_array->opcodes[def_op_num] : NULL;
1932+
const char *def_op_name = def_opline ? zend_get_opcode_name(def_opline->opcode) : "PHI";
1933+
zend_error(E_WARNING, "Narrowing occurred during type inference of %s. Please file a bug report on bugs.php.net", def_op_name);
19311934
} else {
19321935
/* if new_type set resets some bits from old_type set
19331936
* We have completely recalculate types of some dependent SSA variables

0 commit comments

Comments
 (0)