Weird Flash 8 compiler bug?
I haven’t delved into this in detail (so it could simply be an error on my part), but I had a function that returns a string. The string is long and complex, so my return statement looked something like this:
return 'string stuff' + ' more string stuff ' + someVariable + 'string stuff' + ' more string stuff' + ' more string stuff' /* ... about 20 lines of this ... */ + ' more string stuff';
The resulting function always returned undefined instead of the string.
Baffled, I changed the code to look like this:
var result:String = 'string stuff' + ' more string stuff ' + someVariable + 'string stuff' + ' more string stuff' + ' more string stuff' /* ... about 20 lines of this ... */ + ' more string stuff'; return result;
…and that worked as expected. Huh.



This is a Javascript misfeature: Javascript automatically inserts missing semicolons in some cases, and it is doing it here because of the newline after return.