Inderterministic javascript IF sentence..



  •  Step by step trace on javascript with firebug..

     trace



  • I call foul. Firebug lets you jump up and down like a monkey if you wish. However, does in-lining the two statements make it work? Sometimes Firefox's JS interpreter goes bonkers. I trust V8 more now.



  • Perhaps you should explain the WTF.



  • @morbiuswilters said:

    Perhaps you should explain the WTF.
    It executes a line in the if {} block and then something in the else {} block.  Ironically, it's two lines that flip the value of the same variable.



  •  Are yopu sure this isn't just Firebug screwing up and hilighting the wrong line?  I think it's wanting to hilight line 362 to tell you it's breaking out of the if.

    Little known fact: Firebug is kind of buggy.

    But it's still way better than any alternatives.



  • @belgariontheking said:

    @morbiuswilters said:

    Perhaps you should explain the WTF.
    It executes a line in the if {} block and then something in the else {} block.  Ironically, it's two lines that flip the value of the same variable.

    Right, which is pretty common when toggling a variable.  Is there an actual WTF here?  Glancing at the code, I don't see anything weird, but figured the WTF might have been more subtle (in which case it should have been explained better) or had something to do with Firebug and/or the highlighting (I don't use Firebug, so I have no idea if that's the case).



  • @morbiuswilters said:

    @belgariontheking said:

    @morbiuswilters said:

    Perhaps you should explain the WTF.
    It executes a line in the if {} block and then something in the else {} block.  Ironically, it's two lines that flip the value of the same variable.

    Right, which is pretty common when toggling a variable.  Is there an actual WTF here?  Glancing at the code, I don't see anything weird, but figured the WTF might have been more subtle (in which case it should have been explained better) or had something to do with Firebug and/or the highlighting (I don't use Firebug, so I have no idea if that's the case).

     

    Are you aware that the screen shot is actually 3 stages of a time-series of debugging steps in the same 7-line snippet, as opposed to one continuous block of code?

    It's executing the if-block, and then it's (apparently) executing the exact same else-block, implying that the condition is both true and false.



  • @vt_mruhlin said:

     Are yopu sure this isn't just Firebug screwing up and hilighting the wrong line?  I think it's wanting to hilight line 362 to tell you it's breaking out of the if.

    Little known fact: Firebug is kind of buggy.

    But it's still way better than any alternatives.

     

    I'm suspecting this. I've seen lots of IDEs highlight the wrong line, especially lines at or near the "terminating" brace of a block.  It's generally because braces do not produce executable breakpoints, so the IDE picks the source code of the line with the closest exectuable address. I wouldn't necessarily call it a "bug" though.



  • @Aaron said:

    Are you aware that the screen shot is actually 3 stages of a time-series of debugging steps in the same 7-line snippet, as opposed to one continuous block of code?

    It's executing the if-block, and then it's (apparently) executing the exact same else-block, implying that the condition is both true and false.

    Ah, I realized it was three different views of the same block, but didn't understand why the highlighting was a problem.  As I said, the OP really could have explained what was going on rather than just posting a screenshot and assuming everyone else could hear what the voices in his head were saying.



  •  The debugger's "code -> line number" reference got off-by-one. The third highlight should be on the end brace. AFAICT.



  • @vt_mruhlin said:

     Are yopu sure this isn't just Firebug screwing up and hilighting the wrong line?  I think it's wanting to hilight line 362 to tell you it's breaking out of the if.

    Little known fact: Firebug is kind of buggy.

    But it's still way better than any alternatives.

     

    I'm going to be "that guy", but have you used the JS debugger in IE8?



  •  @blakeyrat said:

    I'm going to be "that guy", but have you used the JS debugger in IE8?

    Yeah, my favorite was the time it told me there was an error on line 3,000,000 of a 1,000 line file.



  • @vt_mruhlin said:

     @blakeyrat said:

    I'm going to be "that guy", but have you used the JS debugger in IE8?

    Yeah, my favorite was the time it told me there was an error on line 3,000,000 of a 1,000 line file.

     

    Well... was there?



  • @blakeyrat said:

    @vt_mruhlin said:

     @blakeyrat said:

    I'm going to be "that guy", but have you used the JS debugger in IE8?

    Yeah, my favorite was the time it told me there was an error on line 3,000,000 of a 1,000 line file.

     

    Well... was there?

     

     

    Obviously. IE wanted him to stop slacking and finish his project! The error was that he didn't write 3,000,000 lines yet!



  • @bob171123 said:

    @blakeyrat said:

    @vt_mruhlin said:

     @blakeyrat said:

    I'm going to be "that guy", but have you used the JS debugger in IE8?

    Yeah, my favorite was the time it told me there was an error on line 3,000,000 of a 1,000 line file.

     

    Well... was there?

     

     

    Obviously. IE wanted him to stop slacking and finish his project! The error was that he didn't write 3,000,000 lines yet!

    It's a predictive compiler.  It knew that when he got around to finishing it, he was going to have an error.


  • @bstorer said:

    @bob171123 said:

    @blakeyrat said:

    @vt_mruhlin said:

     @blakeyrat said:

    I'm going to be "that guy", but have you used the JS debugger in IE8?

    Yeah, my favorite was the time it told me there was an error on line 3,000,000 of a 1,000 line file.

     

    Well... was there?

     

     

    Obviously. IE wanted him to stop slacking and finish his project! The error was that he didn't write 3,000,000 lines yet!

    It's a predictive compiler.  It knew that when he got around to finishing it, he was going to have an error.

    What's impressive is that he made it 3,000,000 lines until his first error.



  • @morbiuswilters said:

    What's impressive is that he made it 3,000,000 lines until his first error.

    IE is like the Duracell bunny. It likes to keep running, and running, and running.

    Had to fix one of these the other day...

     



  • @morbiuswilters said:

    @bstorer said:

    @bob171123 said:

    @blakeyrat said:

    @vt_mruhlin said:

     @blakeyrat said:

    I'm going to be "that guy", but have you used the JS debugger in IE8?

    Yeah, my favorite was the time it told me there was an error on line 3,000,000 of a 1,000 line file.

     

    Well... was there?

     

     

    Obviously. IE wanted him to stop slacking and finish his project! The error was that he didn't write 3,000,000 lines yet!

    It's a predictive compiler.  It knew that when he got around to finishing it, he was going to have an error.

    What's impressive is that he made it 3,000,000 lines until his first error.

    Not really.  He just needed a variable with the value of 2,999,000, so he copy-pasted the line "++val;" over and over.


  • @bstorer said:

    @morbiuswilters said:

    @bstorer said:

    @bob171123 said:

    @blakeyrat said:

    @vt_mruhlin said:

     @blakeyrat said:

    I'm going to be "that guy", but have you used the JS debugger in IE8?

    Yeah, my favorite was the time it told me there was an error on line 3,000,000 of a 1,000 line file.

     

    Well... was there?

     

     

    Obviously. IE wanted him to stop slacking and finish his project! The error was that he didn't write 3,000,000 lines yet!

    It's a predictive compiler.  It knew that when he got around to finishing it, he was going to have an error.

    What's impressive is that he made it 3,000,000 lines until his first error.

    Not really.  He just needed a variable with the value of 2,999,000, so he copy-pasted the line "++val;" over and over.

    More likely he just re-typed it that many times, and made a typo the 2,999,000th time.


Log in to reply