Skip to content

Commit 91e46cd

Browse files
author
Max Schaefer
committed
JavaScript: Fix parsing of asynchronous generator methods.
1 parent 6d55d1f commit 91e46cd

File tree

7 files changed

+769
-1
lines changed

7 files changed

+769
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[[ condition: enterprise-only ]]
2+
3+
# Improvements to JavaScript analysis
4+
5+
## Changes to code extraction
6+
7+
* Asynchronous generator methods are now parsed correctly and no longer cause a spurious syntax error.

javascript/extractor/src/com/semmle/jcorn/Parser.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,6 +1944,7 @@ protected Property parseProperty(
19441944
this.parsePropertyName(pi);
19451945
if (!isPattern && this.options.ecmaVersion() >= 8 && !isGenerator && this.isAsyncProp(pi)) {
19461946
pi.isAsync = true;
1947+
pi.isGenerator = this.eat(TokenType.star);
19471948
this.parsePropertyName(pi);
19481949
} else {
19491950
pi.isAsync = false;
@@ -1964,6 +1965,7 @@ private boolean isAsyncProp(PropertyInfo pi) {
19641965
|| this.type == TokenType.num
19651966
|| this.type == TokenType.string
19661967
|| this.type == TokenType.bracketL
1968+
|| this.type == TokenType.star
19671969
|| this.type.keyword != null)
19681970
&& !this.canInsertSemicolon();
19691971
}
@@ -3166,6 +3168,7 @@ protected MemberDefinition<?> parseClassMember(boolean hadConstructor) {
31663168
}
31673169
if (this.options.ecmaVersion() >= 8 && !isGenerator && this.isAsyncProp(pi)) {
31683170
pi.isAsync = true;
3171+
pi.isGenerator = this.eat(TokenType.star);
31693172
this.parsePropertyName(pi);
31703173
}
31713174
return parseClassPropertyBody(pi, hadConstructor, isStatic);

javascript/extractor/src/com/semmle/js/extractor/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class Main {
3737
* A version identifier that should be updated every time the extractor changes in such a way that
3838
* it may produce different tuples for the same file under the same {@link ExtractorConfig}.
3939
*/
40-
public static final String EXTRACTOR_VERSION = "2019-07-25";
40+
public static final String EXTRACTOR_VERSION = "2019-09-02";
4141

4242
public static final Pattern NEWLINE = Pattern.compile("\n");
4343

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
async function* asyncFn() {}
2+
3+
class C {
4+
async *asyncMeth() {}
5+
async *[Symbol.asyncIterator]() {}
6+
}
7+
8+
var o = {
9+
async *asyncMeth() {},
10+
async *[Symbol.asyncIterator]() {}
11+
}

0 commit comments

Comments
 (0)