Skip to content

Commit 323f3c6

Browse files
committed
Improve file/line information for narrowing warning
Report the file/line of the opline rather than the include location. This should make issues like #8251 easier to debug.
1 parent 3b4d33a commit 323f3c6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Zend/Optimizer/zend_inference.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,10 @@ static void emit_type_narrowing_warning(const zend_op_array *op_array, zend_ssa
18641864
int def_op_num = ssa->vars[var].definition;
18651865
const zend_op *def_opline = def_op_num >= 0 ? &op_array->opcodes[def_op_num] : NULL;
18661866
const char *def_op_name = def_opline ? zend_get_opcode_name(def_opline->opcode) : "PHI";
1867-
zend_error(E_WARNING, "Narrowing occurred during type inference of %s. Please file a bug report on bugs.php.net", def_op_name);
1867+
uint32_t lineno = def_opline ? def_opline->lineno : 0;
1868+
zend_error_at(
1869+
E_WARNING, op_array->filename, lineno,
1870+
"Narrowing occurred during type inference of %s. Please file a bug report on https://github.com/php/php-src/issues", def_op_name);
18681871
}
18691872

18701873
ZEND_API uint32_t zend_array_element_type(uint32_t t1, zend_uchar op_type, int write, int insert)

0 commit comments

Comments
 (0)