Category
language · php-src-strict · regression
Problem
Scalar union types (int|string, ?float, DNF arms containing unions) abort compile with:
Unknown Op\Type provided: PHPCfg\Op\Type\Union_
Closed #6850 / #6833 tracked this gap; Docker repro (Jun 2026) shows all union sites fail again — function parameters, return types, promoted properties, and declared instance properties. Intersection types (A&B) still compile.
Self-host and modern PHP sources using unions cannot compile on VM/JIT/AOT.
php-src reference
Repro (failure today)
Parameter union:
<?php
function f(int|string $x): void {
echo $x;
}
f(1);
Declared property union:
<?php
class C {
public int|string $p;
}
$c = new C();
try {
var_dump($c->p);
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && ./script/apply-patches.sh
php bin/vm.php test/repro/maintainer_union_uninit.php 2>&1 | head -3
php bin/vm.php /tmp/param_union.php 2>&1 | head -3 # write repro files as above
'
| Site |
Zend |
VM today |
function f(int|string $x) |
compiles |
Unknown Op\Type\Union_ ❌ |
public int|string $p |
compiles |
Unknown Op\Type\Union_ ❌ |
function f(A&B $x) |
compiles |
compiles ✅ |
Scope (this repo)
| Layer |
Path |
| Compiler |
lib/Compiler.php — compileTypeConstrainedVariable, TYPE_DECLARE_PROPERTY, param/return type lowering for Union_ |
| VM |
lib/VM/TypeCheck.php — per-arm verify on read/write |
| JIT/AOT |
phase 2 after VM green (lib/JIT/TypeCheck.php, DNF helpers) |
| Tests |
test/compliance/cases/types/scalar_union_param.phpt, scalar_union_property.phpt |
PHP-in-PHP: union lowering in lib/; no new runtime/*.c.
Done when
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter scalar_union'
Related
Category
language· php-src-strict · regressionProblem
Scalar union types (
int|string,?float, DNF arms containing unions) abort compile with:Closed #6850 / #6833 tracked this gap; Docker repro (Jun 2026) shows all union sites fail again — function parameters, return types, promoted properties, and declared instance properties. Intersection types (
A&B) still compile.Self-host and modern PHP sources using unions cannot compile on VM/JIT/AOT.
php-src reference
Zend/zend_compile.c—zend_compile_type()union type listsZend/zend_type.c—zend_typebitmask + union armsZend/zend_type_check.c— runtime verifyRepro (failure today)
Parameter union:
Declared property union:
function f(int|string $x)Unknown Op\Type\Union_❌public int|string $pUnknown Op\Type\Union_❌function f(A&B $x)Scope (this repo)
lib/Compiler.php—compileTypeConstrainedVariable,TYPE_DECLARE_PROPERTY, param/return type lowering forUnion_lib/VM/TypeCheck.php— per-arm verify on read/writelib/JIT/TypeCheck.php, DNF helpers)test/compliance/cases/types/scalar_union_param.phpt,scalar_union_property.phptPHP-in-PHP: union lowering in
lib/; no newruntime/*.c.Done when
Errorlike Zend (notUnion_abort)./script/ci-fast.sh --filter scalar_uniongreenVerification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter scalar_union'Related