Skip to content

Commit ec7c714

Browse files
committed
Fix rest pattern completion
1 parent fd9b926 commit ec7c714

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

lib/node_modules/@stdlib/repl/ctor/lib/complete_resolve_local_scopes.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ function declarationPattern( node, parent ) {
7878
appendUnique( parent.locals, node.name );
7979
break;
8080

81-
// `var { a, b } = { 'a': 10, 'b': 20 }`
81+
// `var { a, b } = { 'a': 10, 'b': 20 }` || `var { ...o } = {}`
8282
case 'ObjectPattern':
8383
for ( i = 0; i < node.properties.length; i++ ) {
84-
declarationPattern( node.properties[ i ].value, parent );
84+
declarationPattern( node.properties[ i ].value || node.properties[ i ].argument, parent ); // eslint-disable-line max-len
8585
}
8686
break;
8787

@@ -94,7 +94,7 @@ function declarationPattern( node, parent ) {
9494
}
9595
break;
9696

97-
// `var [ x, y, ...z ] = [ 10, 20, 30, 40, 50 ]`
97+
// `var [ x, y, ...z ] = [ 10, 20, 30, 40, 50 ]` || `var [ ...z ] = []`
9898
case 'RestElement':
9999
declarationPattern( node.argument, parent );
100100
break;
@@ -161,7 +161,9 @@ function FunctionDeclaration( node, parents ) {
161161
}
162162
}
163163
parent.locals = parent.locals || [];
164-
appendUnique( parent.locals, node.id.name );
164+
if ( node.id ) {
165+
appendUnique( parent.locals, node.id.name );
166+
}
165167
declareFunction( node );
166168
}
167169

@@ -182,7 +184,9 @@ function ClassDeclaration( node, parents ) {
182184
}
183185
}
184186
parent.locals = parent.locals || [];
185-
appendUnique( parent.locals, node.id.name );
187+
if ( node.id ) {
188+
appendUnique( parent.locals, node.id.name );
189+
}
186190
}
187191

188192
/**

0 commit comments

Comments
 (0)