Given something like
var obj = {
foo: function(){
try{
doSomething();
}catch(ex){
//@TODO - report error
}
}
}
MSIE 8 would throw up a “Missing semi-colon on line #” which was where the @TODO was.
After I sed’d the dozens of @TODO’s to be !TODO, MSIE was able to properly parse the script and life went on. Am I missing something here, does MSIE use some sort of non-standard mechanism like //@PRAGMA ?
Googling for @TODO or //@ didn’t bring up anything useful.
This is to do with conditional compilation, an IE-only invention for varying JScript (IE’s name for their flavour of ECMAScript) compilation based on information about the browser and environment. The syntax involves the
@symbol followed by a string to make up a variable, directive or statement. In this case, the presence of@TODOdirectly after the start of a comment is causing the comment text to be interpreted as a conditional compilation statement, with@TODObeing a conditional compilation variable (with a value ofNaN: see http://msdn.microsoft.com/en-us/library/k0h7dyd7%28v=VS.80%29.aspx).Conditional compilation statements are generally contained within JavaScript comments: these are there to prevent other browsers from attempting to interpret the code but are not in fact required to trigger conditional compilation. The MSDN documentation is here:
http://msdn.microsoft.com/en-us/library/ahx1z4fs%28v=VS.80%29.aspx
This feature is only enabled for code that appears after conditional compilation is enabled, which is achieved with
Therefore if you can find this line and remove it then your
//@TODO - report errorwill be fine as it is. However, some of your code may rely on conditional compilation so this may not be an option. A workaround is to insert a space between the start of the comment (either//or/*) and the@symbol:Microsoft’s documentation is not clear enough to know why this works, since conditional compilation variables also work outside comments:
Therefore the safest option would be to avoid use of
@TODOaltogether.