Closed thekid closed 1 year ago
Given the following code:
$nonNull= fn($record) => null !== $record; $process= fn($records, $filter) => { foreach ($records as $record) { if ($filter($record)) yield $record; } };
When run, this yields:
Unexpected exception lang.NullPointerException (Undefined variable $record)
The problem is that the second lambda is emitted as a function with use($record), caused by the first lambda's first parameter bleeding into the scope's locals.
function
use($record)
Given the following code:
When run, this yields:
The problem is that the second lambda is emitted as a
function
withuse($record)
, caused by the first lambda's first parameter bleeding into the scope's locals.