https://s3.amazonaws.com/clickhouse-test-reports/0/330987a64b46eda799735ce29267d228475fd143/fuzzer_astfuzzerdebug,actions//report.html

```
2022.01.21 18:46:37.968559 [ 480 ] {4084c2d5-7b0e-4a13-85de-bfeff1cb5588} <Fatal> : Logical error: 'Bad cast from type DB::ASTIdentifier to DB::ASTFunction'.
2022.01.21 18:46:37.969474 [ 481 ] {} <Fatal> BaseDaemon: ########################################
2022.01.21 18:46:37.969658 [ 481 ] {} <Fatal> BaseDaemon: (version 22.2.1.2985, build id: FFB23208CF51ADA0) (from thread 480) (query_id: 4084c2d5-7b0e-4a13-85de-bfeff1cb5588) Received signal Aborted (6)
2022.01.21 18:46:37.969826 [ 481 ] {} <Fatal> BaseDaemon: 
2022.01.21 18:46:37.969951 [ 481 ] {} <Fatal> BaseDaemon: Stack trace: 0x7f29d15de18b 0x7f29d15bd859 0x164226f8 0x16422802 0x16643524 0x166433f9 0x16642ff9 0x23b7de81 0x23b7dcb8 0x2424c89b 0x2424a004 0x24fe6ee3 0x24ff6e65 0x29205bb9 0x292063c8 0x29449914 0x294463fa 0x294451dc 0x7f29d1793609 0x7f29d16ba293
2022.01.21 18:46:37.970142 [ 481 ] {} <Fatal> BaseDaemon: 4. gsignal @ 0x7f29d15de18b in ?
2022.01.21 18:46:37.970258 [ 481 ] {} <Fatal> BaseDaemon: 5. abort @ 0x7f29d15bd859 in ?
2022.01.21 18:46:38.042988 [ 481 ] {} <Fatal> BaseDaemon: 6. ./obj-x86_64-linux-gnu/../src/Common/Exception.cpp:52: DB::handle_error_code(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool, std::__1::vector<void*, std::__1::allocator<void*> > const&) @ 0x164226f8 in /workspace/clickhouse
2022.01.21 18:46:38.102613 [ 481 ] {} <Fatal> BaseDaemon: 7. ./obj-x86_64-linux-gnu/../src/Common/Exception.cpp:59: DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0x16422802 in /workspace/clickhouse
2022.01.21 18:46:38.502878 [ 481 ] {} <Fatal> BaseDaemon: 8. ./obj-x86_64-linux-gnu/../src/Common/typeid_cast.h:40: std::__1::enable_if<std::is_reference_v<DB::ASTFunction&>, DB::ASTFunction&>::type typeid_cast<DB::ASTFunction&, DB::IAST>(DB::IAST&) @ 0x16643524 in /workspace/clickhouse
2022.01.21 18:46:38.902348 [ 481 ] {} <Fatal> BaseDaemon: 9. ./obj-x86_64-linux-gnu/../src/Common/TypePromotion.h:26: DB::TypePromotion<DB::IAST>::CastHelper<DB::ASTFunction&, false, true>::value(DB::IAST*) @ 0x166433f9 in /workspace/clickhouse
2022.01.21 18:46:39.301380 [ 481 ] {} <Fatal> BaseDaemon: 10. ./obj-x86_64-linux-gnu/../src/Common/TypePromotion.h:52: std::__1::invoke_result<decltype(&(CastHelper<DB::ASTFunction&, false>::value)), DB::TypePromotion<DB::IAST>::CastHelper<DB::ASTFunction&, false, std::is_reference_v<DB::ASTFunction&> >, DB::IAST*>::type DB::TypePromotion<DB::IAST>::as<DB::ASTFunction&>() @ 0x16642ff9 in /workspace/clickhouse
2022.01.21 18:46:39.388767 [ 481 ] {} <Fatal> BaseDaemon: 11. ./obj-x86_64-linux-gnu/../src/Interpreters/InterpreterCreateFunctionQuery.cpp:63: DB::InterpreterCreateFunctionQuery::validateFunction(std::__1::shared_ptr<DB::IAST>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) @ 0x23b7de81 in /workspace/clickhouse
2022.01.21 18:46:39.475713 [ 481 ] {} <Fatal> BaseDaemon: 12. ./obj-x86_64-linux-gnu/../src/Interpreters/InterpreterCreateFunctionQuery.cpp:52: DB::InterpreterCreateFunctionQuery::execute() @ 0x23b7dcb8 in /workspace/clickhouse
2022.01.21 18:46:39.715817 [ 481 ] {} <Fatal> BaseDaemon: 13. ./obj-x86_64-linux-gnu/../src/Interpreters/executeQuery.cpp:665: DB::executeQueryImpl(char const*, char const*, std::__1::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) @ 0x2424c89b in /workspace/clickhouse
2022.01.21 18:46:39.969329 [ 481 ] {} <Fatal> BaseDaemon: 14. ./obj-x86_64-linux-gnu/../src/Interpreters/executeQuery.cpp:984: DB::executeQuery(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum) @ 0x2424a004 in /workspace/clickhouse
2022.01.21 18:46:40.275886 [ 481 ] {} <Fatal> BaseDaemon: 15. ./obj-x86_64-linux-gnu/../src/Server/TCPHandler.cpp:333: DB::TCPHandler::runImpl() @ 0x24fe6ee3 in /workspace/clickhouse
2022.01.21 18:46:40.626278 [ 481 ] {} <Fatal> BaseDaemon: 16. ./obj-x86_64-linux-gnu/../src/Server/TCPHandler.cpp:1909: DB::TCPHandler::run() @ 0x24ff6e65 in /workspace/clickhouse
2022.01.21 18:46:40.697042 [ 481 ] {} <Fatal> BaseDaemon: 17. ./obj-x86_64-linux-gnu/../contrib/poco/Net/src/TCPServerConnection.cpp:43: Poco::Net::TCPServerConnection::start() @ 0x29205bb9 in /workspace/clickhouse
2022.01.21 18:46:40.782420 [ 481 ] {} <Fatal> BaseDaemon: 18. ./obj-x86_64-linux-gnu/../contrib/poco/Net/src/TCPServerDispatcher.cpp:115: Poco::Net::TCPServerDispatcher::run() @ 0x292063c8 in /workspace/clickhouse
2022.01.21 18:46:40.872457 [ 481 ] {} <Fatal> BaseDaemon: 19. ./obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/ThreadPool.cpp:199: Poco::PooledThread::run() @ 0x29449914 in /workspace/clickhouse
2022.01.21 18:46:40.961745 [ 481 ] {} <Fatal> BaseDaemon: 20. ./obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Thread.cpp:56: Poco::(anonymous namespace)::RunnableHolder::run() @ 0x294463fa in /workspace/clickhouse
2022.01.21 18:46:41.050275 [ 481 ] {} <Fatal> BaseDaemon: 21. ./obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Thread_POSIX.cpp:345: Poco::ThreadImpl::runnableEntry(void*) @ 0x294451dc in /workspace/clickhouse
2022.01.21 18:46:41.050653 [ 481 ] {} <Fatal> BaseDaemon: 22. ? @ 0x7f29d1793609 in ?
2022.01.21 18:46:41.050746 [ 481 ] {} <Fatal> BaseDaemon: 23. __clone @ 0x7f29d16ba293 in ?
2022.01.21 18:46:42.234828 [ 481 ] {} <Fatal> BaseDaemon: Calculated checksum of the binary: 39B50069795A18A7EDF551B3E0FAE515. There is no information about the reference checksum.

```

```
2022.01.21 18:46:37.968135 [ 480 ] {4084c2d5-7b0e-4a13-85de-bfeff1cb5588} <Debug> executeQuery: (from [::ffff:127.0.0.1]:34630) CREATE FUNCTION `02181_invalid_lambda` AS lambda(x_doubled)
2022.01.21 18:46:37.968315 [ 480 ] {4084c2d5-7b0e-4a13-85de-bfeff1cb5588} <Trace> ContextAccess (default): Access granted: CREATE FUNCTION ON *.*
2022.01.21 18:46:37.968559 [ 480 ] {4084c2d5-7b0e-4a13-85de-bfeff1cb5588} <Fatal> : Logical error: 'Bad cast from type DB::ASTIdentifier to DB::ASTFunction'.
2022.01.21 18:46:37.969658 [ 481 ] {} <Fatal> BaseDaemon: (version 22.2.1.2985, build id: FFB23208CF51ADA0) (from thread 480) (query_id: 4084c2d5-7b0e-4a13-85de-bfeff1cb5588) Received signal Aborted (6)
```
{
    auto & lambda_function = function->as<ASTFunction &>();
    auto & lambda_function_expression_list = lambda_function.arguments->children;
    const auto & tuple_function_arguments = lambda_function_expression_list.at(0)->as<ASTFunction &>();
    std::unordered_set<String> arguments;
    for (const auto & argument : tuple_function_arguments.arguments->children)
    {
        const auto * argument_identifier = argument->as<ASTIdentifier>();
        if (!argument_identifier)
            throw Exception(ErrorCodes::UNSUPPORTED_METHOD, "Lambda argument must be identifier");
        const auto & argument_name = argument_identifier->name();
        auto [_, inserted] = arguments.insert(argument_name);
        if (!inserted)
            throw Exception(ErrorCodes::UNSUPPORTED_METHOD, "Identifier {} already used as function parameter", argument_name);
    }
    ASTPtr function_body = lambda_function_expression_list.at(1);
    validateFunctionRecursiveness(function_body, name);
}
void InterpreterCreateFunctionQuery::validateFunctionRecursiveness(ASTPtr node, const String & function_to_create)
{
    for (const auto & child : node->children)
    {
        auto function_name_opt = tryGetFunctionName(child);
        if (function_name_opt && function_name_opt.value() == function_to_create)
            throw Exception(ErrorCodes::CANNOT_CREATE_RECURSIVE_FUNCTION, "You cannot create recursive function");
        validateFunctionRecursiveness(child, function_to_create);
    }
}
}