Hi everybody!
Well, maybe you are already aware of this... maybe not. I tried to find an issue about this and unless I didn't think of the right keywords, it's not there.
I was debugging a template method and sudenly I found myself spending ours trying to find out why I got different results when printing the result of a message sent to super and when steping into that message and printing the (same) result there.
Imagine this simple situation (I attatch the complete code and some tests so you can reproduce this): AverageTotalization inherits from Totalization. WeightedAverageTotalization inherits from AverageTotalization.
Totalization>>total
^self summatory
AverageTotalization>>total
^(super total) / self denominator
AverageTotalization>> denominator
^values size
WeightedAverageTotalization>> denominator
"Weights is a dictionary"
^self weights values sum
If I debug aWeightedAverateTotalization total and try to print super total in the debugger ParagraphEditor, I'll get this result:
(self summatory / self denominator)
instead of just: self summatory I think that when you print or inspect (etc) super total, the evaluation context takes WeightedAverageTotalization class instead of AverageTotalization, so when total is sent to super under that context, the code is looked up on AverageTotalization instead of Totalization.
Could that be possible? Am I thinking right? I spent a while chasing this bug, and I found a solution, but I don't know if it's OK or if it's the best. It's simple and it seems to work. I tested it in the last PharoCore1.1 unstable image.
I attach some code to reproduce the error (you'll get a halt when you run the test, read the comments, the problem is clear when you run the weighted average test), and the code that fixes this.
If you confirm that this was not a known issue, I'll register it on the issue tracker with both these attachments. If it was a known issue... well, I learned :) (I think XD)
Cheers! Carla.
_______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project DoItBugsInTemplateMethod.st (6K) Download Attachment fixForSuperSendsOnDoIts.1.cs (3K) Download Attachment |
Oh, I forgot, Compiler>>compiledMethodFor: textOrStream in: aContext to: receiver notifying: aRequestor ifFail: failBlock logged: logFlag has no senders.
Was that replaced by Compiler>>evaluate: textOrStream in: aContext to: receiver notifying: aRequestor ifFail: failBlock logged: logFlag ?
On Tue, May 18, 2010 at 3:52 AM, Carla F. Griggio <[hidden email]> wrote: Hi everybody! _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Carla F. Griggio
Hi Carla. I would like to help you, but I have no idea. I could reproduce it.
Maybe Lukas, Igor, Eliot etc can help you. I have no idea. Cheers Mariano 2010/5/18 Carla F. Griggio <[hidden email]> Hi everybody! _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Just reproducing it would be helpful :O a friend of mine already
tested the code I attatched and saw the same problem. If you recall having a class with a method sending a message to super, and a sublclass inheriting that method, you can try to reproduce it there too debugging that message on an instance of the subclass. It's not easy to explain with words, that's why I made a little package of code to illustrate the situation. The thing is that when printing the evaluation of a selected bunch of code inside a debugger window (paragraphEditor?), if the code you're evaluating is a message to super, and the class of the object you're debugging is inheriting the method you're debugging, the printed result will be wrong. In other words, the method lookup fails. This doesn't happen with normal excution of code (thank God!). I think this is an important bug, seeing those wrong results when debugging can be very confusing. I spent hours feeling stupid last Monday while debugging because I trusted those wrong results and couldn't see where I was doing something wrong :P Cheers! Carla On Wednesday, May 19, 2010, Mariano Martinez Peck <[hidden email]> wrote: > Hi Carla. I would like to help you, but I have no idea. I could reproduce it. > > Maybe Lukas, Igor, Eliot etc can help you. I have no idea. > > Cheers > > Mariano > > 2010/5/18 Carla F. Griggio <[hidden email]> > Hi everybody! > Well, maybe you are already aware of this... maybe not. I tried to find an issue about this and unless I didn't think of the right keywords, it's not there. > > > > I was debugging a template method and sudenly I found myself spending ours trying to find out why I got different results when printing the result of a message sent to super and when steping into that message and printing the (same) result there. > > > > Imagine this simple situation (I attatch the complete code and some tests so you can reproduce this): > AverageTotalization inherits from Totalization.WeightedAverageTotalization inherits from AverageTotalization. > > > > Totalization>>total > > ^self summatory > > > > > > AverageTotalization>>total > > ^(super total) / self denominator > > > > > > AverageTotalization>> denominator > > ^values size > > > > > WeightedAverageTotalization>> denominator > > "Weights is a dictionary" > > ^self weights values sum > > > > > If I debug aWeightedAverateTotalization total and try to print super total in the debugger ParagraphEditor, I'll get this result: > > > > (self summatory / self denominator) > > > instead of just: > self summatory > This only happens when I print or inspect or other do-its in the debugger window. The method lookup works OK when just _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > > _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Yes this is an important bug
do you have the cs of your little example? Stef On May 19, 2010, at 9:17 PM, Carla F. Griggio wrote: > Just reproducing it would be helpful :O a friend of mine already > tested the code I attatched and saw the same problem. > > If you recall having a class with a method sending a message to super, > and a sublclass inheriting that method, you can try to reproduce it > there too debugging that message on an instance of the subclass. > > It's not easy to explain with words, that's why I made a little > package of code to illustrate the situation. > > The thing is that when printing the evaluation of a selected bunch of > code inside a debugger window (paragraphEditor?), if the code you're > evaluating is a message to super, and the class of the object you're > debugging is inheriting the method you're debugging, the printed > result will be wrong. In other words, the method lookup fails. > > This doesn't happen with normal excution of code (thank God!). > > I think this is an important bug, seeing those wrong results when > debugging can be very confusing. I spent hours feeling stupid last > Monday while debugging because I trusted those wrong results and > couldn't see where I was doing something wrong :P > > Cheers! > Carla > > On Wednesday, May 19, 2010, Mariano Martinez Peck <[hidden email]> wrote: >> Hi Carla. I would like to help you, but I have no idea. I could reproduce it. >> >> Maybe Lukas, Igor, Eliot etc can help you. I have no idea. >> >> Cheers >> >> Mariano >> >> 2010/5/18 Carla F. Griggio <[hidden email]> >> Hi everybody! >> Well, maybe you are already aware of this... maybe not. I tried to find an issue about this and unless I didn't think of the right keywords, it's not there. >> >> >> >> I was debugging a template method and sudenly I found myself spending ours trying to find out why I got different results when printing the result of a message sent to super and when steping into that message and printing the (same) result there. >> >> >> >> Imagine this simple situation (I attatch the complete code and some tests so you can reproduce this): >> AverageTotalization inherits from Totalization.WeightedAverageTotalization inherits from AverageTotalization. >> >> >> >> Totalization>>total >> >> ^self summatory >> >> >> >> >> >> AverageTotalization>>total >> >> ^(super total) / self denominator >> >> >> >> >> >> AverageTotalization>> denominator >> >> ^values size >> >> >> >> >> WeightedAverageTotalization>> denominator >> >> "Weights is a dictionary" >> >> ^self weights values sum >> >> >> >> >> If I debug aWeightedAverateTotalization total and try to print super total in the debugger ParagraphEditor, I'll get this result: >> >> >> >> (self summatory / self denominator) >> >> >> instead of just: >> self summatory >> This only happens when I print or inspect or other do-its in the debugger window. The method lookup works OK when just _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> >> > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Not the cs, I have an st. It's in the first email of this thread. I also attached a cs with a possible fix.
On Wed, May 19, 2010 at 4:35 PM, Stéphane Ducasse <[hidden email]> wrote: Yes this is an important bug _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Well, just to let you know, I've submitted a fix to PharoInbox:
Name: SLICE-superBugInParagraphEditor-carlaGriggio.1 Author: carlaGriggio Time: 24 May 2010, 2:33:50 am
UUID: 94ff9a49-b4ba-488b-9470-777e0f1885a7 Ancestors: SLICE-superBugInParagraphEditor-carlaGriggio.1 Dependencies: Compiler-carlaGriggio.212, CompilerTests-carlaGriggio.42, Kernel-carlaGriggio.665, ParagraphEditor-Test-carlaGriggio.1
But I can't change the status of the issue to fixed :P On Wed, May 19, 2010 at 4:51 PM, Carla F. Griggio <[hidden email]> wrote: Not the cs, I have an st. It's in the first email of this thread. I also attached a cs with a possible fix. _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
cool!
Stef On May 24, 2010, at 8:04 AM, Carla F. Griggio wrote: > Well, just to let you know, I've submitted a fix to PharoInbox: > > Name: SLICE-superBugInParagraphEditor-carlaGriggio.1 > Author: carlaGriggio > Time: 24 May 2010, 2:33:50 am > UUID: 94ff9a49-b4ba-488b-9470-777e0f1885a7 > Ancestors: SLICE-superBugInParagraphEditor-carlaGriggio.1 > Dependencies: Compiler-carlaGriggio.212, CompilerTests-carlaGriggio.42, Kernel-carlaGriggio.665, ParagraphEditor-Test-carlaGriggio.1 > > But I can't change the status of the issue to fixed :P > > On Wed, May 19, 2010 at 4:51 PM, Carla F. Griggio <[hidden email]> wrote: > Not the cs, I have an st. It's in the first email of this thread. I also attached a cs with a possible fix. > > > > On Wed, May 19, 2010 at 4:35 PM, Stéphane Ducasse <[hidden email]> wrote: > Yes this is an important bug > do you have the cs of your little example? > > Stef > > On May 19, 2010, at 9:17 PM, Carla F. Griggio wrote: > > > Just reproducing it would be helpful :O a friend of mine already > > tested the code I attatched and saw the same problem. > > > > If you recall having a class with a method sending a message to super, > > and a sublclass inheriting that method, you can try to reproduce it > > there too debugging that message on an instance of the subclass. > > > > It's not easy to explain with words, that's why I made a little > > package of code to illustrate the situation. > > > > The thing is that when printing the evaluation of a selected bunch of > > code inside a debugger window (paragraphEditor?), if the code you're > > evaluating is a message to super, and the class of the object you're > > debugging is inheriting the method you're debugging, the printed > > result will be wrong. In other words, the method lookup fails. > > > > This doesn't happen with normal excution of code (thank God!). > > > > I think this is an important bug, seeing those wrong results when > > debugging can be very confusing. I spent hours feeling stupid last > > Monday while debugging because I trusted those wrong results and > > couldn't see where I was doing something wrong :P > > > > Cheers! > > Carla > > > > On Wednesday, May 19, 2010, Mariano Martinez Peck <[hidden email]> wrote: > >> Hi Carla. I would like to help you, but I have no idea. I could reproduce it. > >> > >> Maybe Lukas, Igor, Eliot etc can help you. I have no idea. > >> > >> Cheers > >> > >> Mariano > >> > >> 2010/5/18 Carla F. Griggio <[hidden email]> > >> Hi everybody! > >> Well, maybe you are already aware of this... maybe not. I tried to find an issue about this and unless I didn't think of the right keywords, it's not there. > >> > >> > >> > >> I was debugging a template method and sudenly I found myself spending ours trying to find out why I got different results when printing the result of a message sent to super and when steping into that message and printing the (same) result there. > >> > >> > >> > >> Imagine this simple situation (I attatch the complete code and some tests so you can reproduce this): > >> AverageTotalization inherits from Totalization.WeightedAverageTotalization inherits from AverageTotalization. > >> > >> > >> > >> Totalization>>total > >> > >> ^self summatory > >> > >> > >> > >> > >> > >> AverageTotalization>>total > >> > >> ^(super total) / self denominator > >> > >> > >> > >> > >> > >> AverageTotalization>> denominator > >> > >> ^values size > >> > >> > >> > >> > >> WeightedAverageTotalization>> denominator > >> > >> "Weights is a dictionary" > >> > >> ^self weights values sum > >> > >> > >> > >> > >> If I debug aWeightedAverateTotalization total and try to print super total in the debugger ParagraphEditor, I'll get this result: > >> > >> > >> > >> (self summatory / self denominator) > >> > >> > >> instead of just: > >> self summatory > >> This only happens when I print or inspect or other do-its in the debugger window. The method lookup works OK when just _______________________________________________ > >> Pharo-project mailing list > >> [hidden email] > >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > >> > >> > > > > _______________________________________________ > > Pharo-project mailing list > > [hidden email] > > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Free forum by Nabble | Edit this page |