Skip to content

Commit 233b791

Browse files
committed
Avoid bad join in compatibleTypesCached
This is identical to the code in Ruby and seems to prevent a bad join ordering in a cached version of this predicate in DataFlowCommon
1 parent a8284c0 commit 233b791

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

javascript/ql/lib/semmle/javascript/dataflow/internal/DataFlowPrivate.qll

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,19 @@ predicate neverSkipInPathGraph(Node node) {
373373

374374
string ppReprType(DataFlowType t) { none() }
375375

376+
pragma[inline]
377+
private predicate compatibleTypesNonSymRefl(DataFlowType t1, DataFlowType t2) {
378+
t1 != TAnyType() and
379+
t2 = TAnyType()
380+
}
381+
376382
pragma[inline]
377383
predicate compatibleTypes(DataFlowType t1, DataFlowType t2) {
378384
t1 = t2
379385
or
380-
t1 instanceof TAnyType and exists(t2)
386+
compatibleTypesNonSymRefl(t1, t2)
381387
or
382-
t2 instanceof TAnyType and exists(t1)
388+
compatibleTypesNonSymRefl(t2, t1)
383389
}
384390

385391
predicate forceHighPrecision(Content c) { none() }

0 commit comments

Comments
 (0)