google / google/closure-compiler
JSCompiler does not properly handle escaped backslash in tagged template literal
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
Using a tagged template literal with an escaped backslash causes both backslashes to be passed to the template function, instead of just the single backslash. The raw property contains both backslashes as expected.
For example
```
test`\\.`
compiled to: test({0: "\\\\.", raw: "\\\\."})
expected: test({0: "\\.", raw: "\\\\."})
```
However, other escape sequences work as expected
```
test`\n.`
compiled to: test({0: "\n.", raw: "\\n."})
```
https://closure-compiler-debugger.appspot.com/#input0%3Dfunction%2520test(...args)%2520%257B%250A%2520%2520console.log(args)%253B%250A%257D%250A%250Atest%2560%255C%255C.%2560%250Atest%2560%255Cn.%2560%26input1%26conformanceConfig%26externs%26refasterjs-template%26includeDefaultExterns%3D1%26CHECK_SYMBOLS%3D1%26MISSING_PROPERTIES%3D1%26TRANSPILE%3D1%26CHECK_TYPES%3D1%26CLOSURE_PASS%3D1%26PRESERVE_TYPE_ANNOTATIONS%3D1%26PRETTY_PRINT%3D1
Contributor guide
Assessment
This issue has not been assessed yet.