Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destructuring: Fix array unpacking assignments with holes on RHS #9412

Merged
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -83,7 +83,11 @@ export default declare((api, options) => {

if (op) {
node = t.expressionStatement(
t.assignmentExpression(op, id, t.cloneNode(init)),
t.assignmentExpression(
op,
id,
t.cloneNode(init) || this.scope.buildUndefinedNode(),
),
);
} else {
node = t.variableDeclaration(this.kind, [
@@ -11,3 +11,7 @@ var [a, b] = [...foo, bar];
var [a, b] = [foo(), bar];
var [a, b] = [clazz.foo(), bar];
var [a, b] = [clazz.foo, bar];
var [a, b] = [, 2];
[a, b] = [1, 2];
[a, b] = [, 2];
; // Avoid completion record special case

This comment has been minimized.

Copy link
@nicolo-ribaudo

nicolo-ribaudo Jan 26, 2019

Member

Not in this PR, but this optimization is wrong: ; keeps the previous completion value:

eval("0;;;;")

Can you use something like 0; instead?

This comment has been minimized.

Copy link
@motiz88

motiz88 Jan 26, 2019

Author Contributor

Yeah, I've just realised this on another PR. Ultimately it's a false negative in the isCompletionRecord check, which could be quite expensive to correct without memoising somehow.

I'll change this, but FWIW there are several other tests that currently use ; in this way and would need to change similarly.

This comment has been minimized.

Copy link
@nicolo-ribaudo

nicolo-ribaudo Mar 27, 2019

Member

This can/should be handled in another PR

@@ -34,3 +34,10 @@ var _ref7 = [clazz.foo(), bar],
var _ref8 = [clazz.foo, bar],
a = _ref8[0],
b = _ref8[1];
var a,
b = 2;
a = 1;
b = 2;
a = void 0;
b = 2;
; // Avoid completion record special case
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.