The baffling case of 0x1D and the mysterious syntax error

I love syntax errors. Actually, I love all compilation errors. They're always welcome because, unlike run-time errors, they are usually easy to pinpoint and fix. Not this time though. I present to you the baffling case of the syntax error that wasn't.

It all began not too many keystrokes ago, while porting some old code to ActionScript 2. After running the test, I got a syntax error pointing me to a closing brace. This was going to be easy -- I missed a brace somewhere. It happens! Child's play! Not so, it would appear... After some frantic "CTRL-M"ing in PrimalScript (match brace), I found that all the braces matched. Oh, oh!

Not to be deterred, the code was dutifully copied from the AS file to an empty FLA and stripped to the bare minimum that triggered the error, which left me with:

  1. if ( true ) {}

What the..? Hmm, ok, so let's try some voodoo... hey, what do you know? Deleting the empty space after the second brace fixed the issue, so it was an invisible character messing things up. Using Hexmode in Primalscript revealed the culprit: right after the 0x7D character (right brace) was a sneaky little 0x1D character which I learned is a group separator left over from the days of teletypes.

I have no idea how it managed to sneek in there (me and and fat fingers, no doubt) but one thing is for sure: Flash chokes on it. So, the next time you get a weird error that reduces to something so simple that you know that it must work, take out your trusty hex editor and hunt for our sneeky little friend, 1D :)

Download the FLA (.zip; 5kb) and see for yourself (please note this is only recommended for those of you who are (A) True geeks, (B) have too much time on your hands or (C) keep exotic FLA collections -- in which case I would seriously urge you to reconsider whether or not you fit into group A. My goodness, I wonder which category I fall into with this post!

Oh yes, and happy holidays! :)