diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-02-09 21:42:27 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-10 05:42:27 +0800 |
commit | 228cdf8e7e1dc472813f7def780b8608a4f5f485 (patch) | |
tree | d8836d3831f5d6f465b79d5f7d295d19a7295d76 /lib | |
parent | 14fedbf123a5d8a86621ac6aa996042ee0011b47 (diff) | |
download | tracifyjs-228cdf8e7e1dc472813f7def780b8608a4f5f485.tar.gz tracifyjs-228cdf8e7e1dc472813f7def780b8608a4f5f485.zip |
reject invalid `for...of` syntax (#4632)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/parse.js | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/parse.js b/lib/parse.js index b926f188..ef0fc49a 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -1067,6 +1067,9 @@ function parse($TEXT, options) { if (init.definitions.length > 1) { token_error(init.start, "Only one variable declaration allowed in for..in/of loop"); } + if (ctor !== AST_ForIn && init.definitions[0].value) { + token_error(init.definitions[0].value.start, "No initializers allowed in for..of loop"); + } } else if (!(is_assignable(init) || (init = to_destructured(init)) instanceof AST_Destructured)) { token_error(init.start, "Invalid left-hand side in for..in/of loop"); } |