mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
JS: fixup optional chaining on CallWithNonLocalAnalyzedReturnFlow
This commit is contained in:
@@ -157,6 +157,10 @@ abstract class CallWithNonLocalAnalyzedReturnFlow extends DataFlow::AnalyzedValu
|
||||
|
||||
override AbstractValue getAValue() {
|
||||
result = getACallee().getAReturnValue()
|
||||
or
|
||||
// special case from the local layer (could be more precise if it is inferred that the callee is not `null`/`undefined`)
|
||||
astNode instanceof OptionalChainRoot and
|
||||
result = TAbstractUndefined()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,14 @@
|
||||
| tst.js:7:14:7:26 | (unknown)?.() | file://:0:0:0:0 | undefined |
|
||||
| tst.js:9:13:11:5 | unknown ... ;\\n } | file://:0:0:0:0 | undefined |
|
||||
| tst.js:9:13:11:5 | unknown ... ;\\n } | tst.js:9:33:11:5 | anonymous function |
|
||||
| tst.js:12:14:12:16 | f() | file://:0:0:0:0 | indefinite value (call) |
|
||||
| tst.js:13:14:13:18 | f?.() | file://:0:0:0:0 | indefinite value (call) |
|
||||
| tst.js:12:14:12:16 | f() | file://:0:0:0:0 | non-zero value |
|
||||
| tst.js:13:14:13:18 | f?.() | file://:0:0:0:0 | non-zero value |
|
||||
| tst.js:13:14:13:18 | f?.() | file://:0:0:0:0 | undefined |
|
||||
| tst.js:15:13:17:5 | functio ... ;\\n } | tst.js:15:13:17:5 | function g |
|
||||
| tst.js:18:14:18:16 | g() | file://:0:0:0:0 | non-zero value |
|
||||
| tst.js:19:15:19:19 | g?.() | file://:0:0:0:0 | non-zero value |
|
||||
| tst.js:19:15:19:19 | g?.() | file://:0:0:0:0 | undefined |
|
||||
| tst.js:21:13:21:21 | undefined | file://:0:0:0:0 | undefined |
|
||||
| tst.js:22:15:22:17 | h() | file://:0:0:0:0 | indefinite value (call) |
|
||||
| tst.js:23:15:23:19 | h?.() | file://:0:0:0:0 | indefinite value (call) |
|
||||
| tst.js:23:15:23:19 | h?.() | file://:0:0:0:0 | undefined |
|
||||
|
||||
@@ -8,8 +8,18 @@
|
||||
|
||||
var f = unknown? undefined: function(){
|
||||
return 42;
|
||||
}
|
||||
};
|
||||
var v7 = f();
|
||||
var v8 = f?.();
|
||||
|
||||
var g = function(){
|
||||
return 42;
|
||||
};
|
||||
var v9 = g();
|
||||
var v10 = g?.();
|
||||
|
||||
var h = undefined;
|
||||
var v11 = h();
|
||||
var v12 = h?.();
|
||||
});
|
||||
// semmle-extractor-options: --experimental
|
||||
|
||||
Reference in New Issue
Block a user