Skip to content

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

Closed
@JohelEGP

Description

@JohelEGP

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions