Component declared NTA in both AST and JRAG discards equation result

Issue #198 resolved
Jesper Öqvist
created an issue

This bug is active in at JastAdd 2.1.5 through 2.1.10.

In the below example, the B NTA is always evaluated as null:

A ::= /B/;
aspect Test {
  syn nta B A.getB() = new B();

This bug is caused by the setB method not being called in the attribute evaluation method:

        public B getB() {
                if(getB_computed) {
                        return (B) getChild(getBChildPosition());
                if (getB_visited) {
                        throw new RuntimeException("Circular definition of attr: getB in class: org.jastadd.ast.AST.SynDecl");
                getB_visited = true;
                boolean intermediate = state.INTERMEDIATE_VALUE;
                state.INTERMEDIATE_VALUE = false;
                getB_value = new B();
                if (true) {
                        getB_computed = true;
                } else {
                state.INTERMEDIATE_VALUE |= intermediate;

                getB_visited = false;
                B node = (B) this.getChild(getBChildPosition());
                return node;

This is caused by the code generation skipping the generation of setB because B was declared NTA in the aspect file. If the nta is removed from syn nta ... then the error disappears.

Comments (2)

  1. Log in to comment