Index: clang/lib/Parse/ParseExprCXX.cpp =================================================================== --- clang/lib/Parse/ParseExprCXX.cpp +++ clang/lib/Parse/ParseExprCXX.cpp @@ -1546,7 +1546,8 @@ TemplateParamScope.Exit(); LambdaScope.Exit(); - if (!Stmt.isInvalid() && !TrailingReturnType.isInvalid()) + if (!Stmt.isInvalid() && !TrailingReturnType.isInvalid() && + !D.isInvalidType()) return Actions.ActOnLambdaExpr(LambdaBeginLoc, Stmt.get(), getCurScope()); Actions.ActOnLambdaError(LambdaBeginLoc, getCurScope()); Index: clang/test/Parser/cxx2a-template-lambdas.cpp =================================================================== --- clang/test/Parser/cxx2a-template-lambdas.cpp +++ clang/test/Parser/cxx2a-template-lambdas.cpp @@ -32,3 +32,11 @@ // expected-warning@-3 {{is a C++23 extension}} // expected-warning@-3 {{is a C++23 extension}} #endif + +namespace GH64962 { +void f() { + [] (T i) -> int[] // expected-error {{function cannot return array type 'int[]'}} + // extension-warning {{explicit template parameter list for lambdas is a C++20 extension}} + { return 3; } (v); // expected-error {{use of undeclared identifier 'v'}} +} +} Index: clang/test/SemaCXX/subst-func-type-invalid-ret-type.cpp =================================================================== --- clang/test/SemaCXX/subst-func-type-invalid-ret-type.cpp +++ clang/test/SemaCXX/subst-func-type-invalid-ret-type.cpp @@ -5,12 +5,11 @@ template T declval(); template -auto Call(T x) -> decltype(declval()(0)) {} // expected-note{{candidate template ignored}} +auto Call(T x) -> decltype(declval()(0)) {} class Status {}; void fun() { // The Status() (instead of Status) here used to cause a crash. Call([](auto x) -> Status() {}); // expected-error{{function cannot return function type 'Status ()}} - // expected-error@-1{{no matching function for call to 'Call'}} }