NTA children initialized at incorrect indices in fullCopy

Issue #131 resolved
Jesper Öqvist created an issue

The fullCopy method messes up the children array for the AnonymousDecl class in JastAddJ. AnonymousDecl is declared using this AST declaration:

AnonymousDecl ::= Modifiers <ID:String> /[SuperClass:Access]/ /Implements:Access*/ BodyDecl*;

With JastAdd2 R20130412-32-gf380c36 we get the following fullCopy method:

  public AnonymousDecl fullCopy() {
    AnonymousDecl tree = (AnonymousDecl) copy();
    if (children != null) {
      for (int i = 0; i < children.length; ++i) {
        switch (i) {
        case 3:
          tree.children[i] = new Opt();
          continue;
        case 4:
          tree.children[i] = new List();
          continue;
        }
        ASTNode child = (ASTNode) children[i];
        if(child != null) {
          child = child.fullCopy();
          tree.setChild(child, i);
        }
      }
    }
    return tree;
  }

The indices of the Opt and List should be 2 and 3, respectively.

Comments (1)

  1. Log in to comment