Option safeLazy requires visitCheck to be false

Issue #321 new
Niklas Fors created an issue

The option safeLazy requires the option visitCheck to be false, otherwise a runtime circularity exception is thrown in some situations.

This bug can be seen in a modified version of the test case circular/safe-lazy-01, where the attribute b() is invoked instead of c() in Test.java.
Test.java:

// Using the --safeLazy flag enables non-circular cached attributes in a
// circular attribute cycle.
// .options: safeLazy
// .grammar: { A; }
import static runtime.Test.*;

public class Test {
  public static void main(String[] args) {
    testEqual(5, new A().b());  // Invoke b() instead of c()!
  }
}

Test.jrag:

aspect Test {
  syn int A.c() circular [0] = Math.min(5, 1 + b());

  // --safeLazy makes this safe, even though it circularly defined:
  syn lazy int A.b() = c();
}

This gives the following output with JastAdd2 v.2.3.4

    [junit] Code execution failed when expected to pass:
    [junit] Exception in thread "main" java.lang.RuntimeException: Circular definition of attribute A.b().
    [junit]     at A.b(A.java:204)
    [junit]     at A.c(A.java:151)
    [junit]     at A.b(A.java:207)
    [junit]     at Test.main(Test.java:9)

But the test case works when the option visitCheck=false is added to Test.java.

Comments (2)

  1. Log in to comment