Skip to content

define() inside a function body or an if-branch leaves the constant undefined for later reads. #503

Closed

Description

@blacktrs

Summary

define() inside a function body or an if-branch leaves the constant undefined for later reads.

Repro

<?php
function f() { define("X", 1); }
f();
var_dump(X);
if ($argc > 0) { define("Y", [7]); }
var_dump(Y);

Expected (php)

int(1)
array(1) {
  [0]=>
  int(7)
}

Actual (manticore 64331ee4, Darwin arm64)


[exit code 255]
PHP Fatal error:  Uncaught Error: Undefined constant "X"

Tracking

Known-bug repro: tests/aot/repro/wrong/define_in_function_or_branch.php — bash tests/aot/xfail.sh -k define_in_function_or_branch reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions