What's actually happening there is you're adding an empty statement after the function.
function test (o) { return o; };
could be seen as being similar to:
var test = 0;;
That second semicolon isn't an error per-se. The browser treats it like a statement where absolutely nothing happened.
There are two things to keep in mind, here.
This applies ONLY to function-declarations and control-blocks (for/if/while/switch/etc).
Function-declarations should be defined at the bottom of your scope, so you don't run into problems like this:
function test () {}
(function (window, document, undefined) { /* do stuff */ }(window, document));
Because the browser will assume that you mean function test() {}(/*return value of closure*/);
Which is an error. A very bad and nasty error which is very easy to overlook.
But that's okay, because function-declarations can go under return statements and still work just fine.
So even if you wanted to go:
function doStuff () {
return (function () { /*process stuff*/ test(); }());
function test () {}
}
That's going to work just peachy.