meriyah 4.3.0 → 4.3.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"identifier.d.ts","sourceRoot":"","sources":["../../../src/lexer/identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,KAAK,EAAoB,MAAM,UAAU,CAAC;AAYnD,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK,CAOpG;AAQD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,CAKlF;AAUD,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,CAAC,GAAG,CAAC,EAChB,gBAAgB,EAAE,MAAM,GACvB,KAAK,CA8DP;AAOD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,WAAW,GAAG,KAAK,CAGhE;AAOD,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAQvE;AAOD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAkC7D"}
1
+ {"version":3,"file":"identifier.d.ts","sourceRoot":"","sources":["../../../src/lexer/identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,KAAK,EAAoB,MAAM,UAAU,CAAC;AAYnD,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK,CAOpG;AAQD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,CAKlF;AAUD,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,CAAC,GAAG,CAAC,EAChB,gBAAgB,EAAE,MAAM,GACvB,KAAK,CAiFP;AAOD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,WAAW,GAAG,KAAK,CAGhE;AAOD,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAQvE;AAOD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAkC7D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meriyah",
3
- "version": "4.3.0",
3
+ "version": "4.3.1",
4
4
  "description": "A 100% compliant, self-hosted javascript parser with high focus on both performance and stability",
5
5
  "main": "dist/meriyah.cjs",
6
6
  "module": "dist/meriyah.esm.js",
@@ -76,14 +76,29 @@ export function scanIdentifierSlowCase(
76
76
  if (token === void 0) return Token.Identifier;
77
77
  if (!hasEscape) return token;
78
78
 
79
+ if (token === Token.AwaitKeyword) {
80
+ // await is only reserved word in async functions or modules
81
+ if ((context & (Context.Module | Context.InAwaitContext)) === 0) {
82
+ return token;
83
+ }
84
+ return Token.EscapedReserved;
85
+ }
86
+
79
87
  if (context & Context.Strict) {
80
- return token === Token.AwaitKeyword && (context & (Context.Module | Context.InAwaitContext)) === 0
81
- ? token
82
- : token === Token.StaticKeyword
83
- ? Token.EscapedFutureReserved
84
- : (token & Token.FutureReserved) === Token.FutureReserved
85
- ? Token.EscapedFutureReserved
86
- : Token.EscapedReserved;
88
+ if (token === Token.StaticKeyword) {
89
+ return Token.EscapedFutureReserved;
90
+ }
91
+ if ((token & Token.FutureReserved) === Token.FutureReserved) {
92
+ return Token.EscapedFutureReserved;
93
+ }
94
+ if ((token & Token.Reserved) === Token.Reserved) {
95
+ if (context & Context.AllowEscapedKeyword && (context & Context.InGlobal) === 0) {
96
+ return token;
97
+ } else {
98
+ return Token.EscapedReserved;
99
+ }
100
+ }
101
+ return Token.AnyIdentifier;
87
102
  }
88
103
  if (
89
104
  context & Context.AllowEscapedKeyword &&
@@ -99,13 +114,17 @@ export function scanIdentifierSlowCase(
99
114
  : token;
100
115
  }
101
116
 
102
- return token === Token.AsyncKeyword && context & Context.AllowEscapedKeyword
103
- ? Token.AnyIdentifier
104
- : (token & Token.FutureReserved) === Token.FutureReserved
105
- ? token
106
- : token === Token.AwaitKeyword && (context & Context.InAwaitContext) === 0
107
- ? token
108
- : Token.EscapedReserved;
117
+ // async is not reserved; it can be used as a variable name
118
+ // or statement label without restriction
119
+ if (token === Token.AsyncKeyword) {
120
+ // Escaped "async" such as \u0061sync can only be identifier
121
+ // not as "async" keyword
122
+ return Token.AnyIdentifier;
123
+ }
124
+ if ((token & Token.FutureReserved) === Token.FutureReserved) {
125
+ return token;
126
+ }
127
+ return Token.EscapedReserved;
109
128
  }
110
129
  return Token.Identifier;
111
130
  }
package/src/token.ts CHANGED
@@ -162,7 +162,7 @@ export const enum Token {
162
162
  /* Contextual keywords */
163
163
  AsKeyword = 110 | Contextual | IsExpressionStart,
164
164
  AsyncKeyword = 111 | Contextual | IsIdentifier | IsExpressionStart,
165
- AwaitKeyword = 112 | Contextual | IsExpressionStart | IsIdentifier,
165
+ AwaitKeyword = 112 | Contextual | IsExpressionStart | IsIdentifier, // await is only reserved word in async functions or modules
166
166
  ConstructorKeyword = 113 | Contextual,
167
167
  GetKeyword = 114 | Contextual,
168
168
  SetKeyword = 115 | Contextual,