ircmaxell / ircmaxell/php-cfg

Assertion fail when returning an anonymous function.

Open
#14 6 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.