diff --git a/composer.json b/composer.json index 551e00e9..078fad2f 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "marcj/topsort": "^2.0", "symfony/var-dumper": "^8.0", "symfony/yaml": "^8.0", - "swoole/phpx": "~2.3.1" + "swoole/phpx": "~2.3.3" }, "require-dev": { "phpunit/phpunit": "^10.4", diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 173a14c3..a57c2fa2 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -5270,6 +5270,8 @@ class CompilerBase extends \PhpAot\Core\Translator { $tmpVar = $this->genTmpVarName(); $this->addLocalVar($tmpVar, self::TYPE_ARRAY); + // 释放临时变量,避免修改数组产生数组复制操作 + $this->context->beforeStmtLines[] = $this->getIndent() . $tmpVar . '.clean();'; $items = $node->items; foreach ($items as $item) { @@ -5284,9 +5286,6 @@ class CompilerBase extends \PhpAot\Core\Translator } } - // 释放临时变量,避免修改数组产生数组复制操作 - $this->context->afterStmtLines[] = $this->getIndent() . $tmpVar . '.unset();'; - return $tmpVar; } } \ No newline at end of file diff --git a/src/Php/Translator.php b/src/Php/Translator.php index 3460b29b..b16e6911 100644 --- a/src/Php/Translator.php +++ b/src/Php/Translator.php @@ -36,7 +36,7 @@ use Symfony\Component\Yaml\Yaml; class Translator extends Preprocessor { - public const string VERSION = '0.2.0'; + public const string VERSION = '0.2.3'; public const string APP_NAME = 'Swoole-Compiler (AOT)'; protected string $targetName = 'app'; protected array $sourceDirs = []; diff --git a/tests/aot/array/007.phpt b/tests/aot/array/007.phpt new file mode 100644 index 00000000..c373ff1b --- /dev/null +++ b/tests/aot/array/007.phpt @@ -0,0 +1,20 @@ +--TEST-- +Array 007 +--FILE-- + true]); + $list = array_merge($list, $keys); +} +var_dump($list); +?> +--EXPECT-- +array(3) { + [0]=> + int(0) + [1]=> + int(1) + [2]=> + int(2) +} \ No newline at end of file diff --git a/version.txt b/version.txt index 9a9755e4..bb5b9923 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1058 +1060