From ee3d935a8b45576a237c74fd453fb0810f30f574 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 4 Sep 2018 14:49:49 +0200 Subject: Fix new.target access from eval() Change-Id: I1855eb303225d1784b019f8eebab0ad8bf2cdf5e Reviewed-by: Simon Hausmann --- src/qml/compiler/qv4compilercontext.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/qml/compiler/qv4compilercontext.cpp') diff --git a/src/qml/compiler/qv4compilercontext.cpp b/src/qml/compiler/qv4compilercontext.cpp index 1b4c084ab4..551467f95c 100644 --- a/src/qml/compiler/qv4compilercontext.cpp +++ b/src/qml/compiler/qv4compilercontext.cpp @@ -248,6 +248,13 @@ void Context::emitBlockHeader(Codegen *codegen) Codegen::Reference r = codegen->referenceForName(QStringLiteral("this"), true); r.storeConsumeAccumulator(); } + if (innerFunctionAccessesNewTarget) { + Instruction::LoadReg load; + load.reg = CallData::NewTarget; + bytecodeGenerator->addInstruction(load); + Codegen::Reference r = codegen->referenceForName(QStringLiteral("new.target"), true); + r.storeConsumeAccumulator(); + } if (contextType == ContextType::Global || (contextType == ContextType::Eval && !isStrict)) { // variables in global code are properties of the global context object, not locals as with other functions. -- cgit v1.2.3