Skip to content

Deafault/Destructured Parameter Error #6081

Closed
@machineghost

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionIssues that look for answers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions