JavaScript: Recognise rest patterns as lvalues.

This commit is contained in:
Max Schaefer
2018-10-24 16:36:26 +01:00
parent 394d7b7a9b
commit 34b33ca04c
3 changed files with 9 additions and 1 deletions

View File

@@ -98,7 +98,8 @@ private predicate lvalAux(Expr l, ControlFlowNode def) {
exists (ArrayPattern ap | lvalAux(ap, def) | l = ap.getAnElement().stripParens())
or
exists (ObjectPattern op | lvalAux(op, def) |
l = op.getAPropertyPattern().getValuePattern().stripParens()
l = op.getAPropertyPattern().getValuePattern().stripParens() or
l = op.getRest().stripParens()
)
}

View File

@@ -4,3 +4,5 @@
| test.js:54:10:54:10 | z | Variable z is used like a local variable, but is missing a declaration. |
| test.js:60:6:60:6 | y | Variable y is used like a local variable, but is missing a declaration. |
| test.js:66:2:66:2 | z | Variable z is used like a local variable, but is missing a declaration. |
| tst3.js:7:10:7:10 | x | Variable x is used like a local variable, but is missing a declaration. |
| tst3.js:7:16:7:19 | rest | Variable rest is used like a local variable, but is missing a declaration. |

View File

@@ -2,3 +2,8 @@ function sc_alert(i) {
for(;i;) ;
foo;
}
function f(o) {
for({x, ...rest} of o)
console.log(x in rest);
}