@@ -12,6 +12,7 @@ import javascript
1212 * <tr><td><code>x = y</code><td><code>x = y</code><td><code>x</code><td><code>y</code></tr>
1313 * <tr><td><code>var a = b</code><td><code>var a = b</code><td><code>a</code><td><code>b</code></tr>
1414 * <tr><td><code>function f { ... }</code><td><code>f</code><td><code>f</code><td><code>function f { ... }</code></tr>
15+ * <tr><td><code>function f ( x = y ){ ... }</code><td><code>x</code><td><code>x</code><td><code>y</code></tr>
1516 * <tr><td><code>class C { ... }</code><td><code>C</code><td><code>C</code><td><code>class C { ... }</code></tr>
1617 * <tr><td><code>namespace N { ... }</code><td><code>N</code><td><code>N</code><td><code>namespace N { ... }</code></tr>
1718 * <tr><td><code>enum E { ... }</code><td><code>E</code><td><code>E</code><td><code>enum E { ... }</code></tr>
@@ -42,6 +43,8 @@ private predicate defn(ControlFlowNode def, Expr lhs, AST::ValueNode rhs) {
4243 exists ( EnumMember member | def = member .getIdentifier ( ) |
4344 lhs = def and rhs = member .getInitializer ( )
4445 )
46+ or
47+ lhs = def and def .( Parameter ) .getDefault ( ) = rhs
4548}
4649
4750/**
@@ -187,9 +190,23 @@ class VarDef extends ControlFlowNode {
187190 * the value that this definition assigns to its target.
188191 *
189192 * This predicate is not defined for `VarDef`s where the source is implicit,
190- * such as `for-in` loops or parameters.
193+ * such as `for-in` loops, parameters or destructuring assignments.
194+ */
195+ AST:: ValueNode getSource ( ) {
196+ exists ( Expr target |
197+ not target instanceof DestructuringPattern and defn ( this , target , result )
198+ )
199+ }
200+
201+ /**
202+ * Gets the source that this definition destructs, that is, the
203+ * right hand side of a destructuring assignment.
191204 */
192- AST:: ValueNode getSource ( ) { defn ( this , _, result ) }
205+ AST:: ValueNode getDestructuringSource ( ) {
206+ exists ( Expr target |
207+ target instanceof DestructuringPattern and defn ( this , target , result )
208+ )
209+ }
193210
194211 /**
195212 * Holds if this definition of `v` is overwritten by another definition, that is,
0 commit comments