Skip to content

Incorrect result with redeclared class when JIT #16404

@YuanchengJiang

Description

@YuanchengJiang

Description

The following code:

<?php
echo "this should be called twice!\n";

class Example {} // will be redeclared

if (defined("test")) {
  echo "end\n";
} else {
  define("test", 1);
  echo("now include myself\n");
  include(__FILE__);
}
?>

Resulted in this output:

this should be called twice!
now include myself

Fatal error: Cannot redeclare class Example (previously declared in /tmp/x.php:4) in /tmp/x.php on line 4

But I expected this output instead:

this should be called twice!
now include myself
this should be called twice!

Fatal error: Cannot redeclare class Example (previously declared in /tmp/x.php:4) in /tmp/x.php on line 4

To reproduce:

-d "zend_extension=/php-src/modules/opcache.so" -d "opcache.enable_cli=1" -d "opcache.enable=1"

It seems the error goes before the next execution in JIT so that it does not echo twice?

PHP Version

nightly

Operating System

ubuntu 22.04

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions