Files
codeql/javascript/ql/test/query-tests/LanguageFeatures/IllegalInvocation/tst.js
Max Schaefer 149ae5d7ab JavaScript: Fix IllegalInvocation.
This fixes false positives that arise when a call such as `f.apply` can either be interpreted as a reflective invocation of `f`, or a normal call to method `apply` of `f`.
2019-09-23 07:44:14 +01:00

57 lines
807 B
JavaScript

class C {
m() {}
}
class D extends C {
constructor() {
super(); // OK
}
}
let c = new C(); // OK
C(); // NOT OK
new (x=>x); // NOT OK
c.m(); // OK
new c.m(); // NOT OK
var o = {
f: function() {},
g() {}
};
o.f(); // OK
new o.f(); // OK
o.g(); // OK
new o.g(); // NOT OK
function f(b) {
var g;
if (b)
g = class {};
else
g = (() => {});
console.log();
if (!b)
g(); // OK
else
new g(); // OK
}
function* g() {}
async function h() {}
new g() // NOT OK
new h() // NOT OK
C.call(); // NOT OK
C.apply(); // NOT OK
class E {
static call() {}
static apply() {}
}
E.call(); // OK
E.apply(); // OK
//semmle-extractor-options: --experimental