Skip to content

Regression: new Class()->method() accepted on default 8.2 profile — Zend parse error (re-#22783, Zend/zend_language_parser.y) #24883

Closed

Description

@PurHur

Category

language · php-src-strict · profile-gated syntax (PHP 8.4)

Problem

On the default (8.2) profile, new DateTimeImmutable('…')->format(…) (constructor args, no extra parentheses around new) is accepted and runs. Zend 8.2 parse-rejects it. PHP 8.4 added this form; it must stay behind PHP_COMPILER_PROFILE=8.4 (or equivalent), not leak onto the default profile.

Repro Zend 8.2 (2026-07-29) VM / JIT default
echo new DateTimeImmutable('2020-01-01')->format('Y'); Parse error: unexpected token "->" (exit 255) 2020 (exit 0)

Same leak for new stdClass()->foo. Previously fixed as #22783 / #19684; regresses again.

php-src reference

PHP implementation target

  • Parser / profile gate in lib/ (language parser / versioned syntax flags) — reject this production when profile < 8.4
  • PHP-in-PHP only; no new C

Repro

./script/docker-exec.sh -- bash -lc 'cat > /tmp/newparens.php <<'"'"'PHP'"'"'
<?php
echo new DateTimeImmutable("2020-01-01")->format("Y"), PHP_EOL;
PHP
echo ZEND:; php /tmp/newparens.php 2>&1; echo RC:$?
echo VM:; php bin/vm.php /tmp/newparens.php 2>&1; echo RC:$?
echo JIT:; php bin/jit.php /tmp/newparens.php 2>&1; echo RC:$?'

Done when

  • Default profile: Zend-identical parse error on new Foo()->bar / new Foo()->prop without enclosing parentheses around new
  • PHP_COMPILER_PROFILE=8.4: form still accepted and runs
  • VM + JIT (+ AOT if in scope) agree; compliance/repro guard
  • php-src-strict; no php-compiler-strict shortcut

Activity

  1. added
    bugSomething isn't working
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 29, 2026
  2. PurHur commented on Jul 29, 2026

    @PurHur
    OwnerAuthor

    Maintainer note — pillar-1 probe (same run as filing)

    #10533 comments are locked (>2500), so recording here:

    Gate Status
    inventory OK 6635/6635
    helper-runtime-prelink --strict FAIL (76 stale)
    spine-coverage-sync FAIL (BcMathNumberToString.php)
    north-star5-verify-fast FAIL (follows spine)
    vm-driver-execute-probe OK
    user_release_ready no
    gen-0 stale (9e6b9c1 / 43d / 7014 lowering commits)

    Sibling filings this run: #24884, #24885, #24886. Merged compliance PR #24880 (JITTest baseline + suite-scoped quarantine).

  3. PurHur commented on Jul 29, 2026

    @PurHur
    OwnerAuthor

    claim: compile-link-trust-gate automation — starting this run (lane B). Pillar 1 probe: inventory OK 6635/6635; release-readiness user_release_ready=yes; north-star5-fast ok. Reproing default-profile new Class()->method() leak vs Zend 8.2 parse reject.

  4. PurHur commented on Jul 29, 2026

    @PurHur
    OwnerAuthor

    claim: worker-lane-B — starting this run

    Pillar-1 probe (this harness, before claim):

  5. PurHur commented on Jul 29, 2026

    @PurHur
    OwnerAuthor

    Merged #24898

    Fix: supportsDereferencableNewWithoutOuterParens() now uses languageProfileVersion() (same pattern as #24818 property hooks). Default / unset PROFILE and PROFILE=8.2 parse-reject new Foo()->bar; PROFILE=8.4 still accepts.

    Verified:

    • php bin/vm.php test/repro/issue_24883_new_without_parens_default_profile.php → parse error RC 255
    • PHP_COMPILER_PROFILE=8.4 → 2020 RC 0
    • Docker VM+JIT: new Builder()->build() reject on default, built on 8.4
    • phpunit filter (rejector + gate + compliance case) → OK 22 tests
  6. PurHur commented on Jul 29, 2026

    @PurHur
    OwnerAuthor

    Merged #24899

    Verification

    • Default / PROFILE=8.2 VM+JIT: Parse error: … unexpected token "->" (rc 255)
    • PROFILE=8.4 VM: 2020 (rc 0); JIT simple new Builder()->build() → built
    • Unit: NewDereferenceableSyntaxRejectorTest + gate tests OK
    • Compliance: new_without_parens_default_profile VMTest+JITTest OK

    Gate now uses languageProfileVersion() (not isForwardProfileAtLeast) — same pattern as #24818 property hooks.

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:compilerCompiler / CFG / JITbugSomething isn't workingimplementation-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