mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
JavaScript: Recognise rest patterns as lvalues.
This commit is contained in:
@@ -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()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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. |
|
||||
|
||||
@@ -2,3 +2,8 @@ function sc_alert(i) {
|
||||
for(;i;) ;
|
||||
foo;
|
||||
}
|
||||
|
||||
function f(o) {
|
||||
for({x, ...rest} of o)
|
||||
console.log(x in rest);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user