Reputation: 7
I should test for equality two generic attributes like
a, b: G
...
Result := a.is_equal (b)
but VUTA (target rule validity) says "separate target of the Object_call is not controlled". What can I do?
Upvotes: 0
Views: 67
Reputation: 5810
Here are different options to fix this issue that rely only on changes in your code:
Add a non-separate constraint for the formal generic parameter. By default, the constraint is detachable separate ANY
. E.g., if you have the declaration
class FOO [G] ...
then specifing explicit constraint ANY
(without separate
) should do the trick:
class FOO [G -> ANY] ...
With this change, all instances of type G also become attached. If this should be avoided, the constraint ANY
should be replaced with detachable ANY
, but the code should be updated to check that the attributes are attached before use:
Result := attached a as x and then attached b as y and then x.is_equal (y)
Wrap the target of the call to make it controlled. Here is the example with a separate instruction (similar code could be written using a dedicated feature, e.g. if you have many such equality tests):
separate a as x do
Result := attached x and then attached b as y and then x.is_equal (b)
end
It's also possible to change your project settings to avoid using SCOOP if it is not needed.
Upvotes: 0
Reputation: 7
it seems when you go to doctor...
Result := attached a as x and then attached b as y and then y.is_equal (x)
... alexander thank you for the editing
Upvotes: 0