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

Async function declaration with destructuring object is not supported #86

Closed
victor-cr opened this issue Dec 20, 2018 · 5 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@victor-cr
Copy link

victor-cr commented Dec 20, 2018

In the given valid Node.JS example:

const f = async ({a = 1, b = 'bbb'}) => {
  return a + b;
};
f({}).then(console.log);

I get the error

SyntaxError: Invalid shorthand property name initializer in object literal
    at new Script (vm.js:73:7)
    at createScript (vm.js:245:10)
    at Object.runInThisContext (vm.js:297:10)
    at Module._compile (internal/modules/cjs/loader.js:657:28)
    at Object.<anonymous> (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function._load (internal/modules/cjs/loader.js:530:3)
    at Function.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:295:19)

While vanila Node.JS v10.14.2 returns 1bbb
Also, if I remove either async or default values of the destructuring object - it works in Graal like a charm.
I am using GraalVM CE 1.0.0-rc10

@iamstolis
Copy link
Member

Thank you for reporting this issue. It looks like a bug in our parsing of async arrow functions. Note that we seem to parse

const f = async function ({a = 1, b = 'bbb'}) {
  return a + b;
};

correctly, i.e., you can rewrite the code to avoid async arrow functions as a workaround (until we fix the issue).

@iamstolis iamstolis added the bug Something isn't working label Dec 21, 2018
@victor-cr
Copy link
Author

Unfortunately for me, I found that in 3rd party library and just extracted the minimal example from it.

@iamstolis
Copy link
Member

Unfortunately for me, I found that in 3rd party library ...

I was afraid that this will be the case. Is that library/npm module public? If so, which one is it? I hope to have a fix soon and I would like to verify it against the original code that disclosed this problem, if possible.

@victor-cr
Copy link
Author

victor-cr commented Dec 21, 2018

victor-cr pushed a commit to victor-cr/graaljs that referenced this issue Dec 21, 2018
victor-cr pushed a commit to victor-cr/graaljs that referenced this issue Dec 21, 2018
@woess
Copy link
Member

woess commented Dec 29, 2018

Thanks for the report! @iamstolis has fixed the bug in 8f39670.

@woess woess closed this as completed Dec 29, 2018
graalvmbot pushed a commit that referenced this issue Sep 1, 2021
Original commit message:

    M86-LTS: [compiler] Fix a bug in VisitSpeculativeIntegerAdditiveOp

    (cherry picked from commit 9313c4ce3f32ad81df1c65becccec7e129181ce3)

    No-Try: true
    No-Presubmit: true
    No-Tree-Checks: true
    Bug: chromium:1199345
    Change-Id: I33bf71b33f43919fec4684054b5bf0a0787930ca
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2831478
    Reviewed-by: Nico Hartmann <[email protected]>
    Commit-Queue: Georg Neis <[email protected]>
    Cr-Original-Commit-Position: refs/heads/master@{#74008}
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2848412
    Commit-Queue: Artem Sumaneev <[email protected]>
    Reviewed-by: Victor-Gabriel Savu <[email protected]>
    Cr-Commit-Position: refs/branch-heads/8.6@{#86}
    Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1}
    Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472}

Refs: v8/v8@ab2340a

PR-URL: nodejs/node#38481
Reviewed-By: Richard Lau <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants