-
Key: OCL24-10
-
Legacy Issue Number: 18504
-
Status: closed
-
Source: Universidad Nacional del Litoral ( Roberto Javier Godoy)
-
Summary:
Section 11.9.1.4 states that "there must be at least one element fulfilling body, otherwise the result of this IteratorExp is null." And defines
source->any(iterator|body) = source->select(iterator | body)
>asSequence()>first()However
let seq:Sequence<T>=source->select(body)->asSequence()
in source->any(body)=seq->at(1)>From section 11.7.5
context Sequence::first() : T
post: result = self->at(1)context Sequence::at(i : Integer) : T
pre : i >= 1 and i <= self->size()If there is no element fulfilling body, then seq is empty and the precondition of Sequence::at does not hold because 1 > seq->size().
Related to: Issue 18125 [OCL 2.4]
-
Reported: OCL 2.3.1 — Tue, 26 Feb 2013 05:00 GMT
-
Disposition: Resolved — OCL 2.4
-
Disposition Summary:
The 'equivalent' OCL of
source->select(iterator | body)>asSequence()>first()
returns invalid if no elements are selected, rather than null as the words say.
As identified in Issue 18125, null could also be a valid value, so the words are clearly wrong. -
Updated: Fri, 6 Mar 2015 20:57 GMT
OCL24 — Collection::any() violates precondition if the collection is empty
- Key: OCL24-10
- OMG Task Force: 2nd OCL 2.4 RTF