https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106072
--- Comment #12 from Iain Sandoe <iains at gcc dot gnu.org> --- hmm: std::unique_ptr<AST::Type> type = nullptr; if (lexer.peek_token ()->get_id () == COLON) { lexer.skip_token (); // parse type, which is now required type = parse_type (); if (type == nullptr) { Error error (lexer.peek_token ()->get_locus (), "failed to parse type in closure parameter"); add_error (std::move (error)); // skip somewhere? return AST::ClosureParam::create_error (); } } if lexer.peek_token ()->get_id () != COLON, then type *will be* nullptr. (I don't know the rust impl. at all so cannot tell whether that's syntactically valid).