1111 */
1212
1313import javascript
14+ import DeadStore
1415
1516/**
1617 * Holds if `vd` is a definition of variable `v` that is dead, that is,
@@ -25,22 +26,6 @@ predicate deadStoreOfLocal(VarDef vd, PurelyLocalVariable v) {
2526 not exists ( SsaExplicitDefinition ssa | ssa .defines ( vd , v ) )
2627}
2728
28- /**
29- * Holds if `e` is an expression that may be used as a default initial value,
30- * such as `0` or `-1`, or an empty object or array literal.
31- */
32- predicate isDefaultInit ( Expr e ) {
33- // primitive default values: zero, false, empty string, and (integer) -1
34- e .( NumberLiteral ) .getValue ( ) .toFloat ( ) = 0.0 or
35- e .( NegExpr ) .getOperand ( ) .( NumberLiteral ) .getValue ( ) = "1" or
36- e .( ConstantString ) .getStringValue ( ) = "" or
37- e .( BooleanLiteral ) .getValue ( ) = "false" or
38- // initialising to an empty array or object literal, even if unnecessary,
39- // can convey useful type information to the reader
40- e .( ArrayExpr ) .getSize ( ) = 0 or
41- e .( ObjectExpr ) .getNumProperty ( ) = 0
42- }
43-
4429from VarDef dead , PurelyLocalVariable v // captured variables may be read by closures, so don't flag them
4530where deadStoreOfLocal ( dead , v ) and
4631 // the variable should be accessed somewhere; otherwise it will be flagged by UnusedVariable
0 commit comments