Skip to content

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

Closed

Description

@PurHur

Category

Regression: · php-src-strict · profile gate (re-#19684 / re-#6974)

Problem

new Foo()->method() without wrapping parentheses is PHP 8.4 (new_without_parentheses RFC). Zend 8.2 parse-errors; default-profile VM returns 7 for a trivial method call.

Repro Zend 8.2.32 VM (2026-07-24, default)
echo new C()->m(); Parse error: unexpected token \"->\" 7

master@0ae5abab2.

php-src reference

PHP implementation target

  • Parser profile gate in lib/ — reject new ... immediately followed by ->/::/[/{/( call-chain on profiles < 8.4 with Zend parse error
  • Keep working under PHP_COMPILER_PROFILE=8.4

Repro

./script/docker-exec.sh -- bash -lc 'cat > /tmp/new_no_parens_profile.php <<\"PHP\"
<?php
class C { public function m(){ return 7; } }
echo new C()->m(), PHP_EOL;
PHP
php /tmp/new_no_parens_profile.php; echo EXIT_ZEND:$?
php bin/vm.php /tmp/new_no_parens_profile.php; echo EXIT_VM:$?'

Done when

  • Default profile: Zend-shaped parse error
  • Profile 8.4: prints 7
  • Repro guard; php-src-strict

Activity

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

    @PurHur
    OwnerAuthor

    Maintainer re-check (0ae5aba)

    Repro from the issue body is not reproducible on current master@0ae5abab2 — VM already matches Zend 8.2 rejection:

    Issue VM result (host php bin/vm.php, default profile)
    #22781 property hooks Parse error: unexpected token \"{\"
    #22782 typed class const syntax error, unexpected identifier \"X\", expecting \"=\"
    #22783 new T()->m() Parse error: unexpected token \"->\"
    #22784 public private(set) Fatal error: Multiple access type modifiers are not allowed

    Closing as already fixed / stale observation. Fresh PROFILE=8.3/8.4 gate gaps filed as #22792–#22795.

  3. PurHur commented on Jul 24, 2026

    @PurHur
    OwnerAuthor

    Closed: default-profile Zend rejection already matches on master@0ae5abab2 (see prior comment).

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