Allow 'of' to be a name.

This commit is contained in:
Fábio Santos 2015-10-26 20:56:59 +00:00 committed by Burak Can
parent 292c131743
commit 5e1c89db44
2 changed files with 19 additions and 2 deletions

View File

@ -44,7 +44,7 @@
"use strict"; "use strict";
var KEYWORDS = 'break case catch const continue debugger default delete do else finally for function if in of instanceof new return switch throw try typeof var let void while with'; var KEYWORDS = 'break case catch const continue debugger default delete do else finally for function if in instanceof new return switch throw try typeof var let void while with';
var KEYWORDS_ATOM = 'false null true'; 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 long native package private protected public short static super synchronized this throws transient volatile yield' var RESERVED_WORDS = 'abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized this throws transient volatile yield'
+ " " + KEYWORDS_ATOM + " " + KEYWORDS; + " " + KEYWORDS_ATOM + " " + KEYWORDS;
@ -969,7 +969,7 @@ function parse($TEXT, options) {
is("keyword", "let") ? (next(), let_(true)) : is("keyword", "let") ? (next(), let_(true)) :
expression(true, true); expression(true, true);
var is_in = is("operator", "in"); var is_in = is("operator", "in");
var is_of = is("keyword", "of"); var is_of = is("name", "of");
if (is_in || is_of) { if (is_in || is_of) {
if ((init instanceof AST_Var || init instanceof AST_Let) && if ((init instanceof AST_Var || init instanceof AST_Let) &&
init.definitions.length > 1) init.definitions.length > 1)

View File

@ -158,3 +158,20 @@ regression_cannot_destructure: {
expect_exact: "var x={x:3};x({x:3});"; expect_exact: "var x={x:3};x({x:3});";
} }
regression_cannot_use_of: {
input: {
function of() {
}
var of = "is a valid variable name";
of = { of: "is ok" };
x.of;
of: foo()
}
expect: {
function of(){}
var of="is a valid variable name";
of={of:"is ok"};
x.of;
foo(); /* Label statement missing? No prob. */
}
}