/**
   * @ast method
   * @aspect Namecheck
   * @declaredat C:/teaching/CZ3007/lab3_solution/src/frontend/namecheck.jrag:41
   */
  public void namecheck() {

    /* TODO: check that there aren't multiple functions with the same name (hint: use lookupFunction) */

    getReturnType().namecheck();
    for (Parameter parm : getParameters()) parm.namecheck();
    getBody().namecheck();

    FunctionDeclaration DuplicateName = lookupFunction(getName());

    if (DuplicateName != this && DuplicateName != null) {

      error("Duplicate declaration for function " + DuplicateName);
    }
  }