{"action":"created","issue":{"url":"https://api.github.com/repos/tc39/ecma262/issues/97","labels_url":"https://api.github.com/repos/tc39/ecma262/issues/97/labels{/name}","comments_url":"https://api.github.com/repos/tc39/ecma262/issues/97/comments","events_url":"https://api.github.com/repos/tc39/ecma262/issues/97/events","html_url":"https://github.com/tc39/ecma262/issues/97","id":112491578,"number":97,"title":"Destructuring declarations that bind nothing should probably be an early error","user":{"login":"allenwb","id":505435,"avatar_url":"https://avatars.githubusercontent.com/u/505435?v=3","gravatar_id":"","url":"https://api.github.com/users/allenwb","html_url":"https://github.com/allenwb","followers_url":"https://api.github.com/users/allenwb/followers","following_url":"https://api.github.com/users/allenwb/following{/other_user}","gists_url":"https://api.github.com/users/allenwb/gists{/gist_id}","starred_url":"https://api.github.com/users/allenwb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allenwb/subscriptions","organizations_url":"https://api.github.com/users/allenwb/orgs","repos_url":"https://api.github.com/users/allenwb/repos","events_url":"https://api.github.com/users/allenwb/events{/privacy}","received_events_url":"https://api.github.com/users/allenwb/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/tc39/ecma262/labels/needs%20consensus","name":"needs consensus","color":"f7c6c7"},{"url":"https://api.github.com/repos/tc39/ecma262/labels/observable%20semantics%20delta","name":"observable semantics delta","color":"5319e7"},{"url":"https://api.github.com/repos/tc39/ecma262/labels/spec%20bug","name":"spec bug","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":19,"created_at":"2015-10-21T01:09:25Z","updated_at":"2015-10-22T04:21:22Z","closed_at":null,"body":"In the ES6 spec., there is no check that a destructuring let/const/var actually introduces any bindings.\r\n\r\nFor example:\r\n```js\r\nlet ;\r\n```\r\nis a syntax error, but\r\n```js\r\nlet { };\r\n```\r\nis valid syntax that does nothing.\r\n\r\nThere are [reports](https://www.nczonline.net/blog/2015/10/ecmascript-6-destructuring-gotcha/) that some ES6 developers are encountering bugs cause by complex destructing patterns that unintentionally don't introduce any bindings.\r\n\r\nThis seems like a design bug in ES6.  It would be trivial  to specify that this is an early syntax error.\r\n\r\nIn [13.3.1.1](http://ecma-international.org/ecma-262/6.0/#sec-let-and-const-declarations-static-semantics-early-errors)\r\n*LexicalBinding* : *BindingPattern Initializer*\r\n    - It is a Syntax Error if the BoundNames of *BindingPattern* has no elements.\r\n\r\nIn [14.1.2](http://ecma-international.org/ecma-262/6.0/#sec-function-definitions-static-semantics-early-errors)\r\n*FormalParameter* : * BindingElement*\r\n    - It is a Syntax Error if the BoundNames of *BindingElement* has no elements.\r\n\r\nNote that this is a breaking change for any program that actually contains such empty binding patterns.  So there is some risk to making this change.\r\n"},"comment":{"url":"https://api.github.com/repos/tc39/ecma262/issues/comments/150103063","html_url":"https://github.com/tc39/ecma262/issues/97#issuecomment-150103063","issue_url":"https://api.github.com/repos/tc39/ecma262/issues/97","id":150103063,"user":{"login":"ljharb","id":45469,"avatar_url":"https://avatars.githubusercontent.com/u/45469?v=3","gravatar_id":"","url":"https://api.github.com/users/ljharb","html_url":"https://github.com/ljharb","followers_url":"https://api.github.com/users/ljharb/followers","following_url":"https://api.github.com/users/ljharb/following{/other_user}","gists_url":"https://api.github.com/users/ljharb/gists{/gist_id}","starred_url":"https://api.github.com/users/ljharb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljharb/subscriptions","organizations_url":"https://api.github.com/users/ljharb/orgs","repos_url":"https://api.github.com/users/ljharb/repos","events_url":"https://api.github.com/users/ljharb/events{/privacy}","received_events_url":"https://api.github.com/users/ljharb/received_events","type":"User","site_admin":false},"created_at":"2015-10-22T04:21:22Z","updated_at":"2015-10-22T04:21:22Z","body":"When commenting out every destructuring property in an object destructuring, could you not just add a nonexistent garbage property, and still do your debugging without having to worry about whether \"no destructuring patterns\" are an error?\r\n\r\nI think the real question here is, which is going to be more common: that an empty-bindings destructuring pattern is a developer mistake (worth noting that things like the TDZ attempt to address developer mistakes, and I think this *is* indeed the language's job), or, that an empty-bindings destructuring pattern is a temporary thing that an educated developer is doing for debugging?\r\n\r\nI tend to believe that both the former case is more common, *and* that in the latter case, the developer will not have a practical problem avoiding this error during debugging.\r\n\r\n@rwaldron @getify @rossberg-chromium, do you really think both that the former (a newbie developer making a mistake) is far less common than a developer needing to debug destructuring with things that have side effects such that they need to comment out every destructuring binding, and that discontinuing to allow the latter would be excessively burdensome on an experienced developer during their debugging?"}}