Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java error when calling an auxiliary from an axiom #174

Open
joeseibel opened this issue Oct 26, 2022 · 1 comment
Open

Java error when calling an auxiliary from an axiom #174

joeseibel opened this issue Oct 26, 2022 · 1 comment

Comments

@joeseibel
Copy link

If an axiom calls an auxiliary, then the generated Java code will have a compile error. Consider the following Xsemantics snippet:

auxiliary {
    exampleAuxiliary(Object obj): Object
}

judgments {
    exampleJudgement ||- Object obj : output Object
}

auxiliary exampleAuxiliary(Object obj) {
    obj
}

axiom ExampleAxiom
    G ||- Object obj : exampleAuxiliary(obj)

This produces the following Java method for the axiom:

private Object _applyRuleExampleAxiom_1(final RuleEnvironment G, final Object obj) throws RuleFailedException {
  Object _exampleAuxiliary = this.exampleAuxiliaryInternal(_trace_, obj);
  return _exampleAuxiliary;
}

The generated Java has the error: _trace_ cannot be resolved to a variable.

The problem is that _trace_ is not defined for methods generated from axioms, yet the auxiliary method expects a RuleApplicationTrace to be passed to it. If it doesn't make sense to call an auxiliary from an axiom, then there should be a validation error on the Xsemantics file. If it does make sense, then _trace_ should also be generated for axiom methods.

@LorenzoBettini
Copy link
Contributor

Thanks for the report!
I guess that generated code for axioms should have a trace parameter, like rules. I think I had never considered this use case.
I'll try to fix this ASAP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants