Declaration order dependency between interface and inherited attribute

Issue #248 resolved
Jesper Öqvist created an issue

JastAdd2 2.1.13-83-g418a5b4

I was supervising two students this autumn in a compiler course project. The students were implementing an ExtendJ extension and they had problems building ExtendJ using JastAddGradle. After some debugging and head-scratching I found out that there is still an order dependency in JastAdd.

I tracked down what was causing the build error and made a minimal test case exposing a declaration order dependency in JastAdd:

// Test declaration order dependency for interface / inherited equation.
// grammar = {A ::= B; B;}
// .result=COMPILE_PASS
aspect Test {
  B implements I;

  inh A I.a();

  interface I {
  }

  eq A.getChild().a() = this;
}

This test case generates the following output from JastAdd2:

    [junit] JastAdd code generation failed when expected to pass:
    [junit] Error at tests/aspect/order_01p/Test.jrag:12: missing declaration for inherited attribute a()

If the interface declaration is moved up before the inherited attribute declaration then JastAdd can generate code, without the above error message.

Comments (2)

  1. Jesper Öqvist reporter

    Defer inherited attribute weaving

    Defer inherited attribute weaving so that the attributes are woven after type declarations have been added to the grammar. This works very similar to how synthesized attribute weaving is deferred.

    fixes #248 (bitbucket)

    → <<cset 6abf96f07def>>

  2. Log in to comment