Skip to content

[BUG] Missing _template-head_ in static data member definition #698

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

Closed
JohelEGP opened this issue Sep 24, 2023 · 1 comment · Fixed by #703
Closed

[BUG] Missing _template-head_ in static data member definition #698

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

Comments

@JohelEGP
Copy link
Contributor

Title: Missing template-head in static data member definition.

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

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

Expected result:

template<typename T>
  inline constexpr int t::v = 0;

Actual result and error:

  inline constexpr int t::v = 0;
Cpp2 lowered to Cpp1:
//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"

template<typename T> class t;
  

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

template<typename T> class t {
  public: static const int v;
};
auto main() -> int;


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


  inline constexpr int t::v = 0;

auto main() -> int{}
Output:
main.cpp2:2:24: error: use of class template 't' requires template arguments
    2 |   inline constexpr int t::v = 0;
      |                        ^
build/main.cpp:13:28: note: template is declared here
   13 | template<typename T> class t {
      | ~~~~~~~~~~~~~~~~~~~~       ^
1 error generated.
@JohelEGP
Copy link
Contributor Author

JohelEGP commented Oct 3, 2023

On main, these are the new results (https://cpp2.godbolt.org/z/s31xsTj18).

Actual result and error:

  template<typename T> inline CPP2_CONSTEXPR int<T> t<T>::v = 0;
Output:
main.cpp2:2:49: error: expected unqualified-id
    2 |   template<typename T> inline CPP2_CONSTEXPR int<T> t<T>::v = 0;
      |                                                 ^
1 error generated.

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