Skip to content

A class/trait declared in both arms of if (Cls::CONST >= n) is refused: the class-constant guard is not folded. #621

Closed

Description

@blacktrs

Summary

A class/trait declared in both arms of if (Cls::CONST >= n) is refused: the class-constant guard is not folded.

Repro

<?php
// reported in #614 (sentry/sentry Monolog compat traits)
class Logger { const API = 3; }
if (Logger::API >= 3) {
    trait Compat { public function v() { return "v3"; } }
} else {
    trait Compat { public function v() { return "v2"; } }
}
class H { use Compat; }
echo (new H)->v(), "\n";

Expected (php)

v3

Actual (manticore c421455f, Darwin arm64)

compile failed (rc=65):
compile failed: MIR.lower: unsupported statement kind Class at line 8
compile: front-end (parse/typeck/IR) returned null (rc=65)

Tracking

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

Activity

  1. added
    bug
    wrong-answer
    on Nov 10, 2026
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

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions