Visual Studio 2008 “Format Document/Selection” command and a function named “assert” in JavaScript c
- by AGS777
Just have found some funny behavior of the Visual Studio 2008 editor. Sorry if it is already well known bug.
If you happened to have a JavaScript function named “assert” in your code (and there is pretty high likelihood in my opinion), for example something like:
function assert(x, message) {
if (x) console.log(message);
}
then when either Format Document (Ctrl + K, Ctrl + D) or Format Selection (Ctrl + K, Ctrl + F) command is applied to the document/block containing the function, the result of the formatting will be:
functionassert(x, message) {
if (x) console.log(message);
}
That’s it. function and assert are now joined into one solid word.
So be aware of the fact in case you suddenly start receiving strange exception in your JavaScript code: missing ; before statement functionassert(x, message)
And no, it is not an April Fool's joke. Just try for yourself.