Skip to content

Commit 89f68f4

Browse files
author
Max Schaefer
committed
JavaScript: Improve type inference for captured variables.
1 parent 6269dd9 commit 89f68f4

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

javascript/ql/src/semmle/javascript/dataflow/internal/VariableTypeInference.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ private class AnalyzedVariableCapture extends AnalyzedSsaDefinition, SsaVariable
245245
exists(LocalVariable v | v = getSourceVariable() |
246246
result = v.(AnalyzedCapturedVariable).getALocalValue()
247247
or
248+
result = any(AnalyzedExplicitDefinition def | def.getSourceVariable() = v).getAnRhsValue()
249+
or
248250
not guaranteedToBeInitialized(v) and result = getImplicitInitValue(v)
249251
)
250252
}

javascript/ql/test/library-tests/CallGraphs/AnnotatedTest/client.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ const lib = require("./lib"),
55
lib.f();
66
/** calls:lib.f */
77
f();
8+
9+
(function() {
10+
/** calls:lib.f */
11+
f();
12+
})();

0 commit comments

Comments
 (0)