Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some await expressions break XS parsing #1394

Closed
gibson042 opened this issue Aug 20, 2024 · 3 comments
Closed

Some await expressions break XS parsing #1394

gibson042 opened this issue Aug 20, 2024 · 3 comments

Comments

@gibson042
Copy link

gibson042 commented Aug 20, 2024

Environment: XS 15.5.1, slot 32 bytes, ID 4 bytes

Description
XS fails to parse a ConditionalExpression that starts with an await.

Steps to Reproduce

async function fn() {
  const notAwaited = {
    then() { throw Error("unexpected `then` invocation"); },
  };
  await null ?? notAwaited; // but at least `||` and `&&` are also affected
}
print("START");
fn().then(() => print("END"));

Actual behavior

SyntaxError: missing ;

Expected behavior

START
END

In statement position with an Await parameter (e.g., inside an async function), await null ?? notAwaited; should parse as:

test262 pull request: tc39/test262#4204

@phoddie
Copy link
Collaborator

phoddie commented Aug 21, 2024

Thanks for reporting this.

The issue is real but more obscure than it seems at first. The problem only happens if the (Stage 3) explicit resource management API support is enabled in the XS build with mxExplicitResourceManagement. That is only the case in xst -- which is, of course, what you are using in your tests here. The Moddable SDK today defaults to explicit resource management being off.

The problem is caused by using not being a keyword and the lookahead required in the parser to handle that. Obviously we need to correct this, but it may take a bit as it is a little tricky.

@phoddie
Copy link
Collaborator

phoddie commented Sep 1, 2024

Quick update – we are testing a fix for this. It requires some non-trivial changes to the parser for the additional look-ahead, so we are testing it internally for a bit before pushing it public.

mkellner pushed a commit that referenced this issue Sep 13, 2024
@phoddie
Copy link
Collaborator

phoddie commented Sep 14, 2024

Fixed.

@phoddie phoddie closed this as completed Sep 14, 2024
cmidgley pushed a commit to Intellisplash/moddable that referenced this issue Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants