File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed
src/semmle/javascript/dataflow/internal
test/library-tests/TypeInference/OptionalChaining Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -157,6 +157,10 @@ abstract class CallWithNonLocalAnalyzedReturnFlow extends DataFlow::AnalyzedValu
157157
158158 override AbstractValue getAValue ( ) {
159159 result = getACallee ( ) .getAReturnValue ( )
160+ or
161+ // special case from the local layer (could be more precise if it is inferred that the callee is not `null`/`undefined`)
162+ astNode instanceof OptionalChainRoot and
163+ result = TAbstractUndefined ( )
160164 }
161165}
162166
Original file line number Diff line number Diff line change 99| tst.js:7:14:7:26 | (unknown)?.() | file://:0:0:0:0 | undefined |
1010| tst.js:9:13:11:5 | unknown ... ;\\n } | file://:0:0:0:0 | undefined |
1111| tst.js:9:13:11:5 | unknown ... ;\\n } | tst.js:9:33:11:5 | anonymous function |
12- | tst.js:12:14:12:16 | f() | file://:0:0:0:0 | indefinite value (call) |
13- | tst.js:13:14:13:18 | f?.() | file://:0:0:0:0 | indefinite value (call) |
12+ | tst.js:12:14:12:16 | f() | file://:0:0:0:0 | non-zero value |
13+ | tst.js:13:14:13:18 | f?.() | file://:0:0:0:0 | non-zero value |
1414| tst.js:13:14:13:18 | f?.() | file://:0:0:0:0 | undefined |
15+ | tst.js:15:13:17:5 | functio ... ;\\n } | tst.js:15:13:17:5 | function g |
16+ | tst.js:18:14:18:16 | g() | file://:0:0:0:0 | non-zero value |
17+ | tst.js:19:15:19:19 | g?.() | file://:0:0:0:0 | non-zero value |
18+ | tst.js:19:15:19:19 | g?.() | file://:0:0:0:0 | undefined |
19+ | tst.js:21:13:21:21 | undefined | file://:0:0:0:0 | undefined |
20+ | tst.js:22:15:22:17 | h() | file://:0:0:0:0 | indefinite value (call) |
21+ | tst.js:23:15:23:19 | h?.() | file://:0:0:0:0 | indefinite value (call) |
22+ | tst.js:23:15:23:19 | h?.() | file://:0:0:0:0 | undefined |
Original file line number Diff line number Diff line change 88
99 var f = unknown ? undefined : function ( ) {
1010 return 42 ;
11- }
11+ } ;
1212 var v7 = f ( ) ;
1313 var v8 = f ?. ( ) ;
14+
15+ var g = function ( ) {
16+ return 42 ;
17+ } ;
18+ var v9 = g ( ) ;
19+ var v10 = g ?. ( ) ;
20+
21+ var h = undefined ;
22+ var v11 = h ( ) ;
23+ var v12 = h ?. ( ) ;
1424} ) ;
1525// semmle-extractor-options: --experimental
You can’t perform that action at this time.
0 commit comments