-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Variable with placeholder type can't share name with member call in initializer #550
Comments
All compilers reject https://compiler-explorer.com/z/4f3d818hs: class t { int f(); };
int main() {
auto f = [](auto obj) {
if constexpr (requires { obj.f(); }) return obj.f();
else return f(obj);
}(t());
} (Opened https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110978 for GCC's ICE.) #include <boost/hana/functional/overload_linearly.hpp>
class t { int f(); };
int main() {
auto f = boost::hana::overload_linearly(
[](auto obj) requires requires { obj.f(); } { return obj.f(); },
[](auto obj) requires requires { f(obj); } { return f(obj); }
)(t());
} |
Rewriting Cpp1 Maybe there's something from the exploration of #307 I can salvage to solve this issue.
|
I think the solution is to disable UFCS |
Here is a data point that suggests Cpp1 code equivalent to Cpp2 |
There is another case that #506 doesn't yet cover (https://cpp2.godbolt.org/z/hzYxv5rn6):
There is another case that #506 doesn't yet cover (https://cpp2.godbolt.org/z/xj1P9cd66):
This is the same as #550 (comment). |
For this kind of code, in GitHub, |
Title: Variable with placeholder type can't share name with member call in initializer.
Description:
Something in the UFCS machinery breaks this use case.
My actual use case looks more like this (https://cpp2.godbolt.org/z/sGK36zbe1):
It's a function expression that captures.
Using
std::function
is undesirable,and currently impossible given #343.
Minimal reproducer (https://cpp2.godbolt.org/z/r7Ef84MKs):
Commands:
cppfront main.cpp2 clang++17 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -I . main.cpp
Expected result: A working program.
Actual result and error:
Cpp2 lowered to Cpp1:
The text was updated successfully, but these errors were encountered: