From: Nikita Popov Date: Fri, 22 Feb 2019 10:55:16 +0000 (+0100) Subject: Fix inference warning about missing key type X-Git-Tag: php-7.3.4RC1~62^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2cfb09caa775a7b5851f2ee10fac3c870344a181;p=php Fix inference warning about missing key type --- diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c index 5848778616..9e88e4566b 100644 --- a/ext/opcache/Optimizer/zend_inference.c +++ b/ext/opcache/Optimizer/zend_inference.c @@ -2093,7 +2093,6 @@ static uint32_t assign_dim_result_type( tmp |= MAY_BE_RC1 | MAY_BE_RCN; } if (tmp & MAY_BE_ARRAY) { - tmp |= (value_type & MAY_BE_ANY) << MAY_BE_ARRAY_SHIFT; if (value_type & MAY_BE_UNDEF) { tmp |= MAY_BE_ARRAY_OF_NULL; } @@ -2114,6 +2113,11 @@ static uint32_t assign_dim_result_type( tmp |= MAY_BE_ARRAY_KEY_STRING; } } + /* Only add value type if we have a key type. It might be that the key type is illegal + * for arrays. */ + if (tmp & MAY_BE_ARRAY_KEY_ANY) { + tmp |= (value_type & MAY_BE_ANY) << MAY_BE_ARRAY_SHIFT; + } } return tmp; } diff --git a/ext/opcache/tests/invalid_array_key_type.phpt b/ext/opcache/tests/invalid_array_key_type.phpt new file mode 100644 index 0000000000..f2e65bedba --- /dev/null +++ b/ext/opcache/tests/invalid_array_key_type.phpt @@ -0,0 +1,18 @@ +--TEST-- +Don't add array value type is key type is illegal +--FILE-- + +===DONE=== +--EXPECT-- +===DONE===