The function call operator () is one of the most straightforward, well-understood, and universal operators in all of programming. Let’s see how AS3 can butcher it:

First, the obvious correct usage:


Nothing could be simpler! The above calls the function foo and passes no arguments. Now let’s see some craziness. Seriously, get ready for a freak show:

({first:"John", last:"Smith", age:33})();
(new Sprite())();

Every one of the above is clearly not a function. This should be extremely obvious to the compiler. All of these are literals! You may have to parenthesize, but every one of these will compile without any errors or warnings. At runtime, you get:

TypeError: Error #1006

You can also do this:


It compiles without errors or warnings, but you get a different runtime error:

ArgumentError: Error #1112

It’s absolutely beyond me that any of these should compile, especially without a warning. I found out about one of these due to a typo that took me a while to track down. I was so shocked I just had to see what else I could get away with. I found the rest of this even more shocking. Be vigilant with your parentheses!