Even if you declare a forward class D the error still persists...
struct A2 {
struct B {};
struct D;
consteval {
-> fragment struct {
B b = D(); //error
B getB() { return D(); } //error
};
}
struct D : B {};
};
Well, yeah. D hasn't been defined at the point it's used.
Hmm, that’s an interesting case. One would expect that to work since doing the injection manually works:
struct A2 {
struct B {};
struct D;
B b = D(); // Okay.
B getB() { return D(); } // Okay.
struct D : B {};
};
The way implementations handle that is by saving the tokens of the “complete-context component" for replay later on. Presumably, the fragment handling implementation doesn’t do that, or it replays them before injection?
Daveed