From e588f242768a5fe385c4b8539be5350db1d42957 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 22 Sep 2021 15:30:30 +0300 Subject: [PATCH] Fixed type inference --- ext/opcache/Optimizer/zend_inference.c | 3 +++ ext/opcache/tests/jit/assign_dim_003.phpt | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 ext/opcache/tests/jit/assign_dim_003.phpt diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c index e34d4db9ab9..3ac243c30a3 100644 --- a/ext/opcache/Optimizer/zend_inference.c +++ b/ext/opcache/Optimizer/zend_inference.c @@ -2754,6 +2754,9 @@ static zend_always_inline int _zend_update_type_info( if (t1 & ((MAY_BE_ANY|MAY_BE_UNDEF) - MAY_BE_STRING)) { tmp |= (OP1_DATA_INFO() & (MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF)); + if (OP1_DATA_INFO() & MAY_BE_UNDEF) { + tmp |= MAY_BE_NULL; + } if (opline->op2_type == IS_UNUSED) { /* When appending to an array and the LONG_MAX key is already used * null will be returned. */ diff --git a/ext/opcache/tests/jit/assign_dim_003.phpt b/ext/opcache/tests/jit/assign_dim_003.phpt new file mode 100644 index 00000000000..ab3d4d00fa8 --- /dev/null +++ b/ext/opcache/tests/jit/assign_dim_003.phpt @@ -0,0 +1,20 @@ +--TEST-- +JIT ASSIGN_DIM: 003 +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_buffer_size=1M +opcache.jit=tracing +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: Undefined variable $v in %sassign_dim_003.php on line 3 +NULL \ No newline at end of file