From fb2f8d1a512e5bb8f6b4281d09bbf71fc9a75f23 Mon Sep 17 00:00:00 2001 From: Anthony Van de Gejuchte Date: Mon, 27 Jun 2016 01:17:53 +0200 Subject: [PATCH] Add reserved words to list unescapable keywords Additionals: * Update list reserved keywords --- lib/parse.js | 5 ++--- test/mocha/unicode.js | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/parse.js b/lib/parse.js index fc7d3054..7f306483 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -46,8 +46,7 @@ var KEYWORDS = 'break case catch class const continue debugger default delete do else export extends finally for function if in instanceof new return switch throw try typeof var let void while with import'; var KEYWORDS_ATOM = 'false null true'; -var RESERVED_WORDS = 'abstract boolean byte char class double enum export extends final float goto implements import int interface let long native package private protected public short static super synchronized this throws transient volatile' - + " " + KEYWORDS_ATOM + " " + KEYWORDS; +var RESERVED_WORDS = 'enum implements interface package private protected public static super this' + KEYWORDS_ATOM + " " + KEYWORDS; var KEYWORDS_BEFORE_EXPRESSION = 'return new delete throw else case yield'; KEYWORDS = makePredicate(KEYWORDS); @@ -547,7 +546,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) { } name += ch; } - if (KEYWORDS(name) && escaped) { + if (RESERVED_WORDS(name) && escaped) { parse_error("SyntaxError: Escaped characters are not allowed in keywords"); } return name; diff --git a/test/mocha/unicode.js b/test/mocha/unicode.js index d23b4a46..332adab7 100644 --- a/test/mocha/unicode.js +++ b/test/mocha/unicode.js @@ -99,7 +99,8 @@ describe("Unicode", function() { 'var \\u0069\\u006e = "foo"', // in 'var \\u0076\\u0061\\u0072 = "bar"', // var 'var \\u{66}\\u{6f}\\u{72} = "baz"', // for - 'var \\u0069\\u{66} = "foobar"' // if + 'var \\u0069\\u{66} = "foobar"', // if + 'var \\u{73}uper' // super ]; var exec = function(test) {