terser 5.5.1 → 5.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,6 +63,7 @@ import {
63
63
  AST_Class,
64
64
  AST_ClassExpression,
65
65
  AST_ClassProperty,
66
+ AST_ClassPrivateProperty,
66
67
  AST_ConciseMethod,
67
68
  AST_Conditional,
68
69
  AST_Const,
@@ -78,6 +79,7 @@ import {
78
79
  AST_Directive,
79
80
  AST_Do,
80
81
  AST_Dot,
82
+ AST_DotHash,
81
83
  AST_EmptyStatement,
82
84
  AST_Expansion,
83
85
  AST_Export,
@@ -108,6 +110,9 @@ import {
108
110
  AST_ObjectProperty,
109
111
  AST_ObjectSetter,
110
112
  AST_PrefixedTemplateString,
113
+ AST_PrivateGetter,
114
+ AST_PrivateMethod,
115
+ AST_PrivateSetter,
111
116
  AST_PropAccess,
112
117
  AST_RegExp,
113
118
  AST_Return,
@@ -386,6 +391,23 @@ import {
386
391
  static : M.static,
387
392
  });
388
393
  },
394
+ PropertyDefinition: function(M) {
395
+ let key;
396
+ if (M.computed) {
397
+ key = from_moz(M.key);
398
+ } else {
399
+ if (M.key.type !== "Identifier") throw new Error("Non-Identifier key in PropertyDefinition");
400
+ key = from_moz(M.key);
401
+ }
402
+
403
+ return new AST_ClassProperty({
404
+ start : my_start_token(M),
405
+ end : my_end_token(M),
406
+ key,
407
+ value : from_moz(M.value),
408
+ static : M.static,
409
+ });
410
+ },
389
411
  ArrayExpression: function(M) {
390
412
  return new AST_Array({
391
413
  start : my_start_token(M),
@@ -574,7 +596,7 @@ import {
574
596
  : p.type == "ArrowFunctionExpression" ? (p.params.includes(M)) ? AST_SymbolFunarg : AST_SymbolRef
575
597
  : p.type == "ClassExpression" ? (p.id === M ? AST_SymbolClass : AST_SymbolRef)
576
598
  : p.type == "Property" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolMethod)
577
- : p.type == "FieldDefinition" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolClassProperty)
599
+ : p.type == "PropertyDefinition" || p.type === "FieldDefinition" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolClassProperty)
578
600
  : p.type == "ClassDeclaration" ? (p.id === M ? AST_SymbolDefClass : AST_SymbolRef)
579
601
  : p.type == "MethodDefinition" ? (p.computed ? AST_SymbolRef : AST_SymbolMethod)
580
602
  : p.type == "CatchClause" ? AST_SymbolCatch
@@ -873,6 +895,19 @@ import {
873
895
  };
874
896
  });
875
897
 
898
+ def_to_moz(AST_DotHash, function To_Moz_PrivateMemberExpression(M) {
899
+ return {
900
+ type: "MemberExpression",
901
+ object: to_moz(M.expression),
902
+ computed: false,
903
+ property: {
904
+ type: "PrivateIdentifier",
905
+ name: M.property
906
+ },
907
+ optional: M.optional
908
+ };
909
+ });
910
+
876
911
  def_to_moz(AST_PropAccess, function To_Moz_MemberExpression(M) {
877
912
  var isComputed = M instanceof AST_Sub;
878
913
  return {
@@ -965,12 +1000,38 @@ import {
965
1000
  if (M instanceof AST_ObjectSetter) {
966
1001
  kind = "set";
967
1002
  }
1003
+ if (M instanceof AST_PrivateGetter || M instanceof AST_PrivateSetter) {
1004
+ const kind = M instanceof AST_PrivateGetter ? "get" : "set";
1005
+ return {
1006
+ type: "MethodDefinition",
1007
+ computed: false,
1008
+ kind: kind,
1009
+ static: M.static,
1010
+ key: {
1011
+ type: "PrivateIdentifier",
1012
+ name: M.key.name
1013
+ },
1014
+ value: to_moz(M.value)
1015
+ };
1016
+ }
1017
+ if (M instanceof AST_ClassPrivateProperty) {
1018
+ return {
1019
+ type: "PropertyDefinition",
1020
+ key: {
1021
+ type: "PrivateIdentifier",
1022
+ name: M.key.name
1023
+ },
1024
+ value: to_moz(M.value),
1025
+ computed: false,
1026
+ static: M.static
1027
+ };
1028
+ }
968
1029
  if (M instanceof AST_ClassProperty) {
969
1030
  return {
970
- type: "FieldDefinition",
971
- computed,
1031
+ type: "PropertyDefinition",
972
1032
  key,
973
1033
  value: to_moz(M.value),
1034
+ computed,
974
1035
  static: M.static
975
1036
  };
976
1037
  }
@@ -1005,13 +1066,21 @@ import {
1005
1066
  value: to_moz(M.value)
1006
1067
  };
1007
1068
  }
1069
+
1070
+ const key = M instanceof AST_PrivateMethod
1071
+ ? {
1072
+ type: "PrivateIdentifier",
1073
+ name: M.key.name
1074
+ }
1075
+ : to_moz(M.key);
1076
+
1008
1077
  return {
1009
1078
  type: "MethodDefinition",
1010
- computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
1011
1079
  kind: M.key === "constructor" ? "constructor" : "method",
1080
+ key,
1081
+ value: to_moz(M.value),
1082
+ computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
1012
1083
  static: M.static,
1013
- key: to_moz(M.key),
1014
- value: to_moz(M.value)
1015
1084
  };
1016
1085
  });
1017
1086
 
package/lib/output.js CHANGED
@@ -68,8 +68,12 @@ import {
68
68
  AST_Chain,
69
69
  AST_Class,
70
70
  AST_ClassExpression,
71
+ AST_ClassPrivateProperty,
71
72
  AST_ClassProperty,
72
73
  AST_ConciseMethod,
74
+ AST_PrivateGetter,
75
+ AST_PrivateMethod,
76
+ AST_PrivateSetter,
73
77
  AST_Conditional,
74
78
  AST_Const,
75
79
  AST_Constant,
@@ -83,6 +87,7 @@ import {
83
87
  AST_Directive,
84
88
  AST_Do,
85
89
  AST_Dot,
90
+ AST_DotHash,
86
91
  AST_EmptyStatement,
87
92
  AST_Exit,
88
93
  AST_Expansion,
@@ -928,6 +933,7 @@ function OutputStream(options) {
928
933
  var p = output.parent();
929
934
  return p instanceof AST_PropAccess && p.expression === this
930
935
  || p instanceof AST_Call && p.expression === this
936
+ || p instanceof AST_Binary && p.operator === "**" && p.left === this
931
937
  || output.option("safari10") && p instanceof AST_UnaryPrefix;
932
938
  });
933
939
 
@@ -1803,6 +1809,15 @@ function OutputStream(options) {
1803
1809
  output.print_name(prop);
1804
1810
  }
1805
1811
  });
1812
+ DEFPRINT(AST_DotHash, function(self, output) {
1813
+ var expr = self.expression;
1814
+ expr.print(output);
1815
+ var prop = self.property;
1816
+
1817
+ if (self.optional) output.print("?");
1818
+ output.print(".#");
1819
+ output.print_name(prop);
1820
+ });
1806
1821
  DEFPRINT(AST_Sub, function(self, output) {
1807
1822
  self.expression.print(output);
1808
1823
  if (self.optional) output.print("?.");
@@ -2006,6 +2021,23 @@ function OutputStream(options) {
2006
2021
  self.value.print(output);
2007
2022
  }
2008
2023
  });
2024
+ DEFPRINT(AST_ClassPrivateProperty, (self, output) => {
2025
+ if (self.static) {
2026
+ output.print("static");
2027
+ output.space();
2028
+ }
2029
+
2030
+ output.print("#");
2031
+
2032
+ print_property_name(self.key.name, self.quote, output);
2033
+
2034
+ if (self.value) {
2035
+ output.print("=");
2036
+ self.value.print(output);
2037
+ }
2038
+
2039
+ output.semicolon();
2040
+ });
2009
2041
  DEFPRINT(AST_ClassProperty, (self, output) => {
2010
2042
  if (self.static) {
2011
2043
  output.print("static");
@@ -2027,7 +2059,7 @@ function OutputStream(options) {
2027
2059
 
2028
2060
  output.semicolon();
2029
2061
  });
2030
- AST_ObjectProperty.DEFMETHOD("_print_getter_setter", function(type, output) {
2062
+ AST_ObjectProperty.DEFMETHOD("_print_getter_setter", function(type, is_private, output) {
2031
2063
  var self = this;
2032
2064
  if (self.static) {
2033
2065
  output.print("static");
@@ -2038,6 +2070,7 @@ function OutputStream(options) {
2038
2070
  output.space();
2039
2071
  }
2040
2072
  if (self.key instanceof AST_SymbolMethod) {
2073
+ if (is_private) output.print("#");
2041
2074
  print_property_name(self.key.name, self.quote, output);
2042
2075
  } else {
2043
2076
  output.with_square(function() {
@@ -2047,10 +2080,27 @@ function OutputStream(options) {
2047
2080
  self.value._do_print(output, true);
2048
2081
  });
2049
2082
  DEFPRINT(AST_ObjectSetter, function(self, output) {
2050
- self._print_getter_setter("set", output);
2083
+ self._print_getter_setter("set", false, output);
2051
2084
  });
2052
2085
  DEFPRINT(AST_ObjectGetter, function(self, output) {
2053
- self._print_getter_setter("get", output);
2086
+ self._print_getter_setter("get", false, output);
2087
+ });
2088
+ DEFPRINT(AST_PrivateSetter, function(self, output) {
2089
+ self._print_getter_setter("set", true, output);
2090
+ });
2091
+ DEFPRINT(AST_PrivateGetter, function(self, output) {
2092
+ self._print_getter_setter("get", true, output);
2093
+ });
2094
+ DEFPRINT(AST_PrivateMethod, function(self, output) {
2095
+ var type;
2096
+ if (self.is_generator && self.async) {
2097
+ type = "async*";
2098
+ } else if (self.is_generator) {
2099
+ type = "*";
2100
+ } else if (self.async) {
2101
+ type = "async";
2102
+ }
2103
+ self._print_getter_setter(type, true, output);
2054
2104
  });
2055
2105
  DEFPRINT(AST_ConciseMethod, function(self, output) {
2056
2106
  var type;
@@ -2061,7 +2111,7 @@ function OutputStream(options) {
2061
2111
  } else if (self.async) {
2062
2112
  type = "async";
2063
2113
  }
2064
- self._print_getter_setter(type, output);
2114
+ self._print_getter_setter(type, false, output);
2065
2115
  });
2066
2116
  AST_Symbol.DEFMETHOD("_do_print", function(output) {
2067
2117
  var def = this.definition();
@@ -2101,7 +2151,9 @@ function OutputStream(options) {
2101
2151
  source = regexp_source_fix(source);
2102
2152
  flags = flags ? sort_regexp_flags(flags) : "";
2103
2153
  source = source.replace(r_slash_script, slash_script_replace);
2154
+
2104
2155
  output.print(output.to_utf8(`/${source}/${flags}`));
2156
+
2105
2157
  const parent = output.parent();
2106
2158
  if (
2107
2159
  parent instanceof AST_Binary
package/lib/parse.js CHANGED
@@ -65,8 +65,12 @@ import {
65
65
  AST_Catch,
66
66
  AST_Chain,
67
67
  AST_ClassExpression,
68
+ AST_ClassPrivateProperty,
68
69
  AST_ClassProperty,
69
70
  AST_ConciseMethod,
71
+ AST_PrivateGetter,
72
+ AST_PrivateMethod,
73
+ AST_PrivateSetter,
70
74
  AST_Conditional,
71
75
  AST_Const,
72
76
  AST_Continue,
@@ -80,6 +84,7 @@ import {
80
84
  AST_Directive,
81
85
  AST_Do,
82
86
  AST_Dot,
87
+ AST_DotHash,
83
88
  AST_EmptyStatement,
84
89
  AST_Expansion,
85
90
  AST_Export,
@@ -97,7 +102,6 @@ import {
97
102
  AST_Label,
98
103
  AST_LabeledStatement,
99
104
  AST_LabelRef,
100
- AST_Lambda,
101
105
  AST_Let,
102
106
  AST_NameMapping,
103
107
  AST_New,
@@ -868,6 +872,11 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
868
872
  : token("keyword", word);
869
873
  }
870
874
 
875
+ function read_private_word() {
876
+ next();
877
+ return token("privatename", read_name());
878
+ }
879
+
871
880
  function with_eof_error(eof_error, cont) {
872
881
  return function(x) {
873
882
  try {
@@ -937,6 +946,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
937
946
  if (PUNC_CHARS.has(ch)) return token("punc", next());
938
947
  if (OPERATOR_CHARS.has(ch)) return read_operator();
939
948
  if (code == 92 || is_identifier_start(ch)) return read_word();
949
+ if (code == 35) return read_private_word();
940
950
  break;
941
951
  }
942
952
  parse_error("Unexpected character '" + ch + "'");
@@ -1137,6 +1147,13 @@ function parse($TEXT, options) {
1137
1147
  return S.in_async === S.in_function;
1138
1148
  }
1139
1149
 
1150
+ function can_await() {
1151
+ return (
1152
+ S.in_async === S.in_function
1153
+ || S.in_function === 0 && S.input.has_directive("use strict")
1154
+ );
1155
+ }
1156
+
1140
1157
  function semicolon(optional) {
1141
1158
  if (is("punc", ";")) next();
1142
1159
  else if (!optional && !can_insert_semicolon()) unexpected();
@@ -1275,7 +1292,7 @@ function parse($TEXT, options) {
1275
1292
  if (is_if_body) {
1276
1293
  croak("classes are not allowed as the body of an if");
1277
1294
  }
1278
- return class_(AST_DefClass);
1295
+ return class_(AST_DefClass, is_export_default);
1279
1296
 
1280
1297
  case "function":
1281
1298
  next();
@@ -1421,7 +1438,7 @@ function parse($TEXT, options) {
1421
1438
  var for_await_error = "`for await` invalid in this context";
1422
1439
  var await_tok = S.token;
1423
1440
  if (await_tok.type == "name" && await_tok.value == "await") {
1424
- if (!is_in_async()) {
1441
+ if (!can_await()) {
1425
1442
  token_error(await_tok, for_await_error);
1426
1443
  }
1427
1444
  next();
@@ -1918,7 +1935,7 @@ function parse($TEXT, options) {
1918
1935
 
1919
1936
  function _await_expression() {
1920
1937
  // Previous token must be "await" and not be interpreted as an identifier
1921
- if (!is_in_async()) {
1938
+ if (!can_await()) {
1922
1939
  croak("Unexpected await expression outside async function",
1923
1940
  S.prev.line, S.prev.col, S.prev.pos);
1924
1941
  }
@@ -2470,7 +2487,7 @@ function parse($TEXT, options) {
2470
2487
  return new AST_Object({ properties: a });
2471
2488
  });
2472
2489
 
2473
- function class_(KindOfClass) {
2490
+ function class_(KindOfClass, is_export_default) {
2474
2491
  var start, method, class_name, extends_, a = [];
2475
2492
 
2476
2493
  S.input.push_directives_stack(); // Push directive stack, but not scope stack
@@ -2481,7 +2498,11 @@ function parse($TEXT, options) {
2481
2498
  }
2482
2499
 
2483
2500
  if (KindOfClass === AST_DefClass && !class_name) {
2484
- unexpected();
2501
+ if (is_export_default) {
2502
+ KindOfClass = AST_ClassExpression;
2503
+ } else {
2504
+ unexpected();
2505
+ }
2485
2506
  }
2486
2507
 
2487
2508
  if (S.token.value == "extends") {
@@ -2514,9 +2535,9 @@ function parse($TEXT, options) {
2514
2535
  }
2515
2536
 
2516
2537
  function concise_method_or_getset(name, start, is_class) {
2517
- var get_method_name_ast = function(name, start) {
2538
+ const get_symbol_ast = (name, SymbolClass = AST_SymbolMethod) => {
2518
2539
  if (typeof name === "string" || typeof name === "number") {
2519
- return new AST_SymbolMethod({
2540
+ return new SymbolClass({
2520
2541
  start,
2521
2542
  name: "" + name,
2522
2543
  end: prev()
@@ -2526,43 +2547,74 @@ function parse($TEXT, options) {
2526
2547
  }
2527
2548
  return name;
2528
2549
  };
2529
- const get_class_property_key_ast = (name) => {
2530
- if (typeof name === "string" || typeof name === "number") {
2531
- return new AST_SymbolClassProperty({
2532
- start: property_token,
2533
- end: property_token,
2534
- name: "" + name
2535
- });
2536
- } else if (name === null) {
2537
- unexpected();
2538
- }
2539
- return name;
2540
- };
2550
+
2551
+ const is_not_method_start = () =>
2552
+ !is("punc", "(") && !is("punc", ",") && !is("punc", "}") && !is("operator", "=");
2553
+
2541
2554
  var is_async = false;
2542
2555
  var is_static = false;
2543
2556
  var is_generator = false;
2544
- var property_token = start;
2545
- if (is_class && name === "static" && !is("punc", "(")) {
2557
+ var is_private = false;
2558
+ var accessor_type = null;
2559
+
2560
+ if (is_class && name === "static" && is_not_method_start()) {
2546
2561
  is_static = true;
2547
- property_token = S.token;
2548
2562
  name = as_property_name();
2549
2563
  }
2550
- if (name === "async" && !is("punc", "(") && !is("punc", ",") && !is("punc", "}") && !is("operator", "=")) {
2564
+ if (name === "async" && is_not_method_start()) {
2551
2565
  is_async = true;
2552
- property_token = S.token;
2553
2566
  name = as_property_name();
2554
2567
  }
2555
- if (name === null) {
2568
+ if (prev().type === "operator" && prev().value === "*") {
2556
2569
  is_generator = true;
2557
- property_token = S.token;
2558
2570
  name = as_property_name();
2559
- if (name === null) {
2560
- unexpected();
2571
+ }
2572
+ if ((name === "get" || name === "set") && is_not_method_start()) {
2573
+ accessor_type = name;
2574
+ name = as_property_name();
2575
+ }
2576
+ if (prev().type === "privatename") {
2577
+ is_private = true;
2578
+ }
2579
+
2580
+ const property_token = prev();
2581
+
2582
+ if (accessor_type != null) {
2583
+ if (!is_private) {
2584
+ const AccessorClass = accessor_type === "get"
2585
+ ? AST_ObjectGetter
2586
+ : AST_ObjectSetter;
2587
+
2588
+ name = get_symbol_ast(name);
2589
+ return new AccessorClass({
2590
+ start,
2591
+ static: is_static,
2592
+ key: name,
2593
+ quote: name instanceof AST_SymbolMethod ? property_token.quote : undefined,
2594
+ value: create_accessor(),
2595
+ end: prev()
2596
+ });
2597
+ } else {
2598
+ const AccessorClass = accessor_type === "get"
2599
+ ? AST_PrivateGetter
2600
+ : AST_PrivateSetter;
2601
+
2602
+ return new AccessorClass({
2603
+ start,
2604
+ static: is_static,
2605
+ key: get_symbol_ast(name),
2606
+ value: create_accessor(),
2607
+ end: prev(),
2608
+ });
2561
2609
  }
2562
2610
  }
2611
+
2563
2612
  if (is("punc", "(")) {
2564
- name = get_method_name_ast(name, start);
2565
- var node = new AST_ConciseMethod({
2613
+ name = get_symbol_ast(name);
2614
+ const AST_MethodVariant = is_private
2615
+ ? AST_PrivateMethod
2616
+ : AST_ConciseMethod;
2617
+ var node = new AST_MethodVariant({
2566
2618
  start : start,
2567
2619
  static : is_static,
2568
2620
  is_generator: is_generator,
@@ -2575,42 +2627,18 @@ function parse($TEXT, options) {
2575
2627
  });
2576
2628
  return node;
2577
2629
  }
2578
- const setter_token = S.token;
2579
- if (name == "get") {
2580
- if (!is("punc") || is("punc", "[")) {
2581
- name = get_method_name_ast(as_property_name(), start);
2582
- return new AST_ObjectGetter({
2583
- start : start,
2584
- static: is_static,
2585
- key : name,
2586
- quote : name instanceof AST_SymbolMethod ?
2587
- setter_token.quote : undefined,
2588
- value : create_accessor(),
2589
- end : prev()
2590
- });
2591
- }
2592
- } else if (name == "set") {
2593
- if (!is("punc") || is("punc", "[")) {
2594
- name = get_method_name_ast(as_property_name(), start);
2595
- return new AST_ObjectSetter({
2596
- start : start,
2597
- static: is_static,
2598
- key : name,
2599
- quote : name instanceof AST_SymbolMethod ?
2600
- setter_token.quote : undefined,
2601
- value : create_accessor(),
2602
- end : prev()
2603
- });
2604
- }
2605
- }
2630
+
2606
2631
  if (is_class) {
2607
- const key = get_class_property_key_ast(name, property_token);
2632
+ const key = get_symbol_ast(name, AST_SymbolClassProperty);
2608
2633
  const quote = key instanceof AST_SymbolClassProperty
2609
2634
  ? property_token.quote
2610
2635
  : undefined;
2636
+ const AST_ClassPropertyVariant = is_private
2637
+ ? AST_ClassPrivateProperty
2638
+ : AST_ClassProperty;
2611
2639
  if (is("operator", "=")) {
2612
2640
  next();
2613
- return new AST_ClassProperty({
2641
+ return new AST_ClassPropertyVariant({
2614
2642
  start,
2615
2643
  static: is_static,
2616
2644
  quote,
@@ -2618,8 +2646,14 @@ function parse($TEXT, options) {
2618
2646
  value: expression(false),
2619
2647
  end: prev()
2620
2648
  });
2621
- } else if (is("name") || is("punc", ";") || is("punc", "}")) {
2622
- return new AST_ClassProperty({
2649
+ } else if (
2650
+ is("name")
2651
+ || is("privatename")
2652
+ || is("operator", "*")
2653
+ || is("punc", ";")
2654
+ || is("punc", "}")
2655
+ ) {
2656
+ return new AST_ClassPropertyVariant({
2623
2657
  start,
2624
2658
  static: is_static,
2625
2659
  quote,
@@ -2821,8 +2855,17 @@ function parse($TEXT, options) {
2821
2855
  semicolon();
2822
2856
  } else if ((node = statement(is_default)) instanceof AST_Definitions && is_default) {
2823
2857
  unexpected(node.start);
2824
- } else if (node instanceof AST_Definitions || node instanceof AST_Lambda || node instanceof AST_DefClass) {
2858
+ } else if (
2859
+ node instanceof AST_Definitions
2860
+ || node instanceof AST_Defun
2861
+ || node instanceof AST_DefClass
2862
+ ) {
2825
2863
  exported_definition = node;
2864
+ } else if (
2865
+ node instanceof AST_ClassExpression
2866
+ || node instanceof AST_Function
2867
+ ) {
2868
+ exported_value = node;
2826
2869
  } else if (node instanceof AST_SimpleStatement) {
2827
2870
  exported_value = node.body;
2828
2871
  } else {
@@ -2858,6 +2901,7 @@ function parse($TEXT, options) {
2858
2901
  }
2859
2902
  /* falls through */
2860
2903
  case "name":
2904
+ case "privatename":
2861
2905
  case "string":
2862
2906
  case "num":
2863
2907
  case "big_int":
@@ -2872,7 +2916,7 @@ function parse($TEXT, options) {
2872
2916
 
2873
2917
  function as_name() {
2874
2918
  var tmp = S.token;
2875
- if (tmp.type != "name") unexpected();
2919
+ if (tmp.type != "name" && tmp.type != "privatename") unexpected();
2876
2920
  next();
2877
2921
  return tmp.value;
2878
2922
  }
@@ -2943,7 +2987,8 @@ function parse($TEXT, options) {
2943
2987
  var start = expr.start;
2944
2988
  if (is("punc", ".")) {
2945
2989
  next();
2946
- return subscripts(new AST_Dot({
2990
+ const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
2991
+ return subscripts(new AST_DotVariant({
2947
2992
  start : start,
2948
2993
  expression : expr,
2949
2994
  optional : false,
@@ -2994,8 +3039,9 @@ function parse($TEXT, options) {
2994
3039
  annotate(call);
2995
3040
 
2996
3041
  chain_contents = subscripts(call, true, true);
2997
- } else if (is("name")) {
2998
- chain_contents = subscripts(new AST_Dot({
3042
+ } else if (is("name") || is("privatename")) {
3043
+ const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
3044
+ chain_contents = subscripts(new AST_DotVariant({
2999
3045
  start,
3000
3046
  expression: expr,
3001
3047
  optional: true,
@@ -3066,13 +3112,9 @@ function parse($TEXT, options) {
3066
3112
 
3067
3113
  var maybe_unary = function(allow_calls, allow_arrows) {
3068
3114
  var start = S.token;
3069
- if (start.type == "name" && start.value == "await") {
3070
- if (is_in_async()) {
3071
- next();
3072
- return _await_expression();
3073
- } else if (S.input.has_directive("use strict")) {
3074
- token_error(S.token, "Unexpected await identifier inside strict mode");
3075
- }
3115
+ if (start.type == "name" && start.value == "await" && can_await()) {
3116
+ next();
3117
+ return _await_expression();
3076
3118
  }
3077
3119
  if (is("operator") && UNARY_PREFIX.has(start.value)) {
3078
3120
  next();