Projects
openEuler:Mainline
nodejs-acorn
_service:tar_scm:fix-test-errors.patch
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:fix-test-errors.patch of Package nodejs-acorn
From 42f637999c916455f0fbbeb10e2770b00fdf9c41 Mon Sep 17 00:00:00 2001 From: Teddy Katz <teddy.katz@gmail.com> Date: Sat, 3 Mar 2018 03:03:53 -0500 Subject: [PATCH] Fix misleading error message for octal escapes in template strings This updates the error message for something like `\033` to include something about template strings, rather than claiming that the error is due to strict mode. --- src/tokenize.js | 7 ++++++- test/tests-harmony.js | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/tokenize.js b/src/tokenize.js index 3dbaf67f..3afb8386 100644 --- a/src/tokenize.js +++ b/src/tokenize.js @@ -628,7 +628,12 @@ pp.readEscapedChar = function(inTemplate) { this.pos += octalStr.length - 1 ch = this.input.charCodeAt(this.pos) if ((octalStr !== "0" || ch == 56 || ch == 57) && (this.strict || inTemplate)) { - this.invalidStringToken(this.pos - 1 - octalStr.length, "Octal literal in strict mode") + this.invalidStringToken( + this.pos - 1 - octalStr.length, + inTemplate + ? "Octal literal in template string" + : "Octal literal in strict mode" + ) } return String.fromCharCode(octal) } diff --git a/test/tests-harmony.js b/test/tests-harmony.js index 3f9b4014..775106fa 100644 --- a/test/tests-harmony.js +++ b/test/tests-harmony.js @@ -13281,7 +13281,7 @@ testFail("[...a, b] = c", "Comma is not permitted after the rest element (1:5)", testFail("({ t(eval) { \"use strict\"; } });", "Binding eval in strict mode (1:5)", {ecmaVersion: 6}); -testFail("\"use strict\"; `${test}\\02`;", "Octal literal in strict mode (1:22)", {ecmaVersion: 6}); +testFail("\"use strict\"; `${test}\\02`;", "Octal literal in template string (1:22)", {ecmaVersion: 6}); testFail("if (1) import \"acorn\";", "'import' and 'export' may only appear at the top level (1:7)", {ecmaVersion: 6}); @@ -14591,7 +14591,9 @@ test("export default function foo() {} false", { // https://github.com/acornjs/acorn/issues/274 -testFail("`\\07`", "Octal literal in strict mode (1:1)", {ecmaVersion: 6}); +testFail("`\\07`", "Octal literal in template string (1:1)", {ecmaVersion: 6}); + +testFail("(function(){ 'use strict'; '\\07'; })", "Octal literal in strict mode (1:28)", {ecmaVersion: 6}); // https://github.com/acornjs/acorn/issues/277
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2