aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4codegen.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-05-21 15:10:45 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-05-21 18:03:47 +0200
commit3e716029ae61bf4c7bb33643ac331156e70e34f1 (patch)
tree2a2692dbaf49d87518c4b0da30078e177e8dd5c3 /src/qml/compiler/qv4codegen.cpp
parent9e919489c4e6b0c110281fda139fff84c1c71995 (diff)
Don't add local for anonymous function's "name"
Instead, populate their "name" property directly from the surrounding object pattern if applicable, without adding locals. This fixes some ecmascript tests where functions were assigned to the key "eval" in an object. The JS engine then rejected that because you shouldn't use eval in strict mode. That should be close enough to test for regressions. Fixes: QTBUG-75880 Change-Id: Iacc45a3f7b0eb90cddc6ecf6d2bada616d2cf355 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r--src/qml/compiler/qv4codegen.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 3fdba08f20..d2d913408a 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -1061,6 +1061,7 @@ bool Codegen::visit(Expression *ast)
TailCallBlocker blockTailCalls(this);
statement(ast->left);
blockTailCalls.unblock();
+ clearExprResultName(); // The name only holds for the left part
accept(ast->right);
return false;
}
@@ -2523,7 +2524,7 @@ bool Codegen::visit(ObjectPattern *ast)
{
RegisterScope innerScope(this);
- Reference value = expression(p->initializer);
+ Reference value = expression(p->initializer, name);
if (hasError)
return false;
value.loadInAccumulator();
@@ -2965,7 +2966,7 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast,
// already defined
return leaveContext();
- _context->name = name;
+ _context->name = name.isEmpty() ? currentExpr().result().name : name;
_module->functions.append(_context);
_context->functionIndex = _module->functions.count() - 1;