Hi,
Doing some experiments (Pike 7.4.28)... So: ---snip--- class Parent { mixed `[](mixed ... args) { Stdio.stderr->write("Called `[](%O) in %O: %O\n", args, this, ::`[](@args)); return ::`[](@args); } }
class Child { inherit Parent; }
int main(int argc, array(string)argv) { Child obj = Child(); mixed val; val = obj[-1..1]; // Just in case - optimizer will cut the code when "val =" is removed. } ---snip---
The attempt to execute gives: Bad argument 1 to ::->(). Expected string Unknown program: ::->(-1,1) object.c:2105: object.c:2105()->()(-1,1) inh2.pike:5: inh2()->Child()->](-1,1) inh2.pike:20: inh2()->main(1,({"/home/aldem/src/pike/inh2.pike"}))
I don't have any definition of `->() nor any references to it... And no references in docs that `->() and `[]() are equivalent... In fact, inheritance doesn't matter - it is just my standard template for test cases... Substitute Child to Parent and the error will be exactly the same. Not sure if problem exists with 7.5 or 7.4-cvs version - didn't check it out (yet)... Regards, /Al
I think the problem is that you're doing ::`[](@args) in Parent. Since Parent has no parent of its own, ::`[] will refer to the builtin [] operator. And the default operation for [] on an object will get the member with the indexed name from the object (i.e. the index must be a string). You probably ment to write something else that ::`[] there, although I'm not sure what. What semantics did you intend for your [] operator?
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2003-11-25 20:56: Subject: A bug(?) in lfun::`[]() handling
Hi,
Doing some experiments (Pike 7.4.28)... So:
---snip--- class Parent { mixed `[](mixed ... args) { Stdio.stderr->write("Called `[](%O) in %O: %O\n", args, this, ::`[](@args)); return ::`[](@args); } }
class Child { inherit Parent; }
int main(int argc, array(string)argv) { Child obj = Child(); mixed val;
val = obj[-1..1]; // Just in case - optimizer will cut the code when "val =" is removed. } ---snip---
The attempt to execute gives:
Bad argument 1 to ::->(). Expected string Unknown program: ::->(-1,1) object.c:2105: object.c:2105()->()(-1,1) inh2.pike:5: inh2()->Child()->](-1,1) inh2.pike:20: inh2()->main(1,({"/home/aldem/src/pike/inh2.pike"}))
I don't have any definition of `->() nor any references to it... And no references in docs that `->() and `[]() are equivalent...
In fact, inheritance doesn't matter - it is just my standard template for test cases... Substitute Child to Parent and the error will be exactly the same.
Not sure if problem exists with 7.5 or 7.4-cvs version - didn't check it out (yet)...
Regards, /Al
/ Brevbäraren
pike-devel@lists.lysator.liu.se