You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
js2-mode struggles with this code. async *... within class context seems not to be recognized. The parsed function ends up not being set as async, which means the await is incorrectly flagged as occurring within a non-async function ("msg.bad.await").
#!/usr/bin/env node
classToy{// (1) `async` not detected correctly// (2) `*` not treated correctly// (3) `await` treated as "msg.bad.await"async*oneByOne(){constresp=awaitthis.getRecords();for(constrecofresp.records){yieldrec;}}// `async` / `await` have no parsing errors hereasyncgetRecords(){constout=awaitPromise.resolve({records: [1,2,3]});returnout;}// `*` treated correctly here*correctGeneratorDetection(){for(constrof[1,2,3]){yieldr;}}}(async()=>{consttoy=newToy();forawait(constrecoftoy.oneByOne()){console.log(rec);}})();
There's also a superflous complaint from the code above that the * at *all requires a colon ("msg.no.colon.prop").
📸 click here to see screenshot
Similar, but not identical, parsing errors occur when converting the above code to a simple object. In this next example, the * in *all still shows an error ("msg.no.colon.prop"). The function is not recognized as a generator though, since yield also shows an error ("msg.bad.yield").
#!/usr/bin/env node
constobj={// (1) `async` not detected correctly// (2) `*` not treated correctly (error: "msg.no.colon.prop")// (3) `yield` treated as an error (error: "msg.bad.yield")async*all(){constresp=awaitgetRecords();for(constrecofresp.records){yieldrec;}}};// (4) generic "syntax error" (error: "msg.syntax")asyncfunctiongetRecords(){returnPromise.resolve({records: [1,2,3]});}(async()=>{forawait(constrecofobj.all()){console.log(rec);}})();
📸 click here to see screenshot
In both cases, both pieces of code really do run, and simply log 1\n2\n3\n.
My environment:
node version: 14, 16, 18
js2-mode version: 20230408 (specifically, a fresh clone of this repo, with HEAD at 79bc78d)
GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2023-11-27
The text was updated successfully, but these errors were encountered:
js2-mode
struggles with this code.async *...
withinclass
context seems not to be recognized. The parsed function ends up not being set as async, which means theawait
is incorrectly flagged as occurring within a non-async function ("msg.bad.await"
).There's also a superflous complaint from the code above that the
*
at*all
requires a colon ("msg.no.colon.prop"
).📸 click here to see screenshot
Similar, but not identical, parsing errors occur when converting the above code to a simple object. In this next example, the
*
in*all
still shows an error ("msg.no.colon.prop"
). The function is not recognized as a generator though, sinceyield
also shows an error ("msg.bad.yield"
).📸 click here to see screenshot
In both cases, both pieces of code really do run, and simply log
1\n2\n3\n
.My environment:
HEAD
at 79bc78d)The text was updated successfully, but these errors were encountered: