[BUG] can not override a virtual function to pure virtual
Describe the bug cppfront does not allow to override a function into pure virtual. Whether base type function is pure or not has no impact.
To Reproduce sample code:
base: type =
{
d: (virtual move this);
f: (virtual this) -> int = 1;
}
derived: type =
{
this: base = ();
f: (override this) -> int;
}
expected result - something like this:
class base
{
public:
virtual ~base() = default;
virtual int f() { return 1; }
};
class derived : public base
{
public:
int f() override = 0;
};
actual result: main.cpp2(10,5): error: a function must have a body ('=' initializer), unless it is virtual (has a 'virtual this' parameter) or is defaultable (operator== or operator<=>)
Command lines
cppfront main.cpp2 -p, built from commit dc3758a74d2ab815b7d4c5a19a7635e34e379ef1
Additional context
Conflicting documentation - https://hsutter.github.io/cppfront/cpp2/types/ says:
A pure virtual function is a function with a
virtual thisoroverride thisparameter and no body.
Probably need to add a check for override here.
https://github.com/hsutter/cppfront/blob/dc3758a74d2ab815b7d4c5a19a7635e34e379ef1/source/sema.h#L1636-L1649
I wasn't even aware that this was a thing. I've never seen a pure virtual override, but I can see where it can be useful.