I get the above error with the following code. Shouldn't that work?
arne
-----
class A { object D(string n) { return C.D(this, E(n)); } }
class B { inherit A;
array(object) operands;
void create(object ... operands) { this_program::operands = operands; } }
class C { class D { inherit B;
void foo() { operands->foo(); } } }
class E(string s) { inherit A;
void foo() { werror("foo: %s\n", s); } }
int main() { object o = A()->D("bar"); return 0; }
Hi Arne.
I get the above error with the following code. Shouldn't that work?
The parent use detector is overzealous...
arne
class A { object D(string n) { return C.D(this, E(n));
The problem here is that D has been marked as PROGRAM_USES_PARENT, but is indexed directly from a program (C), so the parent pointer can't be set.
If you change the code to
return C()->D(this, E(n));
it might work.
}
}
class B { inherit A;
array(object) operands; void create(object ... operands) { this_program::operands = operands; }
}
class C { class D { inherit B;
C (and D) get PROGRAM_USES_PARENT set here because B is found by traversing the compile-time parent pointers of D and C.
As inherits are performed at compile-time (it isn't possible to swap out the inherited B by inheriting the top-level program and overriding B (ie link-time)), this isn't meaningful.
It ought to be rather simple to change so that PROGRAM_USES_PARENT isn't set in this case, but I havn't looked close at it.
void foo() { operands->foo(); } }
}
[...]
/grubba
pike-devel@lists.lysator.liu.se