Assertion fail when returning an anonymous function.
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 247
- Forks
- 45
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
In the following code example, an anonymous function is returned, acting like a closure. However, the Printer class expects a function name.
function generateComparisonFunctionForKey($key) {
return function ($left, $right) use ($key) {
if ($left[$key] == $right[$key])
return 0;
else
return ($left[$key] < $right[$key]) ? -1 : 1;
};
}
Error:
Warning: assert(): Assertion failed in /Users/<redacted>/php-cfg/lib/PHPCfg/Printer.php on line 46
Contributor guide
No contributing guide indexed for this repository
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 with Printer.php at line 46 and reproduce the assertion using the anonymous closure shown in the issue. Trace how Printer handles function names versus returned closures; the issue is complete when the closure case no longer triggers the assertion and its intended handling is clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100