class _Main {
static function main(args :string[]) : void {
lab: {
log 42;
}
}
}
Gives the rather unhelpful error:
ERROR!
[source-map/add.jsx:3:9] only blocks, iteration statements, and switch statements are allowed after a label
lab: {
^
[source-map/add.jsx:7:0] expected keyword: class interface mixin abstract final native __fake__ __export__
}
^
Looking at the compiler source, the check is:
var token = this._expectOpt([
"{", "var", ";", "if", "do", "while", "for", "continue", "break", "return", "switch", "throw", "try", "assert", "log", "delete", "debugger", "function", "void", "const"
]);
if (label != null) {
if (! (token != null && token.getValue().match(/^(?:do|while|for|switch)$/) != null)) {
this._newError("only blocks, iteration statements, and switch statements are allowed after a label");
return false;
}
}
So the check doesn't allow {. Either the check or the error message is incorrect.
Compiling the follow code (verified using http://jsx.github.io/try-on-web/):
Gives the rather unhelpful error:
Looking at the compiler source, the check is:
So the check doesn't allow
{
. Either the check or the error message is incorrect.