Skip to content

Destructuring of objects within arrays can generate invalid JavaScript #4787

@sharpblue

Description

@sharpblue

The combination of object and array destructuring seems not to work correctly when using ... in the array destructuring part. For example

[...,{forename,surname}] = arr

generates

var forename, surname;

{forename, surname} = arr[arr.length - 1];

but should generate

var forename, surname;

({forename, surname} = arr[arr.length - 1]);

In CoffeeScript 1.9.1 the same code compiles to

var forename, ref, surname;

(ref = arr[arr.length - 1], forename = ref.forename, surname = ref.surname);

which is valid JavaScript.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions