Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • S sweet-core
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 62
    • Issues 62
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • sweet-js
  • sweet-core
  • Merge requests
  • !650

Throw error when missing commas in Array and Object expressions

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Gabe Johnson requested to merge fix-auto-comma-insertion into master Mar 18, 2017
  • Overview 12
  • Commits 4
  • Pipelines 0
  • Changes 2

Fixes #605 (closed)

Formerly:

[1 2 3]; // [1, 2, 3];

let [a b c] = []; // let [a, b, c] = [];

({ a: 1 b: 2 c: 3 }); // ({a: 1, b:2, c: 3});

let { a b c } = {}; // let { a, b, c } = {};

let [...rest, a] = []; // let [...rest_0] = [];

[...[],]; // [...[],,];

All of these cases save the last should throw (it was simply parsing incorrectly). Now they do:

[1 2 3]
// Error: unexpected token
// __2__ 3

let [a b c] = [];
// Error: unexpected token
// __b__ c

({ a: 1 b: 2 c: 3 })
// Error: unexpected token
// __b__ : 2 c : 3

let { a b c } = {};
// Error: unexpected token
// __b__ c

let [...rest, a] = [];
// Error: Rest element must be last element in array
// , a

[...[],]; // [...[]];
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: fix-auto-comma-insertion