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] Function expression in alias has access specifier #842

Open
JohelEGP opened this issue Nov 18, 2023 · 0 comments · May be fixed by #706
Open

[BUG] Function expression in alias has access specifier #842

JohelEGP opened this issue Nov 18, 2023 · 0 comments · May be fixed by #706
Labels
bug Something isn't working

Comments

@JohelEGP
Copy link
Contributor

Title: Function expression in alias has access specifier.

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

v: @struct type = {
  f: std::type_identity_t<decltype(+ :(_: int) 0)> == :(_: int) 0;
  g: (i) i.f();
}
main: () = { }
Commands:
cppfront main.cpp2
clang++18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -I . main.cpp

Expected result:

  public: static const std::type_identity_t<decltype(+[]([[maybe_unused]] cpp2::in<int> unnamed_param_1) -> auto { return 0; })> f;

Actual result and error:

  public: static const std::type_identity_t<decltype(+public: []([[maybe_unused]] cpp2::in<int> unnamed_param_1) -> auto { return 0; })> f;
Cpp2 lowered to Cpp1:
//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"

class v;
  

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

class v {
  public: static const std::type_identity_t<decltype(+public: []([[maybe_unused]] cpp2::in<int> unnamed_param_1) -> auto { return 0; })> f;
  public: [[nodiscard]] static auto g(auto const& i) -> auto;
};
auto main() -> int;

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


  inline CPP2_CONSTEXPR std::type_identity_t<decltype(+[]([[maybe_unused]] cpp2::in<int> unnamed_param_1) -> auto { return 0; })> v::f = []([[maybe_unused]] cpp2::in<int> unnamed_param_1) -> auto { return 0; };
  [[nodiscard]] auto v::g(auto const& i) -> auto { return CPP2_UFCS_0(f, i);  }

auto main() -> int{}
Output:
main.cpp2:2:55: error: expected expression
    2 |   public: static const std::type_identity_t<decltype(+public: []([[maybe_unused]] cpp2::in<int> unnamed_param_1) -> auto { return 0; })> f;
      |                                                       ^
1 error generated.

See also:

@JohelEGP JohelEGP added the bug Something isn't working label Nov 18, 2023
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