On 4/4/23 3:08 AM, Chris Katko wrote:
Second, could you give me some case examples where this problem occurs?
Is the issue if I override refresh in a derived class, and the base
class will accidentally use child.refresh()?
An example of a problem:
```d
class Base
{
this() { virtualCall()
On Tuesday, 4 April 2023 at 07:08:52 UTC, Chris Katko wrote:
dscanner reports this as a warning:
```D
struct foo{
this()
{
/* some initial setup */
refresh();
}
void refresh() { /* setup some more stuff */}
// [warn] a virtual call inside a constructor may lead to
unexpected results in
On 4/4/23 00:08, Chris Katko wrote:
> dscanner reports this as a warning:
>
> ```D
> struct foo{
> this()
>{
>/* some initial setup */
>refresh();
>}
> void refresh() { /* setup some more stuff */}
> // [warn] a virtual call inside a constructor may lead to unexpected
> results in
> Firstly, are all calls virtual in a struct/class in D?
In D structs are always value types without a vtable or inheritance.
Classes are always reference types with a vtable, but some of the
methods may be final and hence not in vtable.
> Second, could you give me some case examples where th
dscanner reports this as a warning:
```D
struct foo{
this()
{
/* some initial setup */
refresh();
}
void refresh() { /* setup some more stuff */}
// [warn] a virtual call inside a constructor may lead to
unexpected results in the derived classes
}
```
Firstly, are all calls virtual in