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. Jesper Öqvist reporter

    Fixed storing of NTA value bug

    • NTAs using the nta keyword on the equation did not store their value in the child vector even if the NTA was declared in the grammar

    fixes #198 (bitbucket)

    → <<cset 1b4be8d9ade0>>

  2. Jesper Öqvist reporter

    Even though I have only checked as far back as version 2.1.5, this issue was likely active much farther back than that.

  3. Log in to comment