Program: 28124
Project: 28124
Buggy source:
@Override public void visit(NodeTraversal t,Node n,Node parent){
  RefInfo refInfo=allRefInfo.get(n);
  if (refInfo != null) {
    Ref ref=refInfo.ref;
    Name name=refInfo.name;
    String fullName=name.fullName();
switch (ref.type) {
case SET_FROM_GLOBAL:
case SET_FROM_LOCAL:
      Node valParent=getValueParent(ref);
    Node val=valParent.getLastChild();
  if (valParent.getType() == Token.ASSIGN && name.isSimpleName() && name.getDeclaration() == ref) {
    compiler.report(t.makeError(val,INVALID_DEFINE_INIT_ERROR,fullName));
  }
 else   if (processDefineAssignment(t,fullName,val,valParent)) {
    refInfo.name.removeRef(ref);
    lvalueToRemoveLater=valParent;
  }
break;
default :
if (t.inGlobalScope()) {
DefineInfo info=assignableDefines.get(fullName);
if (info != null) {
  setDefineInfoNotAssignable(info,t);
  assignableDefines.remove(fullName);
}
}
break;
}
}
if (!t.inGlobalScope() && n.getJSDocInfo() != null && n.getJSDocInfo().isDefine()) {
compiler.report(t.makeError(n,NON_GLOBAL_DEFINE_INIT_ERROR,"String_Node_Str"));
}
if (lvalueToRemoveLater == n) {
lvalueToRemoveLater=null;
if (n.getType() == Token.ASSIGN) {
Node last=n.getLastChild();
n.removeChild(last);
parent.replaceChild(n,last);
}
 else {
Preconditions.checkState(n.getType() == Token.NAME);
n.removeChild(n.getFirstChild());
}
compiler.reportCodeChange();
}
if (n.getType() == Token.CALL) {
if (t.inGlobalScope()) {
for (DefineInfo info : assignableDefines.values()) {
setDefineInfoNotAssignable(info,t);
}
assignableDefines.clear();
}
}
updateAssignAllowedStack(n,false);
}

Fixed version (ground truth):
@Override public void visit(NodeTraversal t,Node n,Node parent){
  RefInfo refInfo=allRefInfo.get(n);
  if (refInfo != null) {
    Ref ref=refInfo.ref;
    Name name=refInfo.name;
    String fullName=name.getFullName();
switch (ref.type) {
case SET_FROM_GLOBAL:
case SET_FROM_LOCAL:
      Node valParent=getValueParent(ref);
    Node val=valParent.getLastChild();
  if (valParent.getType() == Token.ASSIGN && name.isSimpleName() && name.getDeclaration() == ref) {
    compiler.report(t.makeError(val,INVALID_DEFINE_INIT_ERROR,fullName));
  }
 else   if (processDefineAssignment(t,fullName,val,valParent)) {
    refInfo.name.removeRef(ref);
    lvalueToRemoveLater=valParent;
  }
break;
default :
if (t.inGlobalScope()) {
DefineInfo info=assignableDefines.get(fullName);
if (info != null) {
  setDefineInfoNotAssignable(info,t);
  assignableDefines.remove(fullName);
}
}
break;
}
}
if (!t.inGlobalScope() && n.getJSDocInfo() != null && n.getJSDocInfo().isDefine()) {
compiler.report(t.makeError(n,NON_GLOBAL_DEFINE_INIT_ERROR,"String_Node_Str"));
}
if (lvalueToRemoveLater == n) {
lvalueToRemoveLater=null;
if (n.getType() == Token.ASSIGN) {
Node last=n.getLastChild();
n.removeChild(last);
parent.replaceChild(n,last);
}
 else {
Preconditions.checkState(n.getType() == Token.NAME);
n.removeChild(n.getFirstChild());
}
compiler.reportCodeChange();
}
if (n.getType() == Token.CALL) {
if (t.inGlobalScope()) {
for (DefineInfo info : assignableDefines.values()) {
setDefineInfoNotAssignable(info,t);
}
assignableDefines.clear();
}
}
updateAssignAllowedStack(n,false);
}