diff --git a/javascript/extractor/src/com/semmle/jcorn/Parser.java b/javascript/extractor/src/com/semmle/jcorn/Parser.java index a248a82dd140..07e83dfb9248 100644 --- a/javascript/extractor/src/com/semmle/jcorn/Parser.java +++ b/javascript/extractor/src/com/semmle/jcorn/Parser.java @@ -2296,9 +2296,11 @@ protected Identifier parseIdent(boolean liberal) { && (this.options.ecmaVersion() >= 6 || inputSubstring(this.start, this.end).indexOf("\\") == -1)) this.raiseRecoverable(this.start, "The keyword '" + this.value + "' is reserved"); - if (!isPrivateField && this.inGenerator && this.value.equals("yield")) + // `yield` and `await` are only restricted as bindings and references. `liberal` means we + // are parsing a property name, where they are ordinary identifiers. + if (!liberal && this.inGenerator && this.value.equals("yield")) this.raiseRecoverable(this.start, "Can not use 'yield' as identifier inside a generator"); - if (!isPrivateField && this.inAsync && this.value.equals("await")) + if (!liberal && this.inAsync && this.value.equals("await")) this.raiseRecoverable( this.start, "Can not use 'await' as identifier inside an async function"); name = String.valueOf(this.value); diff --git a/javascript/extractor/test/com/semmle/js/extractor/test/AllTests.java b/javascript/extractor/test/com/semmle/js/extractor/test/AllTests.java index 4061f1a8651b..f2a1f2e3ee60 100644 --- a/javascript/extractor/test/com/semmle/js/extractor/test/AllTests.java +++ b/javascript/extractor/test/com/semmle/js/extractor/test/AllTests.java @@ -27,7 +27,8 @@ ExportExtensionsTests.class, AutoBuildTests.class, RobustnessTests.class, - NumericSeparatorTests.class + NumericSeparatorTests.class, + AwaitYieldIdentifierTests.class }) public class AllTests { diff --git a/javascript/extractor/test/com/semmle/js/extractor/test/AwaitYieldIdentifierTests.java b/javascript/extractor/test/com/semmle/js/extractor/test/AwaitYieldIdentifierTests.java new file mode 100644 index 000000000000..2231d48fb7c4 --- /dev/null +++ b/javascript/extractor/test/com/semmle/js/extractor/test/AwaitYieldIdentifierTests.java @@ -0,0 +1,62 @@ +package com.semmle.js.extractor.test; + +import com.semmle.jcorn.CustomParser; +import com.semmle.jcorn.Options; +import com.semmle.jcorn.SyntaxError; +import org.junit.Assert; +import org.junit.Test; + +/** + * Tests for using await and yield as property names inside async + * functions and generators, where they are only restricted as bindings and references. + */ +public class AwaitYieldIdentifierTests { + private void testSucceed(String input) { + new CustomParser(new Options().esnext(true), input, 0).parse(); + } + + private void testFail(String input, String msg) { + try { + new CustomParser(new Options().esnext(true), input, 0).parse(); + Assert.fail("Expected syntax error, but parsing succeeded."); + } catch (SyntaxError e) { + Assert.assertEquals(msg, e.getMessage()); + } + } + + @Test + public void awaitAsPropertyName() { + testSucceed("async function f(pool) { return await pool.await(); }"); + testSucceed("async function f(o) { return o?.await; }"); + testSucceed("async function f() { return { await: 42 }; }"); + testSucceed("async function f() { class C { await() {} } }"); + testSucceed("async function f(o) { o.await = 42; }"); + } + + @Test + public void yieldAsPropertyName() { + testSucceed("function* g(o) { yield o.yield(); }"); + testSucceed("function* g() { return { yield: 42 }; }"); + testSucceed("function* g() { class C { yield() {} } }"); + } + + @Test + public void awaitAsIdentifier() { + testFail( + "async function f() { var await = 42; }", + "Can not use 'await' as identifier inside an async function (1:25)"); + testFail( + "async function f() { return { await }; }", + "'await' can not be used as shorthand property (1:30)"); + } + + @Test + public void yieldAsIdentifier() { + testFail( + "function* g() { var yield = 42; }", + "Can not use 'yield' as identifier inside a generator (1:20)"); + testFail( + "function* g() { return { yield }; }", + "'yield' can not be used as shorthand property (1:25)"); + } +} diff --git a/javascript/extractor/tests/es2017/input/await-yield-property.js b/javascript/extractor/tests/es2017/input/await-yield-property.js new file mode 100644 index 000000000000..59aab8548a34 --- /dev/null +++ b/javascript/extractor/tests/es2017/input/await-yield-property.js @@ -0,0 +1,17 @@ +const o = { await: 42, yield: 43 }; + +async function f(pool) { + console.log(o.await); + o.await = 1; + return await pool.await(); +} + +function* g() { + yield o.yield; + yield o?.yield; +} + +class C { + async await() {} + *yield() {} +} diff --git a/javascript/extractor/tests/es2017/output/trap/await-yield-property.js.trap b/javascript/extractor/tests/es2017/output/trap/await-yield-property.js.trap new file mode 100644 index 000000000000..452033068110 --- /dev/null +++ b/javascript/extractor/tests/es2017/output/trap/await-yield-property.js.trap @@ -0,0 +1,1089 @@ +#10000=@"/await-yield-property.js;sourcefile" +files(#10000,"/await-yield-property.js") +#10001=@"/;folder" +folders(#10001,"/") +containerparent(#10001,#10000) +#10002=@"loc,{#10000},0,0,0,0" +locations_default(#10002,#10000,0,0,0,0) +hasLocation(#10000,#10002) +#20000=@"global_scope" +scopes(#20000,0) +#20001=@"script;{#10000},1,1" +#20002=* +lines(#20002,#20001,"const o = { await: 42, yield: 43 };"," +") +#20003=@"loc,{#10000},1,1,1,35" +locations_default(#20003,#10000,1,1,1,35) +hasLocation(#20002,#20003) +#20004=* +lines(#20004,#20001,""," +") +#20005=@"loc,{#10000},2,1,2,0" +locations_default(#20005,#10000,2,1,2,0) +hasLocation(#20004,#20005) +#20006=* +lines(#20006,#20001,"async function f(pool) {"," +") +#20007=@"loc,{#10000},3,1,3,24" +locations_default(#20007,#10000,3,1,3,24) +hasLocation(#20006,#20007) +#20008=* +lines(#20008,#20001," console.log(o.await);"," +") +#20009=@"loc,{#10000},4,1,4,23" +locations_default(#20009,#10000,4,1,4,23) +hasLocation(#20008,#20009) +indentation(#10000,4," ",2) +#20010=* +lines(#20010,#20001," o.await = 1;"," +") +#20011=@"loc,{#10000},5,1,5,14" +locations_default(#20011,#10000,5,1,5,14) +hasLocation(#20010,#20011) +indentation(#10000,5," ",2) +#20012=* +lines(#20012,#20001," return await pool.await();"," +") +#20013=@"loc,{#10000},6,1,6,28" +locations_default(#20013,#10000,6,1,6,28) +hasLocation(#20012,#20013) +indentation(#10000,6," ",2) +#20014=* +lines(#20014,#20001,"}"," +") +#20015=@"loc,{#10000},7,1,7,1" +locations_default(#20015,#10000,7,1,7,1) +hasLocation(#20014,#20015) +#20016=* +lines(#20016,#20001,""," +") +#20017=@"loc,{#10000},8,1,8,0" +locations_default(#20017,#10000,8,1,8,0) +hasLocation(#20016,#20017) +#20018=* +lines(#20018,#20001,"function* g() {"," +") +#20019=@"loc,{#10000},9,1,9,15" +locations_default(#20019,#10000,9,1,9,15) +hasLocation(#20018,#20019) +#20020=* +lines(#20020,#20001," yield o.yield;"," +") +#20021=@"loc,{#10000},10,1,10,16" +locations_default(#20021,#10000,10,1,10,16) +hasLocation(#20020,#20021) +indentation(#10000,10," ",2) +#20022=* +lines(#20022,#20001," yield o?.yield;"," +") +#20023=@"loc,{#10000},11,1,11,17" +locations_default(#20023,#10000,11,1,11,17) +hasLocation(#20022,#20023) +indentation(#10000,11," ",2) +#20024=* +lines(#20024,#20001,"}"," +") +#20025=@"loc,{#10000},12,1,12,1" +locations_default(#20025,#10000,12,1,12,1) +hasLocation(#20024,#20025) +#20026=* +lines(#20026,#20001,""," +") +#20027=@"loc,{#10000},13,1,13,0" +locations_default(#20027,#10000,13,1,13,0) +hasLocation(#20026,#20027) +#20028=* +lines(#20028,#20001,"class C {"," +") +#20029=@"loc,{#10000},14,1,14,9" +locations_default(#20029,#10000,14,1,14,9) +hasLocation(#20028,#20029) +#20030=* +lines(#20030,#20001," async await() {}"," +") +#20031=@"loc,{#10000},15,1,15,18" +locations_default(#20031,#10000,15,1,15,18) +hasLocation(#20030,#20031) +indentation(#10000,15," ",2) +#20032=* +lines(#20032,#20001," *yield() {}"," +") +#20033=@"loc,{#10000},16,1,16,13" +locations_default(#20033,#10000,16,1,16,13) +hasLocation(#20032,#20033) +indentation(#10000,16," ",2) +#20034=* +lines(#20034,#20001,"}"," +") +#20035=@"loc,{#10000},17,1,17,1" +locations_default(#20035,#10000,17,1,17,1) +hasLocation(#20034,#20035) +numlines(#20001,17,14,0) +#20036=* +tokeninfo(#20036,7,#20001,0,"const") +#20037=@"loc,{#10000},1,1,1,5" +locations_default(#20037,#10000,1,1,1,5) +hasLocation(#20036,#20037) +#20038=* +tokeninfo(#20038,6,#20001,1,"o") +#20039=@"loc,{#10000},1,7,1,7" +locations_default(#20039,#10000,1,7,1,7) +hasLocation(#20038,#20039) +#20040=* +tokeninfo(#20040,8,#20001,2,"=") +#20041=@"loc,{#10000},1,9,1,9" +locations_default(#20041,#10000,1,9,1,9) +hasLocation(#20040,#20041) +#20042=* +tokeninfo(#20042,8,#20001,3,"{") +#20043=@"loc,{#10000},1,11,1,11" +locations_default(#20043,#10000,1,11,1,11) +hasLocation(#20042,#20043) +#20044=* +tokeninfo(#20044,6,#20001,4,"await") +#20045=@"loc,{#10000},1,13,1,17" +locations_default(#20045,#10000,1,13,1,17) +hasLocation(#20044,#20045) +#20046=* +tokeninfo(#20046,8,#20001,5,":") +#20047=@"loc,{#10000},1,18,1,18" +locations_default(#20047,#10000,1,18,1,18) +hasLocation(#20046,#20047) +#20048=* +tokeninfo(#20048,3,#20001,6,"42") +#20049=@"loc,{#10000},1,20,1,21" +locations_default(#20049,#10000,1,20,1,21) +hasLocation(#20048,#20049) +#20050=* +tokeninfo(#20050,8,#20001,7,",") +#20051=@"loc,{#10000},1,22,1,22" +locations_default(#20051,#10000,1,22,1,22) +hasLocation(#20050,#20051) +#20052=* +tokeninfo(#20052,7,#20001,8,"yield") +#20053=@"loc,{#10000},1,24,1,28" +locations_default(#20053,#10000,1,24,1,28) +hasLocation(#20052,#20053) +#20054=* +tokeninfo(#20054,8,#20001,9,":") +#20055=@"loc,{#10000},1,29,1,29" +locations_default(#20055,#10000,1,29,1,29) +hasLocation(#20054,#20055) +#20056=* +tokeninfo(#20056,3,#20001,10,"43") +#20057=@"loc,{#10000},1,31,1,32" +locations_default(#20057,#10000,1,31,1,32) +hasLocation(#20056,#20057) +#20058=* +tokeninfo(#20058,8,#20001,11,"}") +#20059=@"loc,{#10000},1,34,1,34" +locations_default(#20059,#10000,1,34,1,34) +hasLocation(#20058,#20059) +#20060=* +tokeninfo(#20060,8,#20001,12,";") +#20061=@"loc,{#10000},1,35,1,35" +locations_default(#20061,#10000,1,35,1,35) +hasLocation(#20060,#20061) +#20062=* +tokeninfo(#20062,6,#20001,13,"async") +#20063=@"loc,{#10000},3,1,3,5" +locations_default(#20063,#10000,3,1,3,5) +hasLocation(#20062,#20063) +#20064=* +tokeninfo(#20064,7,#20001,14,"function") +#20065=@"loc,{#10000},3,7,3,14" +locations_default(#20065,#10000,3,7,3,14) +hasLocation(#20064,#20065) +#20066=* +tokeninfo(#20066,6,#20001,15,"f") +#20067=@"loc,{#10000},3,16,3,16" +locations_default(#20067,#10000,3,16,3,16) +hasLocation(#20066,#20067) +#20068=* +tokeninfo(#20068,8,#20001,16,"(") +#20069=@"loc,{#10000},3,17,3,17" +locations_default(#20069,#10000,3,17,3,17) +hasLocation(#20068,#20069) +#20070=* +tokeninfo(#20070,6,#20001,17,"pool") +#20071=@"loc,{#10000},3,18,3,21" +locations_default(#20071,#10000,3,18,3,21) +hasLocation(#20070,#20071) +#20072=* +tokeninfo(#20072,8,#20001,18,")") +#20073=@"loc,{#10000},3,22,3,22" +locations_default(#20073,#10000,3,22,3,22) +hasLocation(#20072,#20073) +#20074=* +tokeninfo(#20074,8,#20001,19,"{") +#20075=@"loc,{#10000},3,24,3,24" +locations_default(#20075,#10000,3,24,3,24) +hasLocation(#20074,#20075) +#20076=* +tokeninfo(#20076,6,#20001,20,"console") +#20077=@"loc,{#10000},4,3,4,9" +locations_default(#20077,#10000,4,3,4,9) +hasLocation(#20076,#20077) +#20078=* +tokeninfo(#20078,8,#20001,21,".") +#20079=@"loc,{#10000},4,10,4,10" +locations_default(#20079,#10000,4,10,4,10) +hasLocation(#20078,#20079) +#20080=* +tokeninfo(#20080,6,#20001,22,"log") +#20081=@"loc,{#10000},4,11,4,13" +locations_default(#20081,#10000,4,11,4,13) +hasLocation(#20080,#20081) +#20082=* +tokeninfo(#20082,8,#20001,23,"(") +#20083=@"loc,{#10000},4,14,4,14" +locations_default(#20083,#10000,4,14,4,14) +hasLocation(#20082,#20083) +#20084=* +tokeninfo(#20084,6,#20001,24,"o") +#20085=@"loc,{#10000},4,15,4,15" +locations_default(#20085,#10000,4,15,4,15) +hasLocation(#20084,#20085) +#20086=* +tokeninfo(#20086,8,#20001,25,".") +#20087=@"loc,{#10000},4,16,4,16" +locations_default(#20087,#10000,4,16,4,16) +hasLocation(#20086,#20087) +#20088=* +tokeninfo(#20088,6,#20001,26,"await") +#20089=@"loc,{#10000},4,17,4,21" +locations_default(#20089,#10000,4,17,4,21) +hasLocation(#20088,#20089) +#20090=* +tokeninfo(#20090,8,#20001,27,")") +#20091=@"loc,{#10000},4,22,4,22" +locations_default(#20091,#10000,4,22,4,22) +hasLocation(#20090,#20091) +#20092=* +tokeninfo(#20092,8,#20001,28,";") +#20093=@"loc,{#10000},4,23,4,23" +locations_default(#20093,#10000,4,23,4,23) +hasLocation(#20092,#20093) +#20094=* +tokeninfo(#20094,6,#20001,29,"o") +#20095=@"loc,{#10000},5,3,5,3" +locations_default(#20095,#10000,5,3,5,3) +hasLocation(#20094,#20095) +#20096=* +tokeninfo(#20096,8,#20001,30,".") +#20097=@"loc,{#10000},5,4,5,4" +locations_default(#20097,#10000,5,4,5,4) +hasLocation(#20096,#20097) +#20098=* +tokeninfo(#20098,6,#20001,31,"await") +#20099=@"loc,{#10000},5,5,5,9" +locations_default(#20099,#10000,5,5,5,9) +hasLocation(#20098,#20099) +#20100=* +tokeninfo(#20100,8,#20001,32,"=") +#20101=@"loc,{#10000},5,11,5,11" +locations_default(#20101,#10000,5,11,5,11) +hasLocation(#20100,#20101) +#20102=* +tokeninfo(#20102,3,#20001,33,"1") +#20103=@"loc,{#10000},5,13,5,13" +locations_default(#20103,#10000,5,13,5,13) +hasLocation(#20102,#20103) +#20104=* +tokeninfo(#20104,8,#20001,34,";") +#20105=@"loc,{#10000},5,14,5,14" +locations_default(#20105,#10000,5,14,5,14) +hasLocation(#20104,#20105) +#20106=* +tokeninfo(#20106,7,#20001,35,"return") +#20107=@"loc,{#10000},6,3,6,8" +locations_default(#20107,#10000,6,3,6,8) +hasLocation(#20106,#20107) +#20108=* +tokeninfo(#20108,6,#20001,36,"await") +#20109=@"loc,{#10000},6,10,6,14" +locations_default(#20109,#10000,6,10,6,14) +hasLocation(#20108,#20109) +#20110=* +tokeninfo(#20110,6,#20001,37,"pool") +#20111=@"loc,{#10000},6,16,6,19" +locations_default(#20111,#10000,6,16,6,19) +hasLocation(#20110,#20111) +#20112=* +tokeninfo(#20112,8,#20001,38,".") +#20113=@"loc,{#10000},6,20,6,20" +locations_default(#20113,#10000,6,20,6,20) +hasLocation(#20112,#20113) +#20114=* +tokeninfo(#20114,6,#20001,39,"await") +#20115=@"loc,{#10000},6,21,6,25" +locations_default(#20115,#10000,6,21,6,25) +hasLocation(#20114,#20115) +#20116=* +tokeninfo(#20116,8,#20001,40,"(") +#20117=@"loc,{#10000},6,26,6,26" +locations_default(#20117,#10000,6,26,6,26) +hasLocation(#20116,#20117) +#20118=* +tokeninfo(#20118,8,#20001,41,")") +#20119=@"loc,{#10000},6,27,6,27" +locations_default(#20119,#10000,6,27,6,27) +hasLocation(#20118,#20119) +#20120=* +tokeninfo(#20120,8,#20001,42,";") +#20121=@"loc,{#10000},6,28,6,28" +locations_default(#20121,#10000,6,28,6,28) +hasLocation(#20120,#20121) +#20122=* +tokeninfo(#20122,8,#20001,43,"}") +hasLocation(#20122,#20015) +#20123=* +tokeninfo(#20123,7,#20001,44,"function") +#20124=@"loc,{#10000},9,1,9,8" +locations_default(#20124,#10000,9,1,9,8) +hasLocation(#20123,#20124) +#20125=* +tokeninfo(#20125,8,#20001,45,"*") +#20126=@"loc,{#10000},9,9,9,9" +locations_default(#20126,#10000,9,9,9,9) +hasLocation(#20125,#20126) +#20127=* +tokeninfo(#20127,6,#20001,46,"g") +#20128=@"loc,{#10000},9,11,9,11" +locations_default(#20128,#10000,9,11,9,11) +hasLocation(#20127,#20128) +#20129=* +tokeninfo(#20129,8,#20001,47,"(") +#20130=@"loc,{#10000},9,12,9,12" +locations_default(#20130,#10000,9,12,9,12) +hasLocation(#20129,#20130) +#20131=* +tokeninfo(#20131,8,#20001,48,")") +#20132=@"loc,{#10000},9,13,9,13" +locations_default(#20132,#10000,9,13,9,13) +hasLocation(#20131,#20132) +#20133=* +tokeninfo(#20133,8,#20001,49,"{") +#20134=@"loc,{#10000},9,15,9,15" +locations_default(#20134,#10000,9,15,9,15) +hasLocation(#20133,#20134) +#20135=* +tokeninfo(#20135,7,#20001,50,"yield") +#20136=@"loc,{#10000},10,3,10,7" +locations_default(#20136,#10000,10,3,10,7) +hasLocation(#20135,#20136) +#20137=* +tokeninfo(#20137,6,#20001,51,"o") +#20138=@"loc,{#10000},10,9,10,9" +locations_default(#20138,#10000,10,9,10,9) +hasLocation(#20137,#20138) +#20139=* +tokeninfo(#20139,8,#20001,52,".") +#20140=@"loc,{#10000},10,10,10,10" +locations_default(#20140,#10000,10,10,10,10) +hasLocation(#20139,#20140) +#20141=* +tokeninfo(#20141,7,#20001,53,"yield") +#20142=@"loc,{#10000},10,11,10,15" +locations_default(#20142,#10000,10,11,10,15) +hasLocation(#20141,#20142) +#20143=* +tokeninfo(#20143,8,#20001,54,";") +#20144=@"loc,{#10000},10,16,10,16" +locations_default(#20144,#10000,10,16,10,16) +hasLocation(#20143,#20144) +#20145=* +tokeninfo(#20145,7,#20001,55,"yield") +#20146=@"loc,{#10000},11,3,11,7" +locations_default(#20146,#10000,11,3,11,7) +hasLocation(#20145,#20146) +#20147=* +tokeninfo(#20147,6,#20001,56,"o") +#20148=@"loc,{#10000},11,9,11,9" +locations_default(#20148,#10000,11,9,11,9) +hasLocation(#20147,#20148) +#20149=* +tokeninfo(#20149,8,#20001,57,"?.") +#20150=@"loc,{#10000},11,10,11,11" +locations_default(#20150,#10000,11,10,11,11) +hasLocation(#20149,#20150) +#20151=* +tokeninfo(#20151,7,#20001,58,"yield") +#20152=@"loc,{#10000},11,12,11,16" +locations_default(#20152,#10000,11,12,11,16) +hasLocation(#20151,#20152) +#20153=* +tokeninfo(#20153,8,#20001,59,";") +#20154=@"loc,{#10000},11,17,11,17" +locations_default(#20154,#10000,11,17,11,17) +hasLocation(#20153,#20154) +#20155=* +tokeninfo(#20155,8,#20001,60,"}") +hasLocation(#20155,#20025) +#20156=* +tokeninfo(#20156,7,#20001,61,"class") +#20157=@"loc,{#10000},14,1,14,5" +locations_default(#20157,#10000,14,1,14,5) +hasLocation(#20156,#20157) +#20158=* +tokeninfo(#20158,6,#20001,62,"C") +#20159=@"loc,{#10000},14,7,14,7" +locations_default(#20159,#10000,14,7,14,7) +hasLocation(#20158,#20159) +#20160=* +tokeninfo(#20160,8,#20001,63,"{") +#20161=@"loc,{#10000},14,9,14,9" +locations_default(#20161,#10000,14,9,14,9) +hasLocation(#20160,#20161) +#20162=* +tokeninfo(#20162,6,#20001,64,"async") +#20163=@"loc,{#10000},15,3,15,7" +locations_default(#20163,#10000,15,3,15,7) +hasLocation(#20162,#20163) +#20164=* +tokeninfo(#20164,6,#20001,65,"await") +#20165=@"loc,{#10000},15,9,15,13" +locations_default(#20165,#10000,15,9,15,13) +hasLocation(#20164,#20165) +#20166=* +tokeninfo(#20166,8,#20001,66,"(") +#20167=@"loc,{#10000},15,14,15,14" +locations_default(#20167,#10000,15,14,15,14) +hasLocation(#20166,#20167) +#20168=* +tokeninfo(#20168,8,#20001,67,")") +#20169=@"loc,{#10000},15,15,15,15" +locations_default(#20169,#10000,15,15,15,15) +hasLocation(#20168,#20169) +#20170=* +tokeninfo(#20170,8,#20001,68,"{") +#20171=@"loc,{#10000},15,17,15,17" +locations_default(#20171,#10000,15,17,15,17) +hasLocation(#20170,#20171) +#20172=* +tokeninfo(#20172,8,#20001,69,"}") +#20173=@"loc,{#10000},15,18,15,18" +locations_default(#20173,#10000,15,18,15,18) +hasLocation(#20172,#20173) +#20174=* +tokeninfo(#20174,8,#20001,70,"*") +#20175=@"loc,{#10000},16,3,16,3" +locations_default(#20175,#10000,16,3,16,3) +hasLocation(#20174,#20175) +#20176=* +tokeninfo(#20176,7,#20001,71,"yield") +#20177=@"loc,{#10000},16,4,16,8" +locations_default(#20177,#10000,16,4,16,8) +hasLocation(#20176,#20177) +#20178=* +tokeninfo(#20178,8,#20001,72,"(") +#20179=@"loc,{#10000},16,9,16,9" +locations_default(#20179,#10000,16,9,16,9) +hasLocation(#20178,#20179) +#20180=* +tokeninfo(#20180,8,#20001,73,")") +#20181=@"loc,{#10000},16,10,16,10" +locations_default(#20181,#10000,16,10,16,10) +hasLocation(#20180,#20181) +#20182=* +tokeninfo(#20182,8,#20001,74,"{") +#20183=@"loc,{#10000},16,12,16,12" +locations_default(#20183,#10000,16,12,16,12) +hasLocation(#20182,#20183) +#20184=* +tokeninfo(#20184,8,#20001,75,"}") +#20185=@"loc,{#10000},16,13,16,13" +locations_default(#20185,#10000,16,13,16,13) +hasLocation(#20184,#20185) +#20186=* +tokeninfo(#20186,8,#20001,76,"}") +hasLocation(#20186,#20035) +#20187=* +tokeninfo(#20187,0,#20001,77,"") +#20188=@"loc,{#10000},18,1,18,0" +locations_default(#20188,#10000,18,1,18,0) +hasLocation(#20187,#20188) +toplevels(#20001,0) +#20189=@"loc,{#10000},1,1,18,0" +locations_default(#20189,#10000,1,1,18,0) +hasLocation(#20001,#20189) +#20190=@"var;{f};{#20000}" +variables(#20190,"f",#20000) +#20191=@"var;{g};{#20000}" +variables(#20191,"g",#20000) +#20192=@"var;{o};{#20000}" +variables(#20192,"o",#20000) +#20193=@"var;{C};{#20000}" +variables(#20193,"C",#20000) +#20194=@"local_type_name;{C};{#20000}" +local_type_names(#20194,"C",#20000) +#20195=@"var;{this};{#20000}" +variables(#20195,"this",#20000) +#20196=* +stmts(#20196,22,#20001,0,"const o ... : 43 };") +hasLocation(#20196,#20003) +stmt_containers(#20196,#20001) +#20197=* +exprs(#20197,64,#20196,0,"o = { a ... d: 43 }") +#20198=@"loc,{#10000},1,7,1,34" +locations_default(#20198,#10000,1,7,1,34) +hasLocation(#20197,#20198) +enclosing_stmt(#20197,#20196) +expr_containers(#20197,#20001) +#20199=* +exprs(#20199,78,#20197,0,"o") +hasLocation(#20199,#20039) +enclosing_stmt(#20199,#20196) +expr_containers(#20199,#20001) +literals("o","o",#20199) +decl(#20199,#20192) +#20200=* +exprs(#20200,8,#20197,1,"{ await ... d: 43 }") +#20201=@"loc,{#10000},1,11,1,34" +locations_default(#20201,#10000,1,11,1,34) +hasLocation(#20200,#20201) +enclosing_stmt(#20200,#20196) +expr_containers(#20200,#20001) +#20202=* +properties(#20202,#20200,0,0,"await: 42") +#20203=@"loc,{#10000},1,13,1,21" +locations_default(#20203,#10000,1,13,1,21) +hasLocation(#20202,#20203) +#20204=* +exprs(#20204,0,#20202,0,"await") +hasLocation(#20204,#20045) +enclosing_stmt(#20204,#20196) +expr_containers(#20204,#20001) +literals("await","await",#20204) +#20205=* +exprs(#20205,3,#20202,1,"42") +hasLocation(#20205,#20049) +enclosing_stmt(#20205,#20196) +expr_containers(#20205,#20001) +literals("42","42",#20205) +#20206=* +properties(#20206,#20200,1,0,"yield: 43") +#20207=@"loc,{#10000},1,24,1,32" +locations_default(#20207,#10000,1,24,1,32) +hasLocation(#20206,#20207) +#20208=* +exprs(#20208,0,#20206,0,"yield") +hasLocation(#20208,#20053) +enclosing_stmt(#20208,#20196) +expr_containers(#20208,#20001) +literals("yield","yield",#20208) +#20209=* +exprs(#20209,3,#20206,1,"43") +hasLocation(#20209,#20057) +enclosing_stmt(#20209,#20196) +expr_containers(#20209,#20001) +literals("43","43",#20209) +#20210=* +stmts(#20210,17,#20001,1,"async f ... it();\n}") +#20211=@"loc,{#10000},3,1,7,1" +locations_default(#20211,#10000,3,1,7,1) +hasLocation(#20210,#20211) +stmt_containers(#20210,#20001) +#20212=* +exprs(#20212,78,#20210,-1,"f") +hasLocation(#20212,#20067) +expr_containers(#20212,#20210) +literals("f","f",#20212) +decl(#20212,#20190) +#20213=* +scopes(#20213,1) +scopenodes(#20210,#20213) +scopenesting(#20213,#20000) +#20214=@"var;{this};{#20213}" +variables(#20214,"this",#20213) +#20215=@"var;{pool};{#20213}" +variables(#20215,"pool",#20213) +#20216=* +exprs(#20216,78,#20210,0,"pool") +hasLocation(#20216,#20071) +expr_containers(#20216,#20210) +literals("pool","pool",#20216) +decl(#20216,#20215) +#20217=@"var;{arguments};{#20213}" +variables(#20217,"arguments",#20213) +is_arguments_object(#20217) +is_async(#20210) +#20218=* +stmts(#20218,1,#20210,-2,"{\n con ... it();\n}") +#20219=@"loc,{#10000},3,24,7,1" +locations_default(#20219,#10000,3,24,7,1) +hasLocation(#20218,#20219) +stmt_containers(#20218,#20210) +#20220=* +stmts(#20220,2,#20218,0,"console ... await);") +#20221=@"loc,{#10000},4,3,4,23" +locations_default(#20221,#10000,4,3,4,23) +hasLocation(#20220,#20221) +stmt_containers(#20220,#20210) +#20222=* +exprs(#20222,13,#20220,0,"console.log(o.await)") +#20223=@"loc,{#10000},4,3,4,22" +locations_default(#20223,#10000,4,3,4,22) +hasLocation(#20222,#20223) +enclosing_stmt(#20222,#20220) +expr_containers(#20222,#20210) +#20224=* +exprs(#20224,14,#20222,-1,"console.log") +#20225=@"loc,{#10000},4,3,4,13" +locations_default(#20225,#10000,4,3,4,13) +hasLocation(#20224,#20225) +enclosing_stmt(#20224,#20220) +expr_containers(#20224,#20210) +#20226=* +exprs(#20226,79,#20224,0,"console") +hasLocation(#20226,#20077) +enclosing_stmt(#20226,#20220) +expr_containers(#20226,#20210) +literals("console","console",#20226) +#20227=@"var;{console};{#20000}" +variables(#20227,"console",#20000) +bind(#20226,#20227) +#20228=* +exprs(#20228,0,#20224,1,"log") +hasLocation(#20228,#20081) +enclosing_stmt(#20228,#20220) +expr_containers(#20228,#20210) +literals("log","log",#20228) +#20229=* +exprs(#20229,14,#20222,0,"o.await") +#20230=@"loc,{#10000},4,15,4,21" +locations_default(#20230,#10000,4,15,4,21) +hasLocation(#20229,#20230) +enclosing_stmt(#20229,#20220) +expr_containers(#20229,#20210) +#20231=* +exprs(#20231,79,#20229,0,"o") +hasLocation(#20231,#20085) +enclosing_stmt(#20231,#20220) +expr_containers(#20231,#20210) +literals("o","o",#20231) +bind(#20231,#20192) +#20232=* +exprs(#20232,0,#20229,1,"await") +hasLocation(#20232,#20089) +enclosing_stmt(#20232,#20220) +expr_containers(#20232,#20210) +literals("await","await",#20232) +#20233=* +stmts(#20233,2,#20218,1,"o.await = 1;") +#20234=@"loc,{#10000},5,3,5,14" +locations_default(#20234,#10000,5,3,5,14) +hasLocation(#20233,#20234) +stmt_containers(#20233,#20210) +#20235=* +exprs(#20235,47,#20233,0,"o.await = 1") +#20236=@"loc,{#10000},5,3,5,13" +locations_default(#20236,#10000,5,3,5,13) +hasLocation(#20235,#20236) +enclosing_stmt(#20235,#20233) +expr_containers(#20235,#20210) +#20237=* +exprs(#20237,14,#20235,0,"o.await") +#20238=@"loc,{#10000},5,3,5,9" +locations_default(#20238,#10000,5,3,5,9) +hasLocation(#20237,#20238) +enclosing_stmt(#20237,#20233) +expr_containers(#20237,#20210) +#20239=* +exprs(#20239,79,#20237,0,"o") +hasLocation(#20239,#20095) +enclosing_stmt(#20239,#20233) +expr_containers(#20239,#20210) +literals("o","o",#20239) +bind(#20239,#20192) +#20240=* +exprs(#20240,0,#20237,1,"await") +hasLocation(#20240,#20099) +enclosing_stmt(#20240,#20233) +expr_containers(#20240,#20210) +literals("await","await",#20240) +#20241=* +exprs(#20241,3,#20235,1,"1") +hasLocation(#20241,#20103) +enclosing_stmt(#20241,#20233) +expr_containers(#20241,#20210) +literals("1","1",#20241) +#20242=* +stmts(#20242,9,#20218,2,"return ... wait();") +#20243=@"loc,{#10000},6,3,6,28" +locations_default(#20243,#10000,6,3,6,28) +hasLocation(#20242,#20243) +stmt_containers(#20242,#20210) +#20244=* +exprs(#20244,92,#20242,0,"await pool.await()") +#20245=@"loc,{#10000},6,10,6,27" +locations_default(#20245,#10000,6,10,6,27) +hasLocation(#20244,#20245) +enclosing_stmt(#20244,#20242) +expr_containers(#20244,#20210) +#20246=* +exprs(#20246,13,#20244,0,"pool.await()") +#20247=@"loc,{#10000},6,16,6,27" +locations_default(#20247,#10000,6,16,6,27) +hasLocation(#20246,#20247) +enclosing_stmt(#20246,#20242) +expr_containers(#20246,#20210) +#20248=* +exprs(#20248,14,#20246,-1,"pool.await") +#20249=@"loc,{#10000},6,16,6,25" +locations_default(#20249,#10000,6,16,6,25) +hasLocation(#20248,#20249) +enclosing_stmt(#20248,#20242) +expr_containers(#20248,#20210) +#20250=* +exprs(#20250,79,#20248,0,"pool") +hasLocation(#20250,#20111) +enclosing_stmt(#20250,#20242) +expr_containers(#20250,#20210) +literals("pool","pool",#20250) +bind(#20250,#20215) +#20251=* +exprs(#20251,0,#20248,1,"await") +hasLocation(#20251,#20115) +enclosing_stmt(#20251,#20242) +expr_containers(#20251,#20210) +literals("await","await",#20251) +#20252=* +stmts(#20252,17,#20001,2,"functio ... ield;\n}") +#20253=@"loc,{#10000},9,1,12,1" +locations_default(#20253,#10000,9,1,12,1) +hasLocation(#20252,#20253) +stmt_containers(#20252,#20001) +#20254=* +exprs(#20254,78,#20252,-1,"g") +hasLocation(#20254,#20128) +expr_containers(#20254,#20252) +literals("g","g",#20254) +decl(#20254,#20191) +#20255=* +scopes(#20255,1) +scopenodes(#20252,#20255) +scopenesting(#20255,#20000) +#20256=@"var;{this};{#20255}" +variables(#20256,"this",#20255) +#20257=@"var;{arguments};{#20255}" +variables(#20257,"arguments",#20255) +is_arguments_object(#20257) +is_generator(#20252) +#20258=* +stmts(#20258,1,#20252,-2,"{\n yie ... ield;\n}") +#20259=@"loc,{#10000},9,15,12,1" +locations_default(#20259,#10000,9,15,12,1) +hasLocation(#20258,#20259) +stmt_containers(#20258,#20252) +#20260=* +stmts(#20260,2,#20258,0,"yield o.yield;") +#20261=@"loc,{#10000},10,3,10,16" +locations_default(#20261,#10000,10,3,10,16) +hasLocation(#20260,#20261) +stmt_containers(#20260,#20252) +#20262=* +exprs(#20262,69,#20260,0,"yield o.yield") +#20263=@"loc,{#10000},10,3,10,15" +locations_default(#20263,#10000,10,3,10,15) +hasLocation(#20262,#20263) +enclosing_stmt(#20262,#20260) +expr_containers(#20262,#20252) +#20264=* +exprs(#20264,14,#20262,0,"o.yield") +#20265=@"loc,{#10000},10,9,10,15" +locations_default(#20265,#10000,10,9,10,15) +hasLocation(#20264,#20265) +enclosing_stmt(#20264,#20260) +expr_containers(#20264,#20252) +#20266=* +exprs(#20266,79,#20264,0,"o") +hasLocation(#20266,#20138) +enclosing_stmt(#20266,#20260) +expr_containers(#20266,#20252) +literals("o","o",#20266) +bind(#20266,#20192) +#20267=* +exprs(#20267,0,#20264,1,"yield") +hasLocation(#20267,#20142) +enclosing_stmt(#20267,#20260) +expr_containers(#20267,#20252) +literals("yield","yield",#20267) +#20268=* +stmts(#20268,2,#20258,1,"yield o?.yield;") +#20269=@"loc,{#10000},11,3,11,17" +locations_default(#20269,#10000,11,3,11,17) +hasLocation(#20268,#20269) +stmt_containers(#20268,#20252) +#20270=* +exprs(#20270,69,#20268,0,"yield o?.yield") +#20271=@"loc,{#10000},11,3,11,16" +locations_default(#20271,#10000,11,3,11,16) +hasLocation(#20270,#20271) +enclosing_stmt(#20270,#20268) +expr_containers(#20270,#20252) +#20272=* +exprs(#20272,14,#20270,0,"o?.yield") +#20273=@"loc,{#10000},11,9,11,16" +locations_default(#20273,#10000,11,9,11,16) +hasLocation(#20272,#20273) +enclosing_stmt(#20272,#20268) +expr_containers(#20272,#20252) +#20274=* +exprs(#20274,79,#20272,0,"o") +hasLocation(#20274,#20148) +enclosing_stmt(#20274,#20268) +expr_containers(#20274,#20252) +literals("o","o",#20274) +bind(#20274,#20192) +#20275=* +exprs(#20275,0,#20272,1,"yield") +hasLocation(#20275,#20152) +enclosing_stmt(#20275,#20268) +expr_containers(#20275,#20252) +literals("yield","yield",#20275) +isOptionalChaining(#20272) +#20276=* +stmts(#20276,26,#20001,3,"class C ... () {}\n}") +#20277=@"loc,{#10000},14,1,17,1" +locations_default(#20277,#10000,14,1,17,1) +hasLocation(#20276,#20277) +stmt_containers(#20276,#20001) +#20278=* +exprs(#20278,78,#20276,0,"C") +hasLocation(#20278,#20159) +enclosing_stmt(#20278,#20276) +expr_containers(#20278,#20001) +literals("C","C",#20278) +decl(#20278,#20193) +typedecl(#20278,#20194) +#20279=* +scopes(#20279,10) +scopenodes(#20276,#20279) +scopenesting(#20279,#20000) +#20280=@"var;{this};{#20279}" +variables(#20280,"this",#20279) +#20281=* +properties(#20281,#20276,2,0,"async await() {}") +#20282=@"loc,{#10000},15,3,15,18" +locations_default(#20282,#10000,15,3,15,18) +hasLocation(#20281,#20282) +#20283=* +exprs(#20283,0,#20281,0,"await") +hasLocation(#20283,#20165) +enclosing_stmt(#20283,#20276) +expr_containers(#20283,#20001) +literals("await","await",#20283) +#20284=* +exprs(#20284,9,#20281,1,"() {}") +#20285=@"loc,{#10000},15,14,15,18" +locations_default(#20285,#10000,15,14,15,18) +hasLocation(#20284,#20285) +enclosing_stmt(#20284,#20276) +expr_containers(#20284,#20001) +#20286=* +scopes(#20286,1) +scopenodes(#20284,#20286) +scopenesting(#20286,#20279) +#20287=@"var;{this};{#20286}" +variables(#20287,"this",#20286) +#20288=@"var;{arguments};{#20286}" +variables(#20288,"arguments",#20286) +is_arguments_object(#20288) +is_async(#20284) +#20289=* +stmts(#20289,1,#20284,-2,"{}") +#20290=@"loc,{#10000},15,17,15,18" +locations_default(#20290,#10000,15,17,15,18) +hasLocation(#20289,#20290) +stmt_containers(#20289,#20284) +is_method(#20281) +#20291=* +properties(#20291,#20276,3,0,"*yield() {}") +#20292=@"loc,{#10000},16,3,16,13" +locations_default(#20292,#10000,16,3,16,13) +hasLocation(#20291,#20292) +#20293=* +exprs(#20293,0,#20291,0,"yield") +hasLocation(#20293,#20177) +enclosing_stmt(#20293,#20276) +expr_containers(#20293,#20001) +literals("yield","yield",#20293) +#20294=* +exprs(#20294,9,#20291,1,"() {}") +#20295=@"loc,{#10000},16,9,16,13" +locations_default(#20295,#10000,16,9,16,13) +hasLocation(#20294,#20295) +enclosing_stmt(#20294,#20276) +expr_containers(#20294,#20001) +#20296=* +scopes(#20296,1) +scopenodes(#20294,#20296) +scopenesting(#20296,#20279) +#20297=@"var;{this};{#20296}" +variables(#20297,"this",#20296) +#20298=@"var;{arguments};{#20296}" +variables(#20298,"arguments",#20296) +is_arguments_object(#20298) +is_generator(#20294) +#20299=* +stmts(#20299,1,#20294,-2,"{}") +#20300=@"loc,{#10000},16,12,16,13" +locations_default(#20300,#10000,16,12,16,13) +hasLocation(#20299,#20300) +stmt_containers(#20299,#20294) +is_method(#20291) +#20301=* +properties(#20301,#20276,4,0,"constructor() {}") +#20302=@"loc,{#10000},14,9,14,8" +locations_default(#20302,#10000,14,9,14,8) +hasLocation(#20301,#20302) +#20303=* +exprs(#20303,0,#20301,0,"constructor") +hasLocation(#20303,#20302) +enclosing_stmt(#20303,#20276) +expr_containers(#20303,#20001) +literals("constructor","constructor",#20303) +#20304=* +exprs(#20304,9,#20301,1,"() {}") +hasLocation(#20304,#20302) +enclosing_stmt(#20304,#20276) +expr_containers(#20304,#20001) +#20305=* +scopes(#20305,1) +scopenodes(#20304,#20305) +scopenesting(#20305,#20279) +#20306=@"var;{this};{#20305}" +variables(#20306,"this",#20305) +#20307=@"var;{arguments};{#20305}" +variables(#20307,"arguments",#20305) +is_arguments_object(#20307) +#20308=* +stmts(#20308,1,#20304,-2,"{}") +hasLocation(#20308,#20302) +stmt_containers(#20308,#20304) +is_method(#20301) +#20309=* +entry_cfg_node(#20309,#20001) +#20310=@"loc,{#10000},1,1,1,0" +locations_default(#20310,#10000,1,1,1,0) +hasLocation(#20309,#20310) +#20311=* +exit_cfg_node(#20311,#20001) +hasLocation(#20311,#20188) +successor(#20304,#20301) +#20312=* +entry_cfg_node(#20312,#20304) +hasLocation(#20312,#20302) +#20313=* +exit_cfg_node(#20313,#20304) +hasLocation(#20313,#20302) +successor(#20308,#20313) +successor(#20312,#20308) +successor(#20303,#20304) +successor(#20301,#20276) +successor(#20294,#20291) +#20314=* +entry_cfg_node(#20314,#20294) +#20315=@"loc,{#10000},16,9,16,8" +locations_default(#20315,#10000,16,9,16,8) +hasLocation(#20314,#20315) +#20316=* +exit_cfg_node(#20316,#20294) +#20317=@"loc,{#10000},16,14,16,13" +locations_default(#20317,#10000,16,14,16,13) +hasLocation(#20316,#20317) +successor(#20299,#20316) +successor(#20314,#20299) +successor(#20293,#20294) +successor(#20291,#20303) +successor(#20284,#20281) +#20318=* +entry_cfg_node(#20318,#20284) +#20319=@"loc,{#10000},15,14,15,13" +locations_default(#20319,#10000,15,14,15,13) +hasLocation(#20318,#20319) +#20320=* +exit_cfg_node(#20320,#20284) +#20321=@"loc,{#10000},15,19,15,18" +locations_default(#20321,#10000,15,19,15,18) +hasLocation(#20320,#20321) +successor(#20289,#20320) +successor(#20318,#20289) +successor(#20283,#20284) +successor(#20281,#20293) +successor(#20278,#20283) +successor(#20276,#20311) +successor(#20252,#20278) +#20322=* +entry_cfg_node(#20322,#20252) +#20323=@"loc,{#10000},9,1,9,0" +locations_default(#20323,#10000,9,1,9,0) +hasLocation(#20322,#20323) +#20324=* +exit_cfg_node(#20324,#20252) +#20325=@"loc,{#10000},12,2,12,1" +locations_default(#20325,#10000,12,2,12,1) +hasLocation(#20324,#20325) +successor(#20268,#20274) +successor(#20275,#20272) +successor(#20274,#20275) +successor(#20272,#20270) +successor(#20274,#20270) +successor(#20270,#20324) +successor(#20260,#20266) +successor(#20267,#20264) +successor(#20266,#20267) +successor(#20264,#20262) +successor(#20262,#20268) +successor(#20258,#20260) +successor(#20322,#20258) +successor(#20210,#20252) +#20326=* +entry_cfg_node(#20326,#20210) +#20327=@"loc,{#10000},3,1,3,0" +locations_default(#20327,#10000,3,1,3,0) +hasLocation(#20326,#20327) +#20328=* +exit_cfg_node(#20328,#20210) +#20329=@"loc,{#10000},7,2,7,1" +locations_default(#20329,#10000,7,2,7,1) +hasLocation(#20328,#20329) +successor(#20251,#20248) +successor(#20250,#20251) +successor(#20248,#20246) +successor(#20246,#20244) +successor(#20244,#20242) +successor(#20242,#20328) +successor(#20233,#20239) +successor(#20241,#20235) +successor(#20240,#20237) +successor(#20239,#20240) +successor(#20237,#20241) +successor(#20235,#20250) +successor(#20220,#20226) +successor(#20232,#20229) +successor(#20231,#20232) +successor(#20229,#20222) +successor(#20228,#20224) +successor(#20226,#20228) +successor(#20224,#20231) +successor(#20222,#20233) +successor(#20218,#20220) +successor(#20216,#20218) +successor(#20326,#20216) +successor(#20196,#20199) +successor(#20200,#20204) +successor(#20209,#20206) +successor(#20208,#20209) +successor(#20206,#20197) +successor(#20205,#20202) +successor(#20204,#20205) +successor(#20202,#20208) +successor(#20199,#20200) +successor(#20197,#20210) +successor(#20254,#20196) +successor(#20212,#20254) +successor(#20309,#20212) +numlines(#10000,17,14,0) +filetype(#10000,"javascript") diff --git a/javascript/ql/lib/change-notes/2026-09-07-await-property.md b/javascript/ql/lib/change-notes/2026-09-07-await-property.md new file mode 100644 index 000000000000..cfaa1b9e02d6 --- /dev/null +++ b/javascript/ql/lib/change-notes/2026-09-07-await-property.md @@ -0,0 +1,4 @@ +--- +category: fix +--- +* Fixed a spurious parse error when `await` is used as a property name inside an `async` function, or `yield` as a property name inside a generator. For example, `await pool.await()` is now extracted correctly.