diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 295ce08071..ac596e2b5b 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -2260,8 +2260,6 @@ int Codegen::createTemplateArray(TemplateLiteral *t) { int arrayTemp = bytecodeGenerator->newRegister(); - RegisterScope scope(this); - int argc = 0; int args = -1; auto push = [this, &argc, &args](const QStringRef &arg) { @@ -2278,22 +2276,50 @@ int Codegen::createTemplateArray(TemplateLiteral *t) ++argc; }; - for (TemplateLiteral *it = t; it; it = it->next) - push(it->value); + { + RegisterScope scope(this); - if (args == -1) { - Q_ASSERT(argc == 0); - args = 0; + for (TemplateLiteral *it = t; it; it = it->next) + push(it->value); + + if (args == -1) { + Q_ASSERT(argc == 0); + args = 0; + } + + Instruction::DefineArray call; + call.argc = argc; + call.args = Moth::StackSlot::createRegister(args); + bytecodeGenerator->addInstruction(call); + + Instruction::StoreReg store; + store.reg = arrayTemp; + bytecodeGenerator->addInstruction(store); } - Instruction::DefineArray call; - call.argc = argc; - call.args = Moth::StackSlot::createRegister(args); - bytecodeGenerator->addInstruction(call); + { + RegisterScope scope(this); - Instruction::StoreReg store; - store.reg = arrayTemp; - bytecodeGenerator->addInstruction(store); + argc = 0; + args = -1; + + for (TemplateLiteral *it = t; it; it = it->next) + push(it->rawValue); + + if (args == -1) { + Q_ASSERT(argc == 0); + args = 0; + } + + Instruction::DefineArray call; + call.argc = argc; + call.args = Moth::StackSlot::createRegister(args); + bytecodeGenerator->addInstruction(call); + + Reference a = Reference::fromStackSlot(this, arrayTemp); + Reference m = Reference::fromMember(a, QStringLiteral("raw")); + m.storeConsumeAccumulator(); + } return arrayTemp; } diff --git a/tests/auto/qml/ecmascripttests/TestExpectations b/tests/auto/qml/ecmascripttests/TestExpectations index 1613888e77..d51b45b75c 100644 --- a/tests/auto/qml/ecmascripttests/TestExpectations +++ b/tests/auto/qml/ecmascripttests/TestExpectations @@ -224,10 +224,6 @@ built-ins/String/prototype/toLocaleLowerCase/Final_Sigma_U180E.js fails built-ins/String/prototype/toLocaleLowerCase/special_casing_conditional.js fails built-ins/String/prototype/toLowerCase/Final_Sigma_U180E.js fails built-ins/String/prototype/toLowerCase/special_casing_conditional.js fails -built-ins/String/raw/return-the-string-value-from-template.js fails -built-ins/String/raw/special-characters.js fails -built-ins/String/raw/template-substitutions-are-appended-on-same-index.js fails -built-ins/String/raw/zero-literal-segments.js fails built-ins/TypedArray/from/arylk-get-length-error.js fails built-ins/TypedArray/from/arylk-to-length-error.js fails built-ins/TypedArray/from/iter-access-error.js fails @@ -580,19 +576,7 @@ language/expressions/tagged-template/tco-member.js strictFails language/expressions/tagged-template/template-object-frozen-non-strict.js sloppyFails language/expressions/tagged-template/template-object-frozen-strict.js strictFails language/expressions/tagged-template/template-object.js fails -language/expressions/template-literal/tv-character-escape-sequence.js fails -language/expressions/template-literal/tv-hex-escape-sequence.js fails -language/expressions/template-literal/tv-line-continuation.js fails -language/expressions/template-literal/tv-line-terminator-sequence.js fails -language/expressions/template-literal/tv-no-substitution.js fails language/expressions/template-literal/tv-null-character-escape-sequence.js fails -language/expressions/template-literal/tv-template-character.js fails -language/expressions/template-literal/tv-template-characters.js fails -language/expressions/template-literal/tv-template-head.js fails -language/expressions/template-literal/tv-template-middle.js fails -language/expressions/template-literal/tv-template-tail.js fails -language/expressions/template-literal/tv-utf16-escape-sequence.js fails -language/expressions/template-literal/tv-zwnbsp.js fails language/function-code/each-param-has-own-non-shared-eval-scope.js sloppyFails language/function-code/each-param-has-own-scope.js sloppyFails language/function-code/eval-param-env-with-computed-key.js sloppyFails