aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-06-06 09:02:53 +0200
committerLars Knoll <lars.knoll@qt.io>2018-06-21 13:30:53 +0000
commit77cb60e0c071f9762f565f1f38859421c928dd4a (patch)
tree5e42f0989bf3908beeccc3fe122302f8367f9b8f /src
parent45d39a1685e72975dd9bd4d3e4a67aab59eeae48 (diff)
Fix const expressions containing destructuring patterns
Don't throw a syntax error when encountering a destructuring pattern. Change-Id: I93250a2963d2d50ff61d725229e1b51be17689e9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/compiler/qv4compilerscanfunctions.cpp2
-rw-r--r--src/qml/parser/qqmljs.g1
2 files changed, 1 insertions, 2 deletions
diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp
index 639728df52..68cb58da46 100644
--- a/src/qml/compiler/qv4compilerscanfunctions.cpp
+++ b/src/qml/compiler/qv4compilerscanfunctions.cpp
@@ -177,7 +177,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) {
+ if (ast->scope == VariableScope::Const && !ast->initializer && !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 f927473e53..7928881d8c 100644
--- a/src/qml/parser/qqmljs.g
+++ b/src/qml/parser/qqmljs.g
@@ -3209,7 +3209,6 @@ ForDeclaration: Var BindingPattern;
/.
case $rule_number: {
auto *node = new (pool) AST::PatternElement(sym(2).Pattern, nullptr);
- node->identifierToken = loc(2);
node->scope = sym(1).scope;
sym(1).Node = node;
} break;