mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
JavaScript: Add support for for-each-in comprehensions.
This commit is contained in:
@@ -274,16 +274,17 @@ public class CustomParser extends FlowParser {
|
||||
List<ComprehensionBlock> blocks = new ArrayList<ComprehensionBlock>();
|
||||
while (this.type == TokenType._for) {
|
||||
SourceLocation blockStart = new SourceLocation(this.startLoc);
|
||||
boolean of = false;
|
||||
this.next();
|
||||
if (this.eatContextual("each"))
|
||||
of = true;
|
||||
this.expect(TokenType.parenL);
|
||||
Expression left = this.parseBindingAtom();
|
||||
this.checkLVal(left, true, null);
|
||||
boolean of;
|
||||
if (this.eatContextual("of")) {
|
||||
of = true;
|
||||
} else {
|
||||
this.expect(TokenType._in);
|
||||
of = false;
|
||||
}
|
||||
Expression right = this.parseExpression(false, null);
|
||||
this.expect(TokenType.parenR);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
[for (year of years) if (year > 2000) year];
|
||||
year;
|
||||
[for (i of numbers) for (j of letters) i+j];
|
||||
[for (i of numbers) for (j of letters) if (i<j) i+j];
|
||||
[for (i of numbers) for (j of letters) if (i<j) i+j];
|
||||
[for each (i in numbers) i];
|
||||
|
||||
@@ -3,3 +3,4 @@ year;
|
||||
(for (i of numbers) for (j of letters) i+j);
|
||||
(for (i of numbers) for (j of letters) if (i<j) i+j);
|
||||
(x.p for (x in xs));
|
||||
(x.p for each (x in xs));
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user