diff --git a/es2panda/ir/expressions/templateLiteral.cpp b/es2panda/ir/expressions/templateLiteral.cpp index 1a66c3b81a0b807c91c7e7681c5ec7457792f25f..202b21dd3b6bf233f890d5d4333d117398380730 100644 --- a/es2panda/ir/expressions/templateLiteral.cpp +++ b/es2panda/ir/expressions/templateLiteral.cpp @@ -43,7 +43,7 @@ void TemplateLiteral::Compile(compiler::PandaGen *pg) const auto quasisIt = quasis_.begin(); auto expressionIt = expressions_.begin(); - pg->LoadAccumulatorString(this, (*quasisIt)->Raw()); + pg->LoadAccumulatorString(this, (*quasisIt)->Cooked()); quasisIt++; @@ -58,7 +58,7 @@ void TemplateLiteral::Compile(compiler::PandaGen *pg) const if (isQuais) { pg->StoreAccumulator(*quasisIt, lhs); - pg->LoadAccumulatorString(this, (*quasisIt)->Raw()); + pg->LoadAccumulatorString(this, (*quasisIt)->Cooked()); node = *quasisIt; quasisIt++; diff --git a/es2panda/test/compiler/js/language/literals/special-character-expected.txt b/es2panda/test/compiler/js/language/literals/special-character-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c54b773db3ce3a1ae4668f0ef7225848e1db8461 --- /dev/null +++ b/es2panda/test/compiler/js/language/literals/special-character-expected.txt @@ -0,0 +1,9 @@ +test + +test + +test +test' +test" +test? +test diff --git a/es2panda/test/compiler/js/language/literals/special-character.js b/es2panda/test/compiler/js/language/literals/special-character.js new file mode 100644 index 0000000000000000000000000000000000000000..7ced4fee80403403446864a7311ea273a8fbd8e7 --- /dev/null +++ b/es2panda/test/compiler/js/language/literals/special-character.js @@ -0,0 +1,13 @@ +function test() { + let a = "test\n"; + print(a); + let b = "test"; + print(`${b}\n`); + print(`${b}\t`); + print(`${b}\'`); + print(`${b}\"`); + print(`${b}\?`); + print(`${b}\0`); +} + +test(); \ No newline at end of file