Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block not accepted after label; error suggests it should be #338

Open
ojwb opened this issue Sep 15, 2015 · 0 comments
Open

Block not accepted after label; error suggests it should be #338

ojwb opened this issue Sep 15, 2015 · 0 comments

Comments

@ojwb
Copy link
Contributor

ojwb commented Sep 15, 2015

Compiling the follow code (verified using http://jsx.github.io/try-on-web/):

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant