diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/compiler/qv4compilerscanfunctions.cpp | 2 | ||||
-rw-r--r-- | src/qml/parser/qqmljs.g | 2 | ||||
-rw-r--r-- | src/qml/parser/qqmljsast_p.h | 1 |
3 files changed, 4 insertions, 1 deletions
diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp index 6ca46fd362..a3bdce05d4 100644 --- a/src/qml/compiler/qv4compilerscanfunctions.cpp +++ b/src/qml/compiler/qv4compilerscanfunctions.cpp @@ -306,7 +306,7 @@ bool ScanFunctions::visit(PatternElement *ast) checkName(QStringRef(&name), ast->identifierToken); if (name == QLatin1String("arguments")) _context->usesArgumentsObject = Context::ArgumentsObjectNotUsed; - if (ast->scope == VariableScope::Const && !ast->initializer && !ast->destructuringPattern()) { + if (ast->scope == VariableScope::Const && !ast->initializer && !ast->isForDeclaration && !ast->destructuringPattern()) { _cg->throwSyntaxError(ast->identifierToken, QStringLiteral("Missing initializer in const declaration")); return false; } diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g index 8d85a006aa..e5ab6e5c5c 100644 --- a/src/qml/parser/qqmljs.g +++ b/src/qml/parser/qqmljs.g @@ -3180,6 +3180,7 @@ ForDeclaration: Var BindingIdentifier; auto *node = new (pool) AST::PatternElement(stringRef(2), nullptr); node->identifierToken = loc(2); node->scope = sym(1).scope; + node->isForDeclaration = true; sym(1).Node = node; } break; ./ @@ -3191,6 +3192,7 @@ ForDeclaration: Var BindingPattern; case $rule_number: { auto *node = new (pool) AST::PatternElement(sym(2).Pattern, nullptr); node->scope = sym(1).scope; + node->isForDeclaration = true; sym(1).Node = node; } break; ./ diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h index c74bf60a99..b69fb6272b 100644 --- a/src/qml/parser/qqmljsast_p.h +++ b/src/qml/parser/qqmljsast_p.h @@ -726,6 +726,7 @@ public: Type type = Literal; // when used in a VariableDeclarationList VariableScope scope = VariableScope::NoScope; + bool isForDeclaration = false; }; class QML_PARSER_EXPORT PatternElementList : public Node |