aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compilerscanfunctions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/compiler/qv4compilerscanfunctions.cpp')
-rw-r--r--src/qml/compiler/qv4compilerscanfunctions.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp
index 4c8f0d0658..c4f46ecf05 100644
--- a/src/qml/compiler/qv4compilerscanfunctions.cpp
+++ b/src/qml/compiler/qv4compilerscanfunctions.cpp
@@ -330,9 +330,13 @@ bool ScanFunctions::visit(PatternElement *ast)
BoundNames names;
ast->boundNames(&names);
- QQmlJS::SourceLocation lastInitializerLocation = ast->lastSourceLocation();
- if (_context->lastBlockInitializerLocation.isValid())
- lastInitializerLocation = _context->lastBlockInitializerLocation;
+ QQmlJS::SourceLocation declarationLocation = ast->firstSourceLocation();
+ if (_context->lastBlockInitializerLocation.isValid()) {
+ declarationLocation.length = _context->lastBlockInitializerLocation.end()
+ - declarationLocation.offset;
+ } else {
+ declarationLocation.length = ast->lastSourceLocation().end() - declarationLocation.offset;
+ }
for (const auto &name : qAsConst(names)) {
if (_context->isStrict && (name.id == QLatin1String("eval") || name.id == QLatin1String("arguments")))
@@ -345,7 +349,7 @@ bool ScanFunctions::visit(PatternElement *ast)
return false;
}
if (!_context->addLocalVar(name.id, ast->initializer ? Context::VariableDefinition : Context::VariableDeclaration, ast->scope,
- /*function*/nullptr, lastInitializerLocation)) {
+ /*function*/nullptr, declarationLocation)) {
_cg->throwSyntaxError(ast->identifierToken, QStringLiteral("Identifier %1 has already been declared").arg(name.id));
return false;
}