{"action":"created","issue":{"url":"https://api.github.com/repos/jquery/esprima/issues/1065","labels_url":"https://api.github.com/repos/jquery/esprima/issues/1065/labels{/name}","comments_url":"https://api.github.com/repos/jquery/esprima/issues/1065/comments","events_url":"https://api.github.com/repos/jquery/esprima/issues/1065/events","html_url":"https://github.com/jquery/esprima/issues/1065","id":58082142,"number":1065,"title":"ES6 feature: Let and Const Declaration","user":{"login":"ariya","id":7288,"avatar_url":"https://avatars.githubusercontent.com/u/7288?v=3","gravatar_id":"","url":"https://api.github.com/users/ariya","html_url":"https://github.com/ariya","followers_url":"https://api.github.com/users/ariya/followers","following_url":"https://api.github.com/users/ariya/following{/other_user}","gists_url":"https://api.github.com/users/ariya/gists{/gist_id}","starred_url":"https://api.github.com/users/ariya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ariya/subscriptions","organizations_url":"https://api.github.com/users/ariya/orgs","repos_url":"https://api.github.com/users/ariya/repos","events_url":"https://api.github.com/users/ariya/events{/privacy}","received_events_url":"https://api.github.com/users/ariya/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jquery/esprima/labels/es6","name":"es6","color":"006b75"}],"state":"closed","locked":false,"assignee":{"login":"ariya","id":7288,"avatar_url":"https://avatars.githubusercontent.com/u/7288?v=3","gravatar_id":"","url":"https://api.github.com/users/ariya","html_url":"https://github.com/ariya","followers_url":"https://api.github.com/users/ariya/followers","following_url":"https://api.github.com/users/ariya/following{/other_user}","gists_url":"https://api.github.com/users/ariya/gists{/gist_id}","starred_url":"https://api.github.com/users/ariya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ariya/subscriptions","organizations_url":"https://api.github.com/users/ariya/orgs","repos_url":"https://api.github.com/users/ariya/repos","events_url":"https://api.github.com/users/ariya/events{/privacy}","received_events_url":"https://api.github.com/users/ariya/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/jquery/esprima/milestones/1","html_url":"https://github.com/jquery/esprima/milestones/2.1","labels_url":"https://api.github.com/repos/jquery/esprima/milestones/1/labels","id":977653,"number":1,"title":"2.1","description":"classes: https://github.com/jquery/esprima/issues/1001\r\nrest parameters: https://github.com/jquery/esprima/issues/1011\r\nlet and const:","creator":{"login":"mikesherov","id":364532,"avatar_url":"https://avatars.githubusercontent.com/u/364532?v=3","gravatar_id":"","url":"https://api.github.com/users/mikesherov","html_url":"https://github.com/mikesherov","followers_url":"https://api.github.com/users/mikesherov/followers","following_url":"https://api.github.com/users/mikesherov/following{/other_user}","gists_url":"https://api.github.com/users/mikesherov/gists{/gist_id}","starred_url":"https://api.github.com/users/mikesherov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikesherov/subscriptions","organizations_url":"https://api.github.com/users/mikesherov/orgs","repos_url":"https://api.github.com/users/mikesherov/repos","events_url":"https://api.github.com/users/mikesherov/events{/privacy}","received_events_url":"https://api.github.com/users/mikesherov/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":8,"state":"open","created_at":"2015-02-12T23:23:06Z","updated_at":"2015-03-05T06:36:01Z","due_on":"2015-03-06T08:00:00Z","closed_at":null},"comments":10,"created_at":"2015-02-18T15:28:31Z","updated_at":"2015-03-05T06:36:01Z","closed_at":"2015-03-05T06:36:01Z","body":"## Syntax:\r\n\r\nPer Rev 32 (Feb 2, 2015) of the draft spec, the relevant grammar is on [Section 13.2.1](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-let-and-const-declarations) on *Let and Const Declarations*:\r\n\r\n```\r\nLexicalDeclaration[In, Yield] :\r\n  LetOrConst BindingList[?In, ?Yield] ;\r\n\r\nLetOrConst :\r\n  let\r\n  const\r\n\r\nBindingList[In, Yield] :\r\n  LexicalBinding[?In, ?Yield]\r\n  BindingList[?In, ?Yield] , LexicalBinding[?In, ?Yield]\r\n\r\nLexicalBinding[In, Yield] :\r\n  BindingIdentifier[?Yield] Initializer[?In, ?Yield]opt\r\n  BindingPattern[?Yield] Initializer[?In, ?Yield]\r\n```\r\n\r\n**Referred to by:**\r\n\r\nDeclaration:\r\n\r\n```\r\nDeclaration[Yield] :\r\n  HoistableDeclaration _[?Yield]\r\n  ClassDeclaration[?Yield]\r\n  LexicalDeclaration[In, ?Yield]\r\n```\r\n\r\nStatementListItem:\r\n\r\n```\r\nStatementListItem[Yield, Return] :\r\n  Statement[?Yield, ?Return]\r\n  Declaration[?Yield]\r\n```\r\n\r\nIteration:\r\n\r\n```\r\nfor ( LexicalDeclaration[?Yield] Expression[In, ?Yield]opt ; Expression[In, ?Yield]opt ) Statement[?Yield, ?Return]\r\nfor ( ForDeclaration[?Yield] in Expression[In, ?Yield] ) Statement[?Yield, ?Return]\r\n```\r\n\r\nwhereas:\r\n\r\n```\r\nForDeclaration[Yield] :\r\n  LetOrConst ForBinding[?Yield]\r\n\r\nForBinding[Yield] :\r\n  BindingIdentifier[?Yield]\r\n  BindingPattern[?Yield]\r\n```\r\n\r\n## Early errors:\r\n\r\n* [x] const without initializer: `const x;` (from Esprima 1.x)\r\n* [x] for-in with multiple let identifiers: `for (let x,y in z){}`\r\n* [x] for-in with multiple const identifiers: `for (const x,y in z){}`\r\n* [x] for-in with let initializer: `for (let i = 1 in x){}`\r\n* [x] for-in with const initializer: `for (const i = 1 in x){}`\r\n * More TBD\r\n\r\n## Spec:\r\n\r\n[13.2.1](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-let-and-const-declarations) *Let and Const Declarations*.\r\n\r\nRelevant AST interfaces (from https://github.com/estree/estree):\r\n\r\n```js\r\ninterface VariableDeclaration <: Declaration {\r\n    type: \"VariableDeclaration\";\r\n    declarations: [ VariableDeclarator ];\r\n    kind: \"var\";\r\n}\r\n```\r\n\r\n```js\r\nextend interface VariableDeclaration {\r\n    kind: \"var\" | \"let\" | \"const\";\r\n}\r\n```\r\n\r\n\r\n## See also\r\n\r\n* [Error messages in V8](https://chromium.googlesource.com/external/v8/+/master/src/messages.js)\r\n* Harmony branch: [switch case accepting declaration](http://code.google.com/p/esprima/issues/detail?id=288)\r\n\r\nNote that V8 doesn't yet support various early errors for lexical declarations. In the mean time, we may need to use the generic `Unexpected token...` message for such an error.\r\n"},"comment":{"url":"https://api.github.com/repos/jquery/esprima/issues/comments/77314570","html_url":"https://github.com/jquery/esprima/issues/1065#issuecomment-77314570","issue_url":"https://api.github.com/repos/jquery/esprima/issues/1065","id":77314570,"user":{"login":"ariya","id":7288,"avatar_url":"https://avatars.githubusercontent.com/u/7288?v=3","gravatar_id":"","url":"https://api.github.com/users/ariya","html_url":"https://github.com/ariya","followers_url":"https://api.github.com/users/ariya/followers","following_url":"https://api.github.com/users/ariya/following{/other_user}","gists_url":"https://api.github.com/users/ariya/gists{/gist_id}","starred_url":"https://api.github.com/users/ariya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ariya/subscriptions","organizations_url":"https://api.github.com/users/ariya/orgs","repos_url":"https://api.github.com/users/ariya/repos","events_url":"https://api.github.com/users/ariya/events{/privacy}","received_events_url":"https://api.github.com/users/ariya/received_events","type":"User","site_admin":false},"created_at":"2015-03-05T06:36:01Z","updated_at":"2015-03-05T06:36:01Z","body":"Tasks in this ticket have been implemented. Further enhancements and more early errors will be filed separately."}}