Skip to content

Language: eval() — compile and execute code string at runtime (zend_execute_API.c parity) #4410

Description

@PurHur

Category

language

Status (refreshed 2026-06-02 — VM done, JIT/AOT tracked in #4652)

VM eval() is implemented (#3358 closed): ext/standard/VmEval.php compiles and executes strings in the caller scope. This issue remains the umbrella for remaining eval parity; workers should claim #4652 for JIT/AOT lowering.

Tier State
VM ✅ repro below prints 42
JIT/AOT LogicException: eval() is VM-only#4652

Problem

Zend eval() compiles and executes PHP source in the current scope, with ParseError on syntax failures. Native tiers must match or emit Zend-compatible fatals — not LogicException stubs.

php-src reference

Repro — VM (passes today)

Save as repro_eval_vm.php:

<?php
$x = 1;
eval('$x = $x + 41;');
echo $x, "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php repro_eval_vm.php    # 42
php repro_eval_vm.php               # Zend: 42
'

Repro — JIT/AOT (fails — #4652)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/jit.php repro_eval_vm.php
php bin/compile.php repro_eval_vm.php /tmp/eval-test && /tmp/eval-test
'

Expected after #4652: 42 on all tiers.

Repro — parse error shape

<?php
try {
    eval('class {');
} catch (Throwable $e) {
    echo get_class($e), ':', $e->getMessage(), "\n";
}
Engine Expected
Zend ParseError: ...
VM must be ParseError, not LogicException

Scope (this repo)

Area Files
VM ext/standard/VmEval.php, eval_.php — done (#3358)
JIT/AOT #4652eval_.php::call(), AOT runtime bridge
Tests test/compliance/cases/language/eval_*.phpt

Done when

Links

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITarea:vmVirtual machineimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions