[quickjs-devel] Re: Parser bug

  • From: Fabrice Bellard <fabrice@xxxxxxxxxxx>
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Mon, 29 Jun 2020 20:29:56 +0200

Hi,

The bug is related to an already signaled bug (message of 25/05/2020) related to the skipping of templates. It will be fixed in the next release.

Best regards,

Fabrice.

On 06/29/2020 05:57 PM, Alex Protasenko wrote:

Hi All,

This one is not easy to demonstrate, but a syntax exception is erroneously recorded internally for the following snippet:

```

let b={a:`${1}`};

```

The problem is, it's not reported to the user at compile time and the script ends up being compiled just fine. It can only be tripped over (reported) by some random "C" extension function when script evaluates/runs.

Suppose we add an extension module called "test.so" with the following function to re-throw an internally recorded exception, which somehow wasn't returned/retrieved by the runtime:

```

static JSValue js_rethrow(JSContext *ctx, JSValueConst this_val,
                           int argc, JSValueConst *argv)
{
     JSValue error = JS_GetException(ctx);
     if (!JS_IsNull(error) && !JS_IsUndefined(error))
         return JS_Throw(ctx, error); //rethrow
     return JS_UNDEFINED;
}

```

Now, if we run this script:

```

import {rethrow} from "./test.so";

rethrow();

let b={a:`${1}`};

```

we get:

SyntaxError: unexpected end of string
     at /file/path/test.js:5


Thanks

Alex




Other related posts: