Program: 29487
Project: 29487
Buggy source:
/** 
 * Outputs a   {@link TemplateNode}, generating the function open and close, along with a a debug template name. <p>If aliasing is not performed (which is always the case for V1 templates), this looks like: <pre> my.namespace.func = function(opt_data, opt_sb) { ... }; if (goog.DEBUG) { my.namespace.func.soyTemplateName = 'my.namespace.func'; } </pre> <p>If aliasing is performed, this looks like: <pre> function $func(opt_data, opt_sb) { ... } exports.func = $func; if (goog.DEBUG) { $func.soyTemplateName = 'my.namespace.func'; } <p>Note that the alias is not exactly the function name as in may conflict with a reserved JavaScript identifier. </pre>
 */
@Override protected void visitTemplateNode(TemplateNode node){
  boolean useStrongTyping=hasStrictParams(node);
  String templateName=node.getTemplateName();
  String partialName=node.getPartialTemplateName();
  String alias;
  boolean addToExports=jsSrcOptions.shouldGenerateGoogModules();
  if (addToExports && node instanceof TemplateDelegateNode) {
    alias=node.getPartialTemplateName().substring(1);
  }
 else {
    alias=templateAliases.get(templateName);
  }
  UniqueNameGenerator nameGenerator=JsSrcNameGenerators.forLocalVariables();
  CodeChunk.Generator codeGenerator=CodeChunk.Generator.create(nameGenerator);
  templateTranslationContext=TranslationContext.of(SoyToJsVariableMappings.forNewTemplate(),codeGenerator,nameGenerator);
  genJsExprsVisitor=genJsExprsVisitorFactory.create(templateTranslationContext,templateAliases,errorReporter);
  assistantForMsgs=null;
  String paramsRecordType=null;
  if (jsSrcOptions.shouldGenerateJsdoc()) {
    jsCodeBuilder.appendLine("String_Node_Str");
    jsCodeBuilder.append("String_Node_Str");
    if (useStrongTyping) {
      paramsRecordType=genParamsRecordType(node);
      jsCodeBuilder.append(paramsRecordType);
    }
 else {
      jsCodeBuilder.append("String_Node_Str");
    }
    jsCodeBuilder.appendLine("String_Node_Str");
    jsCodeBuilder.appendLine("String_Node_Str");
    jsCodeBuilder.appendLine("String_Node_Str");
    String returnType=getTemplateReturnType(node);
    jsCodeBuilder.appendLine("String_Node_Str",returnType,"String_Node_Str");
    String suppressions="String_Node_Str";
    jsCodeBuilder.appendLine("String_Node_Str" + suppressions + "String_Node_Str");
    if (node.getVisibility() == Visibility.PRIVATE) {
      jsCodeBuilder.appendLine("String_Node_Str");
    }
    jsCodeBuilder.appendLine("String_Node_Str");
  }
  if (addToExports) {
    jsCodeBuilder.appendLine("String_Node_Str",alias,"String_Node_Str");
  }
 else {
    jsCodeBuilder.appendLine(alias,"String_Node_Str");
  }
  jsCodeBuilder.increaseIndent();
  if (!SoyTreeUtils.getAllNodesOfType(node,NullCoalescingOpNode.class).isEmpty() || !SoyTreeUtils.getAllNodesOfType(node,SwitchNode.class).isEmpty()) {
    jsCodeBuilder.appendLine("String_Node_Str");
  }
  if (new ShouldEnsureDataIsDefinedVisitor().exec(node)) {
    jsCodeBuilder.appendLine("String_Node_Str");
  }
  if (shouldEnsureIjDataIsDefined(node)) {
    jsCodeBuilder.appendLine("String_Node_Str");
  }
  generateFunctionBody(node);
  jsCodeBuilder.decreaseIndent();
  if (addToExports) {
    jsCodeBuilder.appendLine("String_Node_Str");
    jsCodeBuilder.appendLine("String_Node_Str",partialName.substring(1),"String_Node_Str",alias,"String_Node_Str");
  }
 else {
    jsCodeBuilder.appendLine("String_Node_Str");
  }
  if (paramsRecordType != null) {
    jsCodeBuilder.appendLine("String_Node_Str");
    jsCodeBuilder.appendLine("String_Node_Str",paramsRecordType,"String_Node_Str");
    jsCodeBuilder.appendLine("String_Node_Str");
    jsCodeBuilder.appendLine(alias + "String_Node_Str");
  }
  jsCodeBuilder.appendLine("String_Node_Str");
  jsCodeBuilder.increaseIndent();
  jsCodeBuilder.appendLine(alias + "String_Node_Str" + templateName+ "String_Node_Str");
  jsCodeBuilder.decreaseIndent();
  jsCodeBuilder.appendLine("String_Node_Str");
  if (node instanceof TemplateDelegateNode) {
    TemplateDelegateNode nodeAsDelTemplate=(TemplateDelegateNode)node;
    String delTemplateIdExprText="String_Node_Str" + delTemplateNamer.getDelegateName(nodeAsDelTemplate) + "String_Node_Str";
    String delTemplateVariantExprText="String_Node_Str" + nodeAsDelTemplate.getDelTemplateVariant() + "String_Node_Str";
    jsCodeBuilder.appendLine("String_Node_Str",delTemplateIdExprText,"String_Node_Str",delTemplateVariantExprText,"String_Node_Str",nodeAsDelTemplate.getDelPriority().toString(),"String_Node_Str",alias,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Outputs a   {@link TemplateNode}, generating the function open and close, along with a a debug template name. <p>If aliasing is not performed (which is always the case for V1 templates), this looks like: <pre> my.namespace.func = function(opt_data, opt_sb) { ... }; if (goog.DEBUG) { my.namespace.func.soyTemplateName = 'my.namespace.func'; } </pre> <p>If aliasing is performed, this looks like: <pre> function $func(opt_data, opt_sb) { ... } exports.func = $func; if (goog.DEBUG) { $func.soyTemplateName = 'my.namespace.func'; } <p>Note that the alias is not exactly the function name as in may conflict with a reserved JavaScript identifier. </pre>
 */
@Override protected void visitTemplateNode(TemplateNode node){
  boolean useStrongTyping=hasStrictParams(node);
  String templateName=node.getTemplateName();
  String partialName=node.getPartialTemplateName();
  String alias;
  boolean addToExports=jsSrcOptions.shouldGenerateGoogModules();
  if (addToExports && node instanceof TemplateDelegateNode) {
    alias=node.getPartialTemplateName().substring(1);
  }
 else {
    alias=templateAliases.get(templateName);
  }
  UniqueNameGenerator nameGenerator=JsSrcNameGenerators.forLocalVariables();
  CodeChunk.Generator codeGenerator=CodeChunk.Generator.create(nameGenerator);
  templateTranslationContext=TranslationContext.of(SoyToJsVariableMappings.forNewTemplate(),codeGenerator,nameGenerator);
  genJsExprsVisitor=genJsExprsVisitorFactory.create(templateTranslationContext,templateAliases,errorReporter);
  assistantForMsgs=null;
  String paramsRecordType=null;
  if (jsSrcOptions.shouldGenerateJsdoc()) {
    jsCodeBuilder.appendLine("String_Node_Str");
    jsCodeBuilder.append("String_Node_Str");
    if (useStrongTyping) {
      paramsRecordType=genParamsRecordType(node);
      jsCodeBuilder.append(paramsRecordType);
    }
 else {
      jsCodeBuilder.append("String_Node_Str");
    }
    jsCodeBuilder.appendLine("String_Node_Str");
    jsCodeBuilder.appendLine("String_Node_Str");
    jsCodeBuilder.appendLine("String_Node_Str");
    String returnType=getTemplateReturnType(node);
    jsCodeBuilder.appendLine("String_Node_Str",returnType,"String_Node_Str");
    String suppressions="String_Node_Str";
    jsCodeBuilder.appendLine("String_Node_Str" + suppressions + "String_Node_Str");
    if (node.getVisibility() == Visibility.PRIVATE) {
      jsCodeBuilder.appendLine("String_Node_Str");
    }
    jsCodeBuilder.appendLine("String_Node_Str");
  }
  if (addToExports) {
    jsCodeBuilder.appendLine("String_Node_Str",alias,"String_Node_Str");
  }
 else {
    jsCodeBuilder.appendLine(alias,"String_Node_Str");
  }
  jsCodeBuilder.increaseIndent();
  if (!SoyTreeUtils.getAllNodesOfType(node,NullCoalescingOpNode.class).isEmpty() || !SoyTreeUtils.getAllNodesOfType(node,SwitchNode.class).isEmpty()) {
    jsCodeBuilder.appendLine("String_Node_Str");
  }
  if (new ShouldEnsureDataIsDefinedVisitor().exec(node)) {
    jsCodeBuilder.appendLine("String_Node_Str");
  }
  if (shouldEnsureIjDataIsDefined(node)) {
    jsCodeBuilder.appendLine("String_Node_Str");
  }
  generateFunctionBody(node);
  jsCodeBuilder.decreaseIndent();
  if (addToExports) {
    jsCodeBuilder.appendLine("String_Node_Str");
    jsCodeBuilder.appendLine("String_Node_Str",partialName.substring(1),"String_Node_Str",alias,"String_Node_Str");
  }
 else {
    jsCodeBuilder.appendLine("String_Node_Str");
  }
  if (paramsRecordType != null) {
    jsCodeBuilder.appendLine("String_Node_Str");
    jsCodeBuilder.appendLine("String_Node_Str",paramsRecordType,"String_Node_Str");
    jsCodeBuilder.appendLine("String_Node_Str");
    jsCodeBuilder.appendLine(alias + "String_Node_Str");
  }
  jsCodeBuilder.appendLine("String_Node_Str");
  jsCodeBuilder.increaseIndent();
  jsCodeBuilder.appendLine(alias + "String_Node_Str" + templateName+ "String_Node_Str");
  jsCodeBuilder.decreaseIndent();
  jsCodeBuilder.appendLine("String_Node_Str");
  if (node instanceof TemplateDelegateNode) {
    TemplateDelegateNode nodeAsDelTemplate=(TemplateDelegateNode)node;
    jsCodeBuilder.append(SOY_REGISTER_DELEGATE_FN.call(SOY_GET_DELTEMPLATE_ID.call(stringLiteral(delTemplateNamer.getDelegateName(nodeAsDelTemplate))),stringLiteral(nodeAsDelTemplate.getDelTemplateVariant()),number(nodeAsDelTemplate.getDelPriority().getValue()),dottedIdNoRequire(alias)));
  }
}