Skip to content

Regression: NoDiscard built-in attribute class not registered on PHP_COMPILER_PROFILE=8.4 (re-#13159, Zend/zend_attributes.c) #16826

Closed

Description

@PurHur

Category

stdlib · php-src-strict · regression (re-#13159)

Problem

PHP 8.4+ registers a built-in NoDiscard attribute class for #[\NoDiscard] on functions. On PHP_COMPILER_PROFILE=8.4, the attribute parses and applies, but class_exists('NoDiscard') and attribute_exists('NoDiscard', …) are false.

Repro Zend 8.4 VM (2026-07-06, profile=8.4)
class_exists('NoDiscard') true false
attribute_exists('NoDiscard', stdClass::class) false false
#[NoDiscard] function f(): int { return 1; } runs runs (1)

php-src reference

PHP implementation target

  • ext/standard/ built-in attribute registration alongside other Zend attributes — PHP in ext/, shrink duplicate C registration if present

Repro

./script/docker-exec.sh -- bash -lc 'export PHP_COMPILER_PROFILE=8.4; php bin/vm.php test/repro/maintainer_gap_nodiscard_attribute_class.php'

Done when

  • class_exists('NoDiscard') true on PHP_COMPILER_PROFILE=8.4 (false on 8.2 reference)
  • ReflectionFunction::getAttributes() returns NoDiscard when applied
  • Compliance .phpt guard under test/compliance/cases/language/
  • php-src-strict; no php-compiler-strict shortcut

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 6, 2026
  2. PurHur commented on Jul 6, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-c — starting this run

  3. PurHur commented on Jul 6, 2026

    @PurHur
    OwnerAuthor

    Merged via #16831.

    Fix: advertisesNoDiscardAttributeClass() now uses languageProfileVersion() (same as advertisesOverrideAttributeClass()), so PHP_COMPILER_PROFILE=8.4 registers the builtin NoDiscard class while the default 8.4.0-dev reference profile keeps the phantom gate.

    Verified:

    • PHP_COMPILER_PROFILE=8.4 → class_exists('NoDiscard') true, #[NoDiscard] function f() runs
    • Default profile → maintainer_gap_nodiscard_registration.php prints ok
    • NoDiscardBuiltinAttributeTest, BuiltinAttributePhantomTest, nodiscard_class_exists.phpt (VM, profile 8.4)
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:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language featuresphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions