Skip to content

Regression: constructor-promoted public private(set) accepted — must compile-fatal (re-#6981, Zend/zend_compile.c) #9691

Closed

Description

@PurHur

Category

language · php-src-strict · regression of #6981 / #6742

Problem

Constructor-promoted properties with both public and asymmetric private(set) must be a compile-time fatal in PHP 8.4 (Multiple access type modifiers are not allowed). The VM accepts the syntax and runs the constructor, returning the promoted value.

php-src reference

Repro

test/repro/maintainer_gap_promoted_private_set.php:

<?php
class D {
    public function __construct(public private(set) int $x = 1) {}
}
$d = new D();
echo $d->x, "\n";
Engine Result
Zend PHP 8.2+ (8.4 semantics) Compile fatal: Multiple access type modifiers are not allowed
bin/vm.php Prints 1
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_promoted_private_set.php'
php test/repro/maintainer_gap_promoted_private_set.php # Zend reference

Implementation hints (PHP-in-PHP)

  • Reject in parser/lowering when promoted param has conflicting visibility + asymmetric write modifier
  • Mirror zend_compile promoted-property checks; no new C runtime

Scope

  • lib/ compile-time property/parameter validation
  • Optional compliance guard under test/compliance/cases/language/

Done when

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_promoted_private_set.php' # must not print 1

Activity

  1. added
    enhancementNew feature or request
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 18, 2026
  2. PurHur commented on Jun 18, 2026

    @PurHur
    OwnerAuthor

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

  3. PurHur commented on Jun 18, 2026

    @PurHur
    OwnerAuthor

    Merged via #9699

    Fix: AsymmetricVisibilityRewriter::rejectExplicitReadBeforeAsymmetricSetModifier() rejects explicit read visibility before asymmetric (set) modifiers (including single-line promoted constructor params) with php-src's Multiple access type modifiers are not allowed.

    Verification:

    • php bin/vm.php test/repro/maintainer_gap_promoted_private_set.php → compile fatal (no output 1)
    • php vendor/bin/phpunit test/unit/AsymmetricVisibilityRewriterTest.php test/unit/AsymmetricVisibilityCompileCheckTest.php → OK (28 tests)
    • Valid private(set) promoted ctor compliance case unchanged
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 features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions