Note that there are some explanatory texts on larger screens.

plurals
  1. PONode doesn't allow if statements without braces?
    primarykey
    data
    text
    <p>Something strange is happening. I just upgraded to node v0.10.18.. One of my tests was failing at an unexpected place.. And it looks like I can't do if statements without braces any more.</p> <pre><code>if(false) console.log('shouldn't be printed'); </code></pre> <p>In the above, example the text will be printed even though the if statement failed. But not printed in the following tests;</p> <pre><code>if(false) { console.log('shouldn't be printed'); } if(false) console.log('shouldn't be printed'); </code></pre> <p>Is there something I'm missing, has this always been this way with node? </p> <p><strong>EDIT</strong>: I just noticed this only happens when using <strong>mocha</strong>. Code runs ok in node. Any ideas how this could be happening using mocha?</p> <p><strong>EDIT2</strong>: Thanks for the answers guys, my example was simple, and in reality mocha digs down into files in my directory but when I'm stepping through the code using node-inspector, I see that even those the if statement evaluates to false, it goes into the next line and executes the callback line, which breaks my call. I can't recreate it anywhere else but I'm dumbfounded about how it's happening</p> <p><strong>EDIT3</strong>: Alright guys, I can't recreate this issue other than tell you where i see it happening. I was just trying to do my contribution to an open source project here <a href="https://github.com/jugglingdb/mysql-adapter" rel="nofollow">https://github.com/jugglingdb/mysql-adapter</a> And in the lib/mysql, towards the last lines (10 lines up or so)(linked below) where it checks for filter.where and filter.update, that's where the issue is happening. Tests will pass if i add braces and won't if I don't</p> <p><a href="https://github.com/jugglingdb/mysql-adapter/blob/master/lib/mysql.js" rel="nofollow">https://github.com/jugglingdb/mysql-adapter/blob/master/lib/mysql.js</a> Line 890 here</p> <p>Test where it gets executed: <a href="https://github.com/jugglingdb/mysql-adapter/blob/master/test/migration.test.js" rel="nofollow">https://github.com/jugglingdb/mysql-adapter/blob/master/test/migration.test.js</a> line 291.. It's not there but the check for err will return the error that line 890 is throwing</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload