diff --git a/src/Pattern.php b/src/Pattern.php index 9b625fa..9889602 100644 --- a/src/Pattern.php +++ b/src/Pattern.php @@ -292,7 +292,15 @@ protected function compileParserArgs(Ast $args) : array { return $compiled; } - private function compileAnonymousFunctionArg(array $arg) : \Closure { + private function compileAnonymousFunctionArg($arg) : \Closure { + if ($arg instanceof Ast) { + $arg = $arg->unwrap(); + } + + if (!is_array($arg)) { + throw new InvalidArgumentException('$arg should be an array or instance of Yay\Ast'); + } + $arglist = implode('', $arg['args']); $body = implode('', $arg['body']); $source = "index(); + + if (in_array(strtolower($stream->current()), ["true", "false", "null"])) { + return new \Yay\Error(null, null, $stream->last()); + } + + return new \Yay\Ast; + }), + ·ns()·ns + ) +} >> { + replaced ·ns +} + +matched true +matched false +matched null + +matched strtoupper +matched ucwords + +?> +--EXPECTF-- +