Skip to content

Language: highlight_file()/highlight_string() — __DIR__/__FILE__ concat fails compile (MagicScriptConst, Zend/zend_compile.c) #9924

Description

@PurHur

Category

language · php-src-strict

Problem

Scripts that build paths with __DIR__ / __FILE__ for highlight_file() / highlight_string() fail at compile time:

parseAndCompile failure: Unknown variable op found: Expr_MagicScriptConst

Zend compiles and runs these patterns (common in debug tooling and self-host tests).

php-src reference

Repro (failure today — verified 2026-06-19)

test/repro/maintainer_gap_highlight_file_bool.php:

<?php
$sample = __DIR__ . '/highlight_sample.php';
$fileHtml = highlight_file($sample, true);
echo gettype($fileHtml), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/maintainer_gap_highlight_file_bool.php'
# parseAndCompile failure: Unknown variable op found: Expr_MagicScriptConst

Also fails when highlight_string('<?php echo 1; ?>', true) works but a subsequent highlight_file(__DIR__ . '/x.php', true) does not.

Scope (PHP-in-PHP)

Layer Path
Compiler lib/Compiler.php — lower Op\Expr\MagicScriptConst in concat / call arg contexts
AST lib/Ast/ if php-cfg overlay gaps
Builtins ext/standard/highlight_file.php, highlight_string.php (runtime OK once compile succeeds)
Tests test/compliance/cases/stdlib/highlight_file_dir_concat.phpt

Done when

  • Repro compiles and prints boolean (or string when sample exists) on VM
  • __FILE__, __DIR__, __LINE__ work in string concat passed to highlight builtins
  • JIT/AOT compile same script without MagicScriptConst fatal
  • ./script/ci-fast.sh --filter highlight_file_dir_concat green

Related

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

    IMPORTANTCritical patharea:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-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