Skip to content

Language: parenthesized DNF intersection-only types compile on VM — Zend 8.2 reference profile parse error (Zend/zend_compile.c) #14904

Description

@PurHur

Summary

Parenthesized intersection-only DNF types such as (I1&I2) $param and function f(): (I1&I2) are accepted and executed on this compiler. The project’s Zend 8.2.31 docker reference rejects them at parse time (unexpected variable "$o", expecting "|").

PHP 8.3+ php-src allows these forms; PHP 8.2 does not. Today lib/Ast/DnfParenTypeRewriter.php unwraps them for php-parser 4.x compatibility (#9733) without gating on language profile.

php-src reference

  • Zend/zend_compile.c — zend_compile_type() / DNF normalization (PHP 8.3+ parenthesized intersection leaves)
  • Compare lib/ExitFunctionSyntaxRejector.php — precedent for rejecting 8.4-only syntax on 8.2 profile

PHP implementation target

  • lib/Ast/DnfParenTypeRewriter.php — gate unwrap behind language version / reference profile, or
  • lib/Compiler.php + lib/VM/DnfCheck.php / lib/JIT/DnfParamCheck.php — enforce runtime DNF constraints only when syntax is legal for active profile
  • Do not regress unparenthesized I1&I2 $param (valid on 8.2)

Repro

./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_dnf_paren_intersection_param.php
# Zend 8.2: parse error
# VM: ok

./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_dnf_paren_intersection_return.php
# Zend 8.2: parse error
# VM: true

Done when (php-src-strict)

  • On Zend 8.2 reference profile (current docker): (I1&I2) $param and function f(): (I1&I2) are compile-time parse errors matching Zend output class
  • When profile bumped to 8.3+: same snippets compile and instanceof/return checks succeed
  • Compliance guards for both profiles (or explicit phpc.json language version) under test/compliance/cases/language/

Notes

  • If the project intentionally targets 8.3+ syntax ahead of docker reference, document in issue fix + docs/capabilities.md and add profile gate flag — default CI must stay php-src-strict on 8.2 docker.

Activity

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 / JITarea: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