Weird Flash 8 compiler bug?

November 9th, 2007 § 2 comments

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.

§ 2 Responses to Weird Flash 8 compiler bug?"

  • Jake says:

    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.

  • bunnyhero says:

    Aha, I see! I keep forgetting how JavaScript allows you to leave out semicolons.

What's this?

You are currently reading Weird Flash 8 compiler bug? at bunnyhero dev.

meta