Compilation fails for attribute declaration when incremental + flush + tracing

Issue #332 resolved
René Schöne created an issue

Given the parameters

--flush=full
--incremental=param
--tracing=cache,flush

When defining an (inherited) attribute

Then the compilation fails with the error

org.jastadd.tinytemplate.TemplateExpansionWarning: Template expansion warning: while expanding template 'AttrDecl.emitEquation': while expanding template 'AttrDecl.cacheCheck': while expanding template 'AttrDecl.incHookAttrRead': while expanding template 'AttrDecl.reactToDepChange': unbound variable 'HostClass'

The case is illustrated in https://git-st.inf.tu-dresden.de/jastadd/playground/-/tree/master/nta-token-inc
It uses the grammar

Root ::= WorkingType ErroneousType ;
WorkingType ::= <ID> /A:A/ /<ComputedName:String>/;
A ::= <ID> ;
ErroneousType ::= <ID> ;

and the aspect

aspect Attributes {
  syn A WorkingType.getA() = new A();
  syn String WorkingType.getComputedName() = getID() + "more";
  inh int ErroneousType.ivalue();
  eq Root.getErroneousType().ivalue() = 1;
}

A suggested change is

--- a/src/template/incremental/Notification.tt
+++ b/src/template/incremental/Notification.tt
@@ -235,7 +235,7 @@ $endif
   #resetCache
   #(signature)_handler.notifyDependencies();
   $if (TraceFlush)
-  state().trace().flushIncAttr($HostClass.this, "#signature", "", "");
+  state().trace().flushIncAttr(#hostClassName.this, "#hostClassName.#signatureJavaStyle", "", "");
   $endif
 }
 $endif

Comments (13)

  1. Jesper Öqvist

    I tried adding your test as a standalone test to the regression test suite but I get a different error than the one you describe:

        [junit] Compilation failed when expected to pass:
        [junit] warning: [options] bootstrap class path not set in conjunction with -source 7
        [junit] tmp/incremental/param/nta_token_03/ASTNode.java:523: error: cannot find symbol
        [junit]             res.append("[" + index + (mayHaveRewrite() ? ",r" : "") + "]");
    

    The change from $HostClass to #hostClassName should be good either way.

  2. René Schöne reporter

    Strange. Can’t reproduce the error you get (running the example from the playground repository) using various build settings.

    Maybe one thing I forgot to mention, the attribute in question (ivalue) needs to be marked as cached, either directly or using --cache=all. But I still only get the error I wrote in the description.

  3. René Schöne reporter

    Same as you, 2.3.4-68-g9a65594. To test it, I’ve used the playground repository and changed the jastadd2 dependency from "org.jastadd:jastadd:2.3.4" to my locally built jar using files('../jastadd-2/jastadd2.jar').

  4. René Schöne reporter

    Could you commit your changes to some branch in the jastadd-test repo, so I can try to reproduce it? With the playground-repo I’m not able to.

  5. Jesper Öqvist
    • changed status to open

    The fix caused a test regression. The reason is that #hostClassName is evaluated on an attribute declaration when the host class of the attribute equation needs to be used.

  6. Log in to comment