Compilation fails for attribute declaration when incremental + flush + tracing
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)
-
-
I tried it with JastAdd2 2.3.4-68-g9a65594c btw.
-
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. -
What build of JastAdd are you running?
-
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 usingfiles('../jastadd-2/jastadd2.jar')
. -
When I added
cache=all
I got the same error as you! -
After applying your patch my original error remains - the
mayHaveRewrites
error. -
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.
-
My test was using
rewrite=regular
, switching torewrite=cnta
fixed the error. -
The test harness uses different default options than the gradle plugin.
-
- changed status to resolved
-
- 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. -
- changed status to resolved
[incremental] Fix unbound template variable
This reverts commit 1a3072525645689f52fce34e02cc3684ec781be2.
fixes
#332→ <<cset 4acf4f072b03>>
- Log in to comment
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:
The change from
$HostClass
to#hostClassName
should be good either way.