Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions change-notes/1.23/extractor-javascript.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[[ condition: enterprise-only ]]

# Improvements to JavaScript analysis

## Changes to code extraction

* Asynchronous generator methods are now parsed correctly and no longer cause a spurious syntax error.
3 changes: 3 additions & 0 deletions javascript/extractor/src/com/semmle/jcorn/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -1944,6 +1944,7 @@ protected Property parseProperty(
this.parsePropertyName(pi);
if (!isPattern && this.options.ecmaVersion() >= 8 && !isGenerator && this.isAsyncProp(pi)) {
pi.isAsync = true;
pi.isGenerator = this.eat(TokenType.star);
this.parsePropertyName(pi);
} else {
pi.isAsync = false;
Expand All @@ -1964,6 +1965,7 @@ private boolean isAsyncProp(PropertyInfo pi) {
|| this.type == TokenType.num
|| this.type == TokenType.string
|| this.type == TokenType.bracketL
|| this.type == TokenType.star
|| this.type.keyword != null)
&& !this.canInsertSemicolon();
}
Expand Down Expand Up @@ -3166,6 +3168,7 @@ protected MemberDefinition<?> parseClassMember(boolean hadConstructor) {
}
if (this.options.ecmaVersion() >= 8 && !isGenerator && this.isAsyncProp(pi)) {
pi.isAsync = true;
pi.isGenerator = this.eat(TokenType.star);
this.parsePropertyName(pi);
}
return parseClassPropertyBody(pi, hadConstructor, isStatic);
Expand Down
2 changes: 1 addition & 1 deletion javascript/extractor/src/com/semmle/js/extractor/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class Main {
* A version identifier that should be updated every time the extractor changes in such a way that
* it may produce different tuples for the same file under the same {@link ExtractorConfig}.
*/
public static final String EXTRACTOR_VERSION = "2019-07-25";
public static final String EXTRACTOR_VERSION = "2019-09-02";

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

Expand Down
11 changes: 11 additions & 0 deletions javascript/extractor/tests/es2018/input/asyncIter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
async function* asyncFn() {}

class C {
async *asyncMeth() {}
async *[Symbol.asyncIterator]() {}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test with an async method in an object literal (if such a thing is valid)?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


var o = {
async *asyncMeth() {},
async *[Symbol.asyncIterator]() {}
}
Loading