It should be possible to inherit "fake" classes
Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=6573
Reported by @marcus
It is possible to use the name of a "fake" class (really an object) when declaring a variable. However, when instead declaring an inherit the behaviour is not the expected.
Example:
---8<--- A.pmod ---8<--- static class Meta(string name) { string a() { return "+"+name; }
static class I(string value) { string a() { return "-"+name+":"+value; } int x() { return 0; } }
static program cast(string type) { return type=="program" && I; }
static I `()(string v)
{
return I(v);
}
}
Meta B = Meta("B");
---8<---
---8<--- b.pike ---8<---
import .A;
class C { inherit B; }
void main()
{
B b = B("*");
C c = C("%");
write("%O %O\n", _typeof(b)<=typeof(b), b->a());
write("%O %O\n", _typeof(c)<=typeof(b), c->a());
}
---8<---
Running b.pike gives the output
1 "-B:*" 0 "+%"
But the expected output is
1 "-B:*" 1 "-B:%"
compiler_do_inherit needs to check either the `() lfun (which is what the variable declaration does) or the cast lfun instead of just doing object_program().