Skip to content

Self-host M2: php-cfg UnionType parser — compiler_lib_spine_smoke compile fails #2499

Description

@PurHur

Problem

BOOTSTRAP_LIB_SPINE_SMOKE=1 make bootstrap-selfhost-lib-spine-smoke is red on master (Docker php-compiler:22.04-dev, May 2026):

PHP Fatal error: Uncaught LogicException: Unknown type node: UnionType
  in vendor/ircmaxell/php-cfg/lib/PHPCfg/Parser.php:206
  … Runtime->parse() → bin/compile.php during spine bundle compile

php bin/compile.php -l test/selfhost/compiler_lib_spine_smoke/main.php fails with the same error.

Docs still claim M2 native link ✅ (docs/self-host-target.md, docs/bootstrap-selfhost.md). make bootstrap-loop-probe --dry-run fails at the M2 prerequisite step.

We already ship patches/php-cfg-intersection-type.patch for IntersectionType; union return/parameter types are not parsed.

First offender (spine bundle)

File Symbol Syntax
ext/standard/VmString.php VmString::str_word_count ): int|array (line ~1931)

Audit other inventory paths after the patch lands (grep -E '\): [A-Za-z_\\]+\|' ext/ lib/).

Goal

Spine bundle compiles and links natively without Zend:

BOOTSTRAP_LIB_SPINE_SMOKE=1 make bootstrap-selfhost-lib-spine-smoke
# stdout: compiler_lib_spine_smoke bundle OK
./script/bootstrap-loop-probe.sh --dry-run   # M2 step passes

Implementation hints

Piece Path Notes
Vendor patch patches/php-cfg-union-type.patch Mirror php-cfg-intersection-type.patch: Op\Type\Union, parseTypeNode() for Node\UnionType
Apply script/apply-patches.sh Composer patches entry if needed
CFG types lib/Compiler.php / lib/JIT.php Only if lowering gaps appear after parse (separate PR)
Spine test/selfhost/compiler_lib_spine_smoke/main.php No shim removal required for this slice

Done when

Repro (local / Docker only)

script/apply-patches.sh
./script/docker-exec.sh -- bash -lc 'BOOTSTRAP_LIB_SPINE_SMOKE=1 make bootstrap-selfhost-lib-spine-smoke'

No GitHub Actions (#394 ✅).

Dependencies / links

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions