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

Deafault/Destructured Parameter Error #6081

Closed
machineghost opened this issue Apr 6, 2016 · 4 comments
Closed

Deafault/Destructured Parameter Error #6081

machineghost opened this issue Apr 6, 2016 · 4 comments
Labels
question Issues that look for answers.

Comments

@machineghost
Copy link

machineghost commented Apr 6, 2016

Version: v5.9.1
Platform: Linux mymachine 3.16.0-62-generic #83~14.04.1-Ubuntu SMP Fri Feb 26 22:52:39 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Expected: Default and destructured parameters can be combined without error (as they can be in the latest version of Chrome)

Actual: Using both results in a ReferenceError

Steps to reproduce:

  1. Start Node with some harmony flags: node --harmony --harmony_default_parameters --harmony_destructring

  2. Enter this line of code (({foo}={}) => {console.log(foo);})({foo: 'baz'});

// Human-friendly version
function logFooProperty({foo}={}) {
    console.log(foo);
};
logFooProperty({foo: 'baz'} );`
  1. Get an error:
    ReferenceError: Invalid left-hand side in assignment
    at Object.exports.createScript (vm.js:24:10)
    at REPLServer.defaultEval (repl.js:233:25)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:429:12)
    at emitOne (events.js:95:20)
    at REPLServer.emit (events.js:182:7)
    at REPLServer.Interface._onLine (readline.js:211:10)
    at REPLServer.Interface._line (readline.js:550:8)
    at REPLServer.Interface._ttyWrite (readline.js:827:14)

Currently both default and destrctured parameters work on their own:

(({foo}) => {console.log(foo);})({foo: 'baz'}); // works
((options={}) => {console.log(options.foo);})({foo: 'baz'});

and the two can be combined in Chrome without error, so it seems as though Node (when started with the appropriate harmony flags) should also be able to combine the two without error.

@MylesBorins MylesBorins added the question Issues that look for answers. label Apr 6, 2016
@MylesBorins
Copy link
Member

@machineghost Node is not running the exact same version of v8 as chrome. es6 features behind a flag are currently un supported.

Expect a big v8 update in the coming week as we release node v6

Closing for now as this is not something that can be fixed on v5

@machineghost
Copy link
Author

Wow, so fast!

And yeah, while I understood that these were experimental features I still thought you might want bug reports on them. But if all that code is going away soon then there's certainly no need.

Thanks.

@dnalborczyk
Copy link
Contributor

It'll work in v6 (just tested it), coming likely end of this month. You can run pretty much all ES2015 features (except modules) without flags with the next coming major version.

If you are interested check out the vee-eight-v5.0 branch.

Daniel

@machineghost
Copy link
Author

@dnalborczyk: while I would love to check out that branch, I have to share a codebase with others (who will get annoyed at me if I check in code that doesn't work for them), so I'll hold out for the official release. Thanks for the update though!.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issues that look for answers.
Projects
None yet
Development

No branches or pull requests

3 participants