Overloading of getter/setters with plain variables seems broken
From jonasw
@ Roxen Slack:
class Op
{
object `data() {}
string _sprintf() {
return sprintf("%s(%O)",
function_name(object_program(this)),
data || "-");
}
}
class Op1(object mupp)
{
inherit Op;
object `data() { return mupp; }
}
class Op2(object data)
{
inherit Op;
// object `data() { return this::data; }
}
class Data()
{
string _sprintf() { return "DATA"; }
}
void main()
{
object data = Data();
werror("op1: %O, op2: %O\n", Op1(data), Op2(data));
}
When the above is run (Pike 8.0.1832 or 9.0.1), the following is output:
op1: Op1(DATA), op2: Op2("-")
The comment in Op2
triggers a compilation error due to the name clash between the variable data
and the getter of the same name.
It looks like the reference to data
in Op()->_sprintf()
has a local
/inline
scope even though data
has not been declared as such.