In the current implementation of cppfront (fbf55ad) the following code:
element: type = {
children: std::vector<int> = ();
operator=: (out this, t : int ) = {
}
}
Generates:
#define CPP2_USE_MODULES Yes
#include "cpp2util.h"
#line 1 "../tests/bug_assignement_operator.cpp2"
class element;
//=== Cpp2 definitions ==========================================================
#line 1 "../tests/bug_assignement_operator.cpp2"
class element {
private: std::vector<int> children {};
public: explicit element(cpp2::in<int> t){
}
#line 4 "../tests/bug_assignement_operator.cpp2"
public: auto operator=(cpp2::in<int> t) -> element&
: children{ }
#line 5 "../tests/bug_assignement_operator.cpp2"
{
return *this;
#line 6 "../tests/bug_assignement_operator.cpp2"
}};
The issue is that the assignment operator has an initializer list and fails to compile with the error:
../tests/bug_assignement_operator.cpp2... ok (all Cpp2, passes safety checks)
../tests/bug_assignement_operator.cpp2:5:5: error: only constructors take base initializers
: children{ }
^
1 error generated.