Check for duplicated label statements as to 12.12 of the spec
authorLars Knoll <lars.knoll@digia.com>
Fri, 14 Jun 2013 09:18:12 +0000 (11:18 +0200)
committerSimon Hausmann <simon.hausmann@digia.com>
Fri, 14 Jun 2013 10:05:22 +0000 (12:05 +0200)
Change-Id: Ia2ccddef08a2b3dedd46c509a8693d52dc472982
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/qml/v4/qv4codegen.cpp

index f5868b1..77c4610 100644 (file)
@@ -2158,6 +2158,15 @@ bool Codegen::visit(IfStatement *ast)
 
 bool Codegen::visit(LabelledStatement *ast)
 {
+    // check that no outer loop contains the label
+    Loop *l = _loop;
+    while (l) {
+        if (l->labelledStatement->label == ast->label) {
+            QString error = QString(QStringLiteral("Label '%1' has already been declared")).arg(ast->label.toString());
+            throwSyntaxError(ast->firstSourceLocation(), error);
+        }
+        l = l->parent;
+    }
     _labelledStatement = ast;
 
     if (AST::cast<AST::SwitchStatement *>(ast->statement) ||