archives

« Bugzilla Issues Index

#4095 — duplicate bindings allowed in VariableDeclaration BindingPattern


Similar to #4087, there are no early errors that prevent the BindingPattern in a VariableDeclaration from having duplicate bindings. This appears to be an error. Note that the restriction should not be added to VariableDeclarationList, since that should allow duplicate bindings.


multiple var redeclaration of the same name within a scope has always been allowed by JavaScript.

For example:

var x=1,x=2,x=3;

So

var [x,x,x]=[1,2,3];

is just a consistent of the same var naming rules.


This will be the only place a BindingPattern allows duplicate bindings. That's not consistent in my mind. This is not something we must allow for backward compatibility, so I see no reason why it should be allowed.


You perspective on this is not unreasonable, but it isn't the one taken as the ES6 design was developed. The current semantics for this has been reviewed in spec. drafts for around three years and has already been widely implemented. This is actually the first time I've heard your view expressed.

Since the spec. text rectly reflects the intended design, I'm closing this as invalid.