Closed
Description
Describe the bug
error: non-local lambda expression cannot have a capture-default
.
To Reproduce
Steps to reproduce the behavior:
- Sample code - distilled down to minimal essentials please
f: (x)->int = 0;
y: int = 0.f();
Generated code
//=== Cpp2 type declarations ====================================================
#include "cpp2util.h"
//=== Cpp2 type definitions and function declarations ===========================
#line 1 "x.cpp2"
[[nodiscard]] auto f(auto const& x) -> int;
extern int y;
//=== Cpp2 function definitions =================================================
#line 1 "x.cpp2"
[[nodiscard]] auto f(auto const& x) -> int { return 0; }
int y {CPP2_UFCS_0(f, 0)};
- Command lines including which C++ compiler you are using
~/root/bin/cppfront x.cpp2
~/root/clang/bin/clang++ -std=c++20 -I $CPPFRONT_INCLUDE_DIR x.cpp
clang version 17.0.0
-
Expected result - what you expected to happen
UFCS to work at namespace scope. By using a different macro that doesn't use a capture-default. -
Actual result/error
x.cpp2:2:8: error: non-local lambda expression cannot have a capture-default
int y {CPP2_UFCS_0(f, 0)};
^
/home/johel/Documents/C++/Forks/cppfront/include/cpp2util.h:646:2: note: expanded from macro 'CPP2_UFCS_0'
[&](auto&& obj) CPP2_FORCE_INLINE_LAMBDA -> decltype(auto) { \
^
1 error generated.