qore icon indicating copy to clipboard operation
qore copied to clipboard

Const and member variables of a class with the same name - user should be warned about it

Open turlyalz opened this issue 6 years ago • 0 comments

Const and member variables of a class with the same name - user should be warned about it. To keep the backward compatibility a warning is the best solution.

For example this could be confusing:

class A {
    private {
        string test = "asd";
    }
}

class B inherits A {
    private {
        const test = "123";
    }

    constructor() {
        printf("B.test: %y\n", test);
        printf("B::test: %y\n", B::test);
    }
}

B b();

prints:

B.test: "asd"
B::test: "123"

turlyalz avatar Jan 28 '19 13:01 turlyalz