Script Editor 2.0: opening scripts that end with a one-line 'if'

Script Editor 2.0 won’t open a compiled script file on the first attempt if the last line of the script is a one-line ‘if’ statement and one or more of the following is true:

The ‘if’ condition is an expression rather than a direct boolean value, or:
The conditionally executed code contains another ‘if’ statement, or:
The conditionally executed code contains an application specifier.

The file opens on the second attempt, but the resulting Script Editor window has the name “Window” instead of the name of the file.

If the text of such a script has not yet been compiled, or has not yet been recompiled after an edit, running it in Script Editor 2.0 (if that’s something you’re likely to do) only effects the compilation. A second Run is needed to run it.

Work-rounds include:

Rewriting the last line of the script as a multi-line statement.
Splitting the line with a continuation character.
Putting a comment line or more than one blank line after the last line.

This bug is only known to affect Script Editor 2.0 and its sub-versions and has existed since the days of Jaguar.

Thanks to Sean Zhu for noticing the problem and raising it in the OS X forum.