loonwerks/AGREE

bindingName in Array Expressions Must Be Unique

Closed this issue · 4 comments

I'm not sure if this is a java validator issue, but for some reason the following lines result in an error for each eq: "Duplicate Element 'x'" Should the scope of this variable be limited to just the exists, flatmap, foldl, etc.?

eq b2 : bool = exists x in a1, (x > 0);
eq a3 : bool[3] = flatmap x in a1, [|(x > 0)|];
eq i0 : int = foldl x in a1 into asdf = 0 , asdf + x;
eq i2 : int = foldr x in a1 into acc = 0 , acc + x;
eq b3 : bool = forall x in a2, x > 0;
eq a4 : int[3] = flatmap x in indices(a3), [| if a3[x] then 1 else 0 |];

Documentation on some of these functions is also pretty limited so additional examples would be appreciated. It would also be nice to have some type of "for which" expression that might return an index value of the first instance in which the expression evaluates to true.

For example, something like

eq a1 : int[3] = [| -1, 2, 3 |];
eq b3 : int = for which x in indicies(a1), a1[x] > 0;

would return 2 as that's the first index where the RHS evaluates to true. I'm not sure if this can be expressed more easily, but it was somewhat difficult to write a function that does this using foldl and some if then else logic.

The currently favored way of attacking this problem using the Xtext framework is to register a language-specific Resource Description Strategy implementing the custom behavior.

This requires addition of an extension point to the OSATE annex support. A patch with a candidate implementation has been submitted to the OSATE team.

Pull request #73 has been created to treat this issue once OSATE includes the required extension point.

This depends on OSATE issue 2751: Annexes should be able to use a customized resource description strategy which was resolved by OSATE pull request 2758. Since that pull request has been merged and the issue closed, we should be able to merge and close.

Resolved by #73.