Question

I get the following error while trying to evaluate a predicate in a a4solution:

Fatal error in /some/path at line 9 column 2: Field "field (A/Attribute <: type)" is not bound to a legal value during translation.

Here is the code at the origin of the error:

for(ExprVar a : solution.getAllAtoms()){    
    // additional checks are here to assure that a is of an "appropriate type"
     solution.eval(predicate.call(a));
}

In my vain attempts to solve this problem by myself, I read from this source http://code.google.com/p/alloy4eclipse/issues/detail?id=86 that the way the solution has been read from the file might cause this problem. But the source doesn't give further details.

I have created my solution object as follows :

        XMLNode xml = new XMLNode(new StringReader(source.getFileContent()));
        this.solution = A4SolutionReader.read(new ArrayList<Sig>(), xml); 

Thank you for your support

Was it helpful?

Solution

The problem was that the expression to be evaluated (predicate.call(a)) was drawn from one CompModule object (namely the predicate function was taken from there) while the solution object, against which the expression was evaluated, was not obtained from the same CompModule, but was read from a file.

Generally, when reading a solution from an xml file, to be on the safe side, it is recommended to reread and reconstruct everything from that xml file, e.g.,

XMLNode xmlNode = new XMLNode(new File("my_solution.xml"));
String alloySourceFilename = xmlNode.iterator().next().getAttribute("filename");
Module module = CompUtil.parseEverything_fromFile(rep, null, alloySourceFilename);
A4Solution ans = A4SolutionReader.read(module.getAllReachableSigs(), xmlNode);

In some cases it suffices to just pass the sigs from the original CompModule to the reconstructed solution:

XMLNode xmlNode = new XMLNode(new File("my_solution.xml"));
A4Solution ans = A4SolutionReader.read(originalModule.getAllReachableSigs(), xmlNode);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top