JS: Add prop names for array element pattern PropReads

This commit is contained in:
Asger F
2019-11-15 11:13:31 +00:00
parent 73d9cc2e7b
commit e3b15a98c4
3 changed files with 23 additions and 4 deletions

View File

@@ -840,16 +840,18 @@ module DataFlow {
* An array element pattern viewed as a property read; for instance, in
* `var [ x, y ] = arr`, `x` is a read of property 0 of `arr` and similar
* for `y`.
*
* Note: We currently do not expose the array index as the property name,
* instead treating it as a read of an unknown property.
*/
private class ElementPatternAsPropRead extends PropRead, ElementPatternNode {
override Node getBase() { result = TDestructuringPatternNode(pattern) }
override Expr getPropertyNameExpr() { none() }
override string getPropertyName() { none() }
override string getPropertyName() {
exists (int i |
elt = pattern.getElement(i) and
result = i.toString()
)
}
}
/**