summaryrefslogtreecommitdiff
path: root/src/qml/compiler/qv4compilerscanfunctions.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-02-10 19:17:40 +0100
committerLars Knoll <lars.knoll@qt.io>2018-04-25 17:49:21 +0000
commit31026b2e83ac338ebfb59ce0fede268e9ce51fed (patch)
tree0a9bdf078db659cbed8c923bc04c8b6352bdf925 /src/qml/compiler/qv4compilerscanfunctions.cpp
parent219485d898556368a833576f1c55e210c1cf7189 (diff)
downloadqtdeclarative-31026b2e83ac338ebfb59ce0fede268e9ce51fed.tar.gz
Correctly check for duplicate parameter names
Those are not allowed as soon as we have default values for parameters or rest arguments. Change-Id: I7dec826c37e6045e4dd1f6b0adb90301efe33daf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compilerscanfunctions.cpp')
-rw-r--r--src/qml/compiler/qv4compilerscanfunctions.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp
index f985c74f9d..8824a47def 100644
--- a/src/qml/compiler/qv4compilerscanfunctions.cpp
+++ b/src/qml/compiler/qv4compilerscanfunctions.cpp
@@ -431,12 +431,14 @@ void ScanFunctions::enterFunction(Node *ast, const QString &name, FormalParamete
if (body && !_context->isStrict)
checkDirectivePrologue(body->elements);
+ bool isSimpleParameterList = formals->isSimpleParameterList();
+
for (FormalParameterList *it = formals; it; it = it->next) {
QString arg = it->name.toString();
int duplicateIndex = _context->arguments.indexOf(arg);
if (duplicateIndex != -1) {
- if (_context->isStrict) {
- _cg->throwSyntaxError(it->identifierToken, QStringLiteral("Duplicate parameter name '%1' is not allowed in strict mode").arg(arg));
+ if (_context->isStrict || !isSimpleParameterList) {
+ _cg->throwSyntaxError(it->identifierToken, QStringLiteral("Duplicate parameter name '%1' is not allowed.").arg(arg));
return;
} else {
// change the name of the earlier argument to enforce the specified lookup semantics