summaryrefslogtreecommitdiff
path: root/src/qml/compiler/qv4codegen.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-09-04 14:49:49 +0200
committerLars Knoll <lars.knoll@qt.io>2018-09-07 10:31:45 +0000
commitee3d935a8b45576a237c74fd453fb0810f30f574 (patch)
tree4de5e0829d6159f9020f8abd549f59fce94a6236 /src/qml/compiler/qv4codegen.cpp
parentd71df8db162ff8b4d6bd1833c088024b8870b02c (diff)
downloadqtdeclarative-ee3d935a8b45576a237c74fd453fb0810f30f574.tar.gz
Fix new.target access from eval()
Change-Id: I1855eb303225d1784b019f8eebab0ad8bf2cdf5e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r--src/qml/compiler/qv4codegen.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index d61f79f0fc..cbe935c5cd 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -2143,10 +2143,15 @@ bool Codegen::visit(FieldMemberExpression *ast)
if (AST::IdentifierExpression *id = AST::cast<AST::IdentifierExpression *>(ast->base)) {
if (id->name == QLatin1String("new")) {
// new.target
- if (ast->name != QLatin1String("target")) {
- throwSyntaxError(ast->identifierToken, QLatin1String("Expected 'target' after 'new.'."));
+ Q_ASSERT(ast->name == QLatin1String("target"));
+
+ if (_context->isArrowFunction || _context->contextType == ContextType::Eval) {
+ Reference r = referenceForName(QStringLiteral("new.target"), false);
+ r.isReadonly = true;
+ _expr.setResult(r);
return false;
}
+
Reference r = Reference::fromStackSlot(this, CallData::NewTarget);
_expr.setResult(r);
return false;