Skip to content

Conversation

@onepointerT
Copy link

@onepointerT onepointerT commented Mar 22, 2024

Solves the error 'Unexpected reserved word "await"':

 dir = (await opendir(this.path)); ^^^^^ SyntaxError: Unexpected reserved word at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:152:18) at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:298:14) Node.js v18.19.1```` 
Solves the error 'Unexpected reserved word "await"': ```` dir = (await opendir(this.path)); ^^^^^ SyntaxError: Unexpected reserved word at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:152:18) at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:298:14) Node.js v18.19.1````
@GeoffreyBooth
Copy link
Collaborator

This needs tests, and you need to commit the compiled output.

@onepointerT
Copy link
Author

onepointerT commented Mar 22, 2024

I'm not from yesterday, I know that and what testing is. I've tested it on the same testing script. The output is omitted, because no further output on that functionality. After using the corrected commit I've got output on a completly other topic, import statements in ES scripts, with "type": "module" in package.json. The problem with the asyncronous await is patched and delivers no further output, I manually controlled the function, it is now an async function, before the commit it was a simple function.

@edemaine
Copy link
Contributor

What's the input that causes the output error you mention?

I'm worried that this code will add async to the outer function in this case (but I didn't test):

-> -> await undefined
@onepointerT
Copy link
Author

onepointerT commented Mar 23, 2024

export class File extends Path constructor: (path) -> super path readSync: () -> fd = await open @path 'r' return fd.createReadStream() writeSync: (data) -> fd = await open @path 'rw' return fd.createWriteStream data 

Somehow an await undefined sounds a little bit silly, since loops that iterate unless the stack is empty are implemented already. This feature request is required on every async function use inside of a function, except the already included async functionality with For and Of.

What's the input that causes the output error you mention?

I'm worried that this code will add async to the outer function in this case (but I didn't test):

-> -> await undefined
@edemaine
Copy link
Contributor

Your code already compiles to

export var File = class File extends Path { constructor(path) { super(path); } async readSync() { var fd; fd = (await open(this.path('r'))); return fd.createReadStream(); } async writeSync(data) { var fd; fd = (await open(this.path('rw'))); return fd.createWriteStream(data); } };

It seems that async is already where it needs to be. So I'm not sure what this PR is aiming to fix. It would help if you added a test that is broken with the current CoffeeScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants