Skip to content

Language: reject generator :void return type at compile time (#11666) - #11670

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-11666-generator-void-return
Jun 25, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-11666-generator-void-return

Conversation

@PurHur

@PurHur PurHur commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Summary

Generator functions that yield with a declared : void return type now fail at compile time with Zend's message, matching Zend/zend_compile.c (zend_handle_generator_func_return_type).

Extends GeneratorNeverReturnCompileCheck (same pass as : never rejection from #7351).

php-src reference

  • Zend/zend_compile.c — generator return type validation

PHP implementation

  • lib/Compiler/GeneratorNeverReturnCompileCheck.php

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_generator_void_return.php 2>&1; echo "zend exit: $?"
php bin/vm.php test/repro/maintainer_gap_generator_void_return.php 2>&1; echo "vm exit: $?"
./vendor/bin/phpunit --filter GeneratorNeverReturnCompileTest
./vendor/bin/phpunit --filter generator_void_return_compile test/compliance/VMTest.php'

Output:

PHP Fatal error:  Generator return type must be a supertype of Generator, void given in .../maintainer_gap_generator_void_return.php on line 4
zend exit: 255
Fatal error: Generator return type must be a supertype of Generator, void given in .../maintainer_gap_generator_void_return.php on line 4
vm exit: 255
OK (9 tests, 16 assertions)
OK (1 test, 1 assertion)

Closes #11666

Made with Cursor

Zend rejects yield + void; extend GeneratorNeverReturnCompileCheck to match php-src (#11666).

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Language: Generator return type void accepted — must fatal at compile time (Zend/zend_compile.c)

1 participant