bytecodealliance / javy

JS to WebAssembly toolchain
Apache License 2.0
2.3k stars 111 forks source link

Errors in async top-level functions do not result in traps #627

Open jeffcharles opened 7 months ago

jeffcharles commented 7 months ago

Operating system: MacOS 14.4.1 (Sanoma) Processor architecture: Apple M3 Rust version: 1.77.1 Javy version: f270956bc9f7164efd4ea873d9f727356a4c1499

Problem

Errors in async functions do not result in error messages or traps.

Error Message and Context

Compiling and running:

(async function() {
    adfasdfsa;
})();

should throw a syntax error and trap. Right now it exits successfully with no error messages.

This does not require the experimental_event_loop feature to be enabled.

jeffcharles commented 7 months ago

It looks like this behaviour reproduces with the latest native QuickJS:

➜  quickjs git:(master) ./qjs    
QuickJS - Type "\h" for help
qjs > (async function() {
({  ...         asdfasd;
({  ...         })()
{  }
qjs > (function() {
({  ...         asdfasdf;
({  ...         })()
ReferenceError: 'asdfasdf' is not defined
    at <anonymous> (<evalScript>:2)
    at <eval> (<evalScript>:3)