Awkward error using first-class callable syntax with missing function
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
The following code:
<?php
'missing'(...);
Resulted in this output:
Fatal error: Uncaught Error: Call to undefined function missing()
But I expected this output instead:
Fatal error: Uncaught Error: Unable to create closure from undefined function missing()
When using the first-class callable syntax on a missing function, the error message claims the user is calling a function. However, this should only be creating a closure.
I thought the (...) syntax would only try to create a closure. Does it actually try to call the function with a ... argument if it's not found?
If you use the original Closure::fromCallable() method, the error is different.
Closure::fromCallable('missing');
Uncaught TypeError: Failed to create closure from callable: function "missing" not found or invalid function name
PHP Version
8.1
Operating System
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the PHP 8.1 example using 'missing'(...); and compare its error with Closure::fromCallable('missing'). Trace the first-class callable handling for an undefined function; done means the syntax reports a closure-creation error rather than claiming the function was called.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100