Skip to content

Regression: trait use insteadof/as — adapted methods missing at runtime (re-#3238, Zend/zend_compile.c) #9903

Description

@PurHur

Category

language · php-src-strict · regression on closed #3238

Problem

Trait use adaptations (insteadof precedence + as alias) compile but do not merge adapted methods onto the using class. C::f() and aliased C::g() are undefined at runtime despite valid use TA, TB { TA::f insteadof TB; TB::f as g; }.

php-src reference

Repro

test/repro-maintainer/trait_use_adaptations.php:

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro-maintainer/trait_use_adaptations.php'
# VM today: Fatal "Call to undefined method C::f()"; Zend: AB

Implementation hints (PHP-in-PHP)

  • Fix trait adaptation merge in compiler/VM (applyTraitUsesWithAdaptations, class entry materialization)
  • Compliance guard: test/compliance/cases/language/trait_use_adaptations.phpt

Done when

  • Repro prints AB under VM (php-src-strict)
  • JIT/AOT agree when trait-merged methods are invoked from compiled units

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro-maintainer/trait_use_adaptations.php'

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

    IMPORTANTCritical patharea: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