Skip to content
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] template in front of _qualified-id_ instead of _unqualified-id_ in UFCS #854

Closed
JohelEGP opened this issue Nov 24, 2023 · 1 comment · Fixed by #506
Closed

[BUG] template in front of _qualified-id_ instead of _unqualified-id_ in UFCS #854

JohelEGP opened this issue Nov 24, 2023 · 1 comment · Fixed by #506
Labels
bug Something isn't working

Comments

@JohelEGP
Copy link
Contributor

Title: template in front of qualified-id instead of unqualified-id in UFCS.

Minimal reproducer (https://cpp2.godbolt.org/z/fTM758bhW):

main: () = {
  _ = std::views::iota(0, 42).std::ranges::to<std::vector>();
}
Commands:
cppfront main.cpp2
clang++18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -Werror=unused-value -Werror=unused-parameter -I . main.cpp

Expected result:
Cpp1 std::views::iota(0, 42).std::ranges::template to<std::vector>() (https://cpp1.godbolt.org/z/G44hKecs5).

Actual result and error:
Cpp1 std::views::iota(0, 42).template std::ranges::to<std::vector>() (https://cpp1.godbolt.org/z/s5fWYbxdP).

Cpp2 lowered to Cpp1:
//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"

#line 1 "/app/example.cpp2"


//=== Cpp2 type definitions and function declarations ===========================

#line 1 "/app/example.cpp2"
auto main() -> int;

//=== Cpp2 function definitions =================================================

#line 1 "/app/example.cpp2"
auto main() -> int{
#line 2 "/app/example.cpp2"
  static_cast<void>(CPP2_UFCS_TEMPLATE_0(std::ranges::to, (<std::vector>), std::views::iota(0, 42)));
}
Output:
main.cpp2:2:45: error: expected ';' at end of requirement
    2 |   static_cast<void>(CPP2_UFCS_TEMPLATE_0(std::ranges::to, (<std::vector>), std::views::iota(0, 42)));
      |                                             ^
main.cpp2:2:45: error: expected ';' after return statement
main.cpp2:2:55: error: no member named 'to' in namespace 'std::ranges'
    2 |   static_cast<void>(CPP2_UFCS_TEMPLATE_0(std::ranges::to, (<std::vector>), std::views::iota(0, 42)));
      |                                          ~~~~~~~~~~~~~^
raw.githubusercontent.com/hsutter/cppfront/main/include/cpp2util.h:816:16: note: expanded from macro 'CPP2_UFCS_TEMPLATE_0'
  816 |         return FUNCNAME CPP2_UFCS_REMPARENS TEMPARGS (CPP2_FORWARD(obj)); \
      |                ^~~~~~~~
main.cpp2:2:72: error: expected '(' for function-style cast or type construction
    2 |   static_cast<void>(CPP2_UFCS_TEMPLATE_0(std::ranges::to, (<std::vector>), std::views::iota(0, 42)));
      |                                                             ~~~~~~~~~~~^
raw.githubusercontent.com/hsutter/cppfront/main/include/cpp2util.h:816:45: note: expanded from macro 'CPP2_UFCS_TEMPLATE_0'
  816 |         return FUNCNAME CPP2_UFCS_REMPARENS TEMPARGS (CPP2_FORWARD(obj)); \
      |                                             ^~~~~~~~
raw.githubusercontent.com/hsutter/cppfront/main/include/cpp2util.h:800:34: note: expanded from macro 'CPP2_UFCS_REMPARENS'
  800 | #define CPP2_UFCS_REMPARENS(...) __VA_ARGS__
      |                                  ^~~~~~~~~~~
main.cpp2:2:81: error: no member named 'views' in namespace 'std'
    2 |   static_cast<void>(CPP2_UFCS_TEMPLATE_0(std::ranges::to, (<std::vector>), std::views::iota(0, 42)));
      |                                                                            ~~~~~^
raw.githubusercontent.com/hsutter/cppfront/main/include/cpp2util.h:818:3: note: expanded from macro 'CPP2_UFCS_TEMPLATE_0'
  818 | }(PARAM1)
      |   ^~~~~~
5 errors generated.
@JohelEGP JohelEGP added the bug Something isn't working label Nov 24, 2023
@JohelEGP
Copy link
Contributor Author

JohelEGP commented Nov 24, 2023

Fixed: https://cpp1.godbolt.org/z/MThznW56f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant