diff options
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 9 |
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; |