Category
language · php-src-strict
Problem
Using never inside a union type (int|never, function f(int|never $x)) must be rejected at compile time with Zend's message:
never can only be used as a standalone type
This compiler dies earlier with Unknown Op\Type provided: PHPCfg\Op\Type\Union_ — same abort as general union regression (#7327), but never-in-union needs an explicit guard so workers do not confuse it with scalar union lowering.
Standalone never (function f(): never, never $p) must keep compiling.
php-src reference
Repro
test/repro/never_union_property.php:
<?php
class C {
public int|never $x;
}
echo "ok\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/never_union_property.php 2>&1 | head -1
php -r "class C { public int|never \$x; }" 2>&1 | head -1 # PHP 8.x reference when available
'
| Engine |
Message |
| Zend |
never can only be used as a standalone type |
| VM |
Unknown Op\Type\Union_ ❌ |
Also verify parameter declarations: function f(int|never $x).
Scope (this repo)
| Path |
Work |
lib/Compiler.php |
Before union CFG lowering: scan type arms for Never_; throwCompileError('never can only be used as a standalone type') |
| Tests |
test/compliance/cases/language/never_union_type.phpt (property + parameter) |
Coordinate with #7327 scalar union lowering — this issue is the never-specific guard + message even if union compile is fixed separately.
Done when
Related
Category
language· php-src-strictProblem
Using
neverinside a union type (int|never,function f(int|never $x)) must be rejected at compile time with Zend's message:This compiler dies earlier with
Unknown Op\Type provided: PHPCfg\Op\Type\Union_— same abort as general union regression (#7327), butnever-in-union needs an explicit guard so workers do not confuse it with scalar union lowering.Standalone
never(function f(): never,never $p) must keep compiling.php-src reference
Zend/zend_compile.c—zend_compile_type()never-in-union checkZend/zend_type.cRepro
test/repro/never_union_property.php:never can only be used as a standalone typeUnknown Op\Type\Union_❌Also verify parameter declarations:
function f(int|never $x).Scope (this repo)
lib/Compiler.phpNever_;throwCompileError('never can only be used as a standalone type')test/compliance/cases/language/never_union_type.phpt(property + parameter)Coordinate with #7327 scalar union lowering — this issue is the never-specific guard + message even if union compile is fixed separately.
Done when
Unknown Op\Type\Union_)nevertypes still compile./script/ci-fast.sh --filter never_union_typegreenRelated