Closed as not planned
Description
Hello,
Commit 93d7002 introduced a regression. A reproducing snippet:
template <typename T> T &declval() noexcept {}
template <typename T> struct FakeVoidToVoid {};
template <typename Func> inline auto call(Func &&func) { return func(); }
template <typename Func>
using NormalizedCallResult = FakeVoidToVoid<decltype(call(declval<Func>()))>;
template <typename T> class SemiFuture {
public:
template <typename Func> auto then(Func &&func) {
return and_then(wrapCB<T>(func));
}
template <typename Func> auto and_then(Func &&func) {
using Result = NormalizedCallResult<Func>;
}
protected:
template <typename RawArg, typename Func> auto wrapCB(Func &&func) {
return [func = func](auto... args) -> SemiFuture<decltype(func(args...))> {return {};};
}
};
auto removeDocumentsInRange(SemiFuture<void> waitForActiveQueriesToComplete) {
return waitForActiveQueriesToComplete.then([]() {});
}
This has been reduced from code coming from MongoDB.
Before 93d7002, the func
in decltype(func(args...)
would refer to the parameter func
. After the commit, it would refer to the variable func
introduced by the capture. It looks like other parts of the parser (i,e, TemplateInstantiator::TransformDecl
) do not expect to find a VarDecl
and fail to handle them.
This regression happens for C++14 and higher, even though "Change scope of lambda trailing-return-type" was introduced with C++23.