code: static boolean canBeSideEffected(Node n, Set<String> knownConstants, @Nullable Scope scope) {
      switch (n.getToken()) {
        case YIELD:
        case CALL:
        case NEW:
          // Function calls or constructor can reference changed values.
          // TODO(johnlenz): Add some mechanism for determining that functions
          // are unaffected by side effects.
          return true;
        case NAME:
          // Non-constant names values may have been changed.
          return !isConstantVar(n, scope) && !knownConstants.contains(n.getString());
  
        // Properties on constant NAMEs can still be side-effected.
        case GETPROP:
        case GETELEM:
          return true;
  
        case FUNCTION:
          // Function expression are not changed by side-effects,
          // and function declarations are not part of expressions.
          // TODO(bradfordcsmith): Do we need to add a case for CLASS here?
          //     This checkState currently does not exclude class methods.
          checkState(!isFunctionDeclaration(n), n);
          return false;
        default:
          break;
      }
  
      for (Node c = n.getFirstChild(); c != null; c = c.getNext()) {
        if (canBeSideEffected(c, knownConstants, scope)) {
          return true;
        }
      }
  
      return false;
    }
docs: scope with InferConsts.