Open
Description
Title: Type of this
can't be a nested type.
Description:
It's common to alias complicated base types.
Cpp2's member declaration order suggests a nested type could be used for a this
member.
But it's not generally possible for the lowered Cpp1 to make use of it
(it's directly impossible,
and only for the simple cases could cppfront
recursively replace nested types for their initializer).
Minimal reproducer (https://cpp2.godbolt.org/z/vs1abM95E):
#include <chrono>
my_time: type = {
this: duration;
rep: type == cpp2::longdouble;
period: type == std::ratio<17, 29>;
duration: type == std::chrono::duration<rep, period>;
operator=: (out this, d: duration) = { duration = d; }
}
main: () = { }
Commands:
cppfront -clean-cpp1 main.cpp2
clang++17 -std=c++2b -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -I . main.cpp
Expected result:
A well-formed program or a diagnostic by cppfront
.
Actual result and error:
Cpp2 lowered to Cpp1.
#include "cpp2util.h"
class my_time;
#include <chrono>
class my_time: public duration {
public: using rep = cpp2::longdouble;
public: using period = std::ratio<17,29>;
public: using duration = std::chrono::duration<rep,period>;
public: explicit my_time(cpp2::in<duration> d);
public: my_time(my_time const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(my_time const&) -> void = delete;
};
auto main() -> int;
my_time::my_time(cpp2::in<duration> d)
: duration{ d }
{}
auto main() -> int{}
build/_cppfront/main.cpp:9:23: error: expected class name
class my_time: public duration {
^