Skip to content

Language: diamond trait insteadof compile error wrong — Zend "Required Trait … wasn't added" (Zend/zend_compile.c) #32130

Description

@PurHur

Category

language · php-src-strict · traits · compile-time error text

Problem

Diamond trait graphs that require insteadof to pick a single DA::m provider should fail at compile time with Zend's "Required Trait DA wasn't added to DD" when the resolution is invalid. This compiler reports Could not find trait DA, hiding the real conflict reason.

Repro Zend 8.2+ VM/JIT compile (2026-08-18 @ 2f0c85a98d)
trait DA{}; trait DB{use DA;}; trait DC{use DA;}; class DD{use DB,DC{DA::m insteadof DB,DC;}} Fatal: Required Trait DA wasn't added to DD Could not find trait DA

Distinct from #32129 (parent class in insteadof); same error-reporting subsystem.

php-src reference

PHP implementation target

  • lib/ trait alias registration — surface Zend required-trait message when alias names a method provider not directly used on the class
  • PHP compile path only; shrink misleading generic trait lookup errors

Repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_trait_diamond_insteadof.php 2>&1 | head -1'
./script/docker-exec.sh -- bash -lc 'php bin/jit.php test/repro/maintainer_gap_trait_diamond_insteadof.php 2>&1 | head -1'

Done when

  • Compile abort matches Zend substring Required Trait DA wasn't added on VM and JIT
  • Compliance .phpt guard under test/compliance/cases/language/trait_diamond_insteadof*.phpt
  • php-src-strict; no php-compiler-strict shortcut

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