Program: 135905
Project: 135905
Buggy source:
/** 
 * The following method goes through all the nodes to set their            tool-specific fields.  It was modified on 1 May 2007 so it would find   the nodes in the body of a Lambda expression.  Obviously, if new        semantic node types are added, this method will have to be modified.    Less obviously, if a tool wants to call TLC on a specification that     was not all created inside a module, then this method may need to be    modified so TLC finds thos nodes not part of the module.                * Yuan claims that this is the only method in TLC that has to find all    the nodes in such a way.                                               
 */
private final void processConstants(SemanticNode expr){
switch (expr.getKind()) {
case ModuleKind:
{
      ModuleNode expr1=(ModuleNode)expr;
      OpDefNode[] opDefs=expr1.getOpDefs();
      for (int i=0; i < opDefs.length; i++) {
        Object def=opDefs[i].getToolObject(TLCGlobals.ToolId);
        if (def instanceof OpDefNode) {
          this.processConstants(((OpDefNode)def).getBody());
        }
        this.processConstants(opDefs[i].getBody());
      }
      ModuleNode[] imods=expr1.getInnerModules();
      for (int i=0; i < imods.length; i++) {
        this.processConstants(imods[i]);
      }
      AssumeNode[] assumps=expr1.getAssumptions();
      for (int i=0; i < assumps.length; i++) {
        this.processConstants(assumps[i]);
      }
      TheoremNode[] thms=expr1.getTheorems();
      for (int i=0; i < thms.length; i++) {
        this.processConstants(thms[i]);
      }
      return;
    }
case OpApplKind:
{
    OpApplNode expr1=(OpApplNode)expr;
    SymbolNode opNode=expr1.getOperator();
    Object val=this.defns.get(opNode.getName());
    if (val != null) {
      opNode.setToolObject(TLCGlobals.ToolId,val);
    }
 else {
      SemanticNode[] args=expr1.getArgs();
      for (int i=0; i < args.length; i++) {
        if (args[i] != null) {
          this.processConstants(args[i]);
        }
      }
      ExprNode[] bnds=expr1.getBdedQuantBounds();
      for (int i=0; i < bnds.length; i++) {
        this.processConstants(bnds[i]);
      }
    }
    return;
  }
case LetInKind:
{
  LetInNode expr1=(LetInNode)expr;
  OpDefNode[] letDefs=expr1.getLets();
  for (int i=0; i < letDefs.length; i++) {
    this.processConstants(letDefs[i].getBody());
  }
  this.processConstants(expr1.getBody());
  return;
}
case SubstInKind:
{
SubstInNode expr1=(SubstInNode)expr;
Subst[] subs=expr1.getSubsts();
for (int i=0; i < subs.length; i++) {
  this.processConstants(subs[i].getExpr());
}
this.processConstants(expr1.getBody());
return;
}
case APSubstInKind:
{
APSubstInNode expr1=(APSubstInNode)expr;
Subst[] subs=expr1.getSubsts();
for (int i=0; i < subs.length; i++) {
this.processConstants(subs[i].getExpr());
}
this.processConstants(expr1.getBody());
return;
}
case NumeralKind:
{
NumeralNode expr1=(NumeralNode)expr;
IntValue val=IntValue.gen(expr1.val());
expr1.setToolObject(TLCGlobals.ToolId,val);
return;
}
case DecimalKind:
{
DecimalNode expr1=(DecimalNode)expr;
Assert.fail(EC.TLC_CANT_HANDLE_REAL_NUMBERS,expr1.toString());
return;
}
case StringKind:
{
StringNode expr1=(StringNode)expr;
StringValue val=new StringValue(expr1.getRep());
expr1.setToolObject(TLCGlobals.ToolId,val);
return;
}
case AssumeKind:
{
AssumeNode expr1=(AssumeNode)expr;
this.processConstants(expr1.getAssume());
return;
}
case TheoremKind:
{
TheoremNode expr1=(TheoremNode)expr;
this.processConstants(expr1.getTheorem());
return;
}
case OpArgKind:
{
SymbolNode opArgNode=((OpArgNode)expr).getOp();
if (opArgNode.getKind() == UserDefinedOpKind) {
this.processConstants(((OpDefNode)opArgNode).getBody());
}
return;
}
case LabelKind:
{
LabelNode expr1=(LabelNode)expr;
this.processConstants(expr1.getBody());
}
}
}

Fixed version (ground truth):
/** 
 * The following method goes through all the nodes to set their            tool-specific fields.  It was modified on 1 May 2007 so it would find   the nodes in the body of a Lambda expression.  Obviously, if new        semantic node types are added, this method will have to be modified.    Less obviously, if a tool wants to call TLC on a specification that     was not all created inside a module, then this method may need to be    modified so TLC finds thos nodes not part of the module.                * Yuan claims that this is the only method in TLC that has to find all    the nodes in such a way.                                               
 */
private final void processConstants(SemanticNode expr){
switch (expr.getKind()) {
case ModuleKind:
{
      ModuleNode expr1=(ModuleNode)expr;
      OpDefNode[] opDefs=expr1.getOpDefs();
      for (int i=0; i < opDefs.length; i++) {
        Object def=opDefs[i].getToolObject(TLCGlobals.ToolId);
        if (def instanceof OpDefNode) {
          this.processConstants(((OpDefNode)def).getBody());
        }
        this.processConstants(opDefs[i].getBody());
      }
      ModuleNode[] imods=expr1.getInnerModules();
      for (int i=0; i < imods.length; i++) {
        this.processConstants(imods[i]);
      }
      AssumeNode[] assumps=expr1.getAssumptions();
      for (int i=0; i < assumps.length; i++) {
        this.processConstants(assumps[i]);
      }
      TheoremNode[] thms=expr1.getTheorems();
      for (int i=0; i < thms.length; i++) {
        this.processConstants(thms[i]);
      }
      return;
    }
case OpApplKind:
{
    OpApplNode expr1=(OpApplNode)expr;
    SymbolNode opNode=expr1.getOperator();
    Object val=this.defns.get(opNode.getName());
    if (val != null) {
      opNode.setToolObject(TLCGlobals.ToolId,val);
    }
 else {
      SemanticNode[] args=expr1.getArgs();
      for (int i=0; i < args.length; i++) {
        if (args[i] != null) {
          this.processConstants(args[i]);
        }
      }
      ExprNode[] bnds=expr1.getBdedQuantBounds();
      for (int i=0; i < bnds.length; i++) {
        this.processConstants(bnds[i]);
      }
    }
    return;
  }
case LetInKind:
{
  LetInNode expr1=(LetInNode)expr;
  OpDefNode[] letDefs=expr1.getLets();
  for (int i=0; i < letDefs.length; i++) {
    this.processConstants(letDefs[i].getBody());
  }
  this.processConstants(expr1.getBody());
  return;
}
case SubstInKind:
{
SubstInNode expr1=(SubstInNode)expr;
Subst[] subs=expr1.getSubsts();
for (int i=0; i < subs.length; i++) {
  this.processConstants(subs[i].getExpr());
}
this.processConstants(expr1.getBody());
return;
}
case APSubstInKind:
{
APSubstInNode expr1=(APSubstInNode)expr;
Subst[] subs=expr1.getSubsts();
for (int i=0; i < subs.length; i++) {
this.processConstants(subs[i].getExpr());
}
this.processConstants(expr1.getBody());
return;
}
case NumeralKind:
{
NumeralNode expr1=(NumeralNode)expr;
IntValue val=IntValue.gen(expr1.val());
if (expr1.bigVal() != null) {
Assert.fail(EC.TLC_INTEGER_TOO_BIG,expr1.toString());
return;
}
expr1.setToolObject(TLCGlobals.ToolId,val);
return;
}
case DecimalKind:
{
DecimalNode expr1=(DecimalNode)expr;
Assert.fail(EC.TLC_CANT_HANDLE_REAL_NUMBERS,expr1.toString());
return;
}
case StringKind:
{
StringNode expr1=(StringNode)expr;
StringValue val=new StringValue(expr1.getRep());
expr1.setToolObject(TLCGlobals.ToolId,val);
return;
}
case AssumeKind:
{
AssumeNode expr1=(AssumeNode)expr;
this.processConstants(expr1.getAssume());
return;
}
case TheoremKind:
{
TheoremNode expr1=(TheoremNode)expr;
this.processConstants(expr1.getTheorem());
return;
}
case OpArgKind:
{
SymbolNode opArgNode=((OpArgNode)expr).getOp();
if (opArgNode.getKind() == UserDefinedOpKind) {
this.processConstants(((OpDefNode)opArgNode).getBody());
}
return;
}
case LabelKind:
{
LabelNode expr1=(LabelNode)expr;
this.processConstants(expr1.getBody());
}
}
}