eclipse-ocl / org.eclipse.ocl

Eclipse Public License 2.0
0 stars 0 forks source link

[evaluator] Null values are ignored in collection literals #399

Closed eclipse-ocl-bot closed 5 hours ago

eclipse-ocl-bot commented 5 hours ago

| --- | --- | | Bugzilla Link | 283518 | | Status | CLOSED FIXED | | Importance | P3 normal | | Reported | Jul 15, 2009 05:58 EDT | | Modified | May 27, 2011 06:41 EDT | | Version | 1.3.0 | | Depends on | 318048 | | Blocks | 156363, 287977 | | Reporter | Alexander Igdalov |

Description

Set{1, null} is equivalent to Set{1} which is wrong. Moreover, this is inconsistent with Set{1}->including(null) which contains both elements.

eclipse-ocl-bot commented 5 hours ago

By Ed Willink on Aug 16, 2009 13:40

Can you clarify in what sense equivalent?

I've just single stepped the AST creation for:

inv: Set{1, null} = null

and the CollectionLiteralExp definitely has 2 CollectionItem elements.

eclipse-ocl-bot commented 5 hours ago

By Laurent Goubet on Aug 18, 2009 07:54

I definetely need to finish my testing of the evaluation visitor ... Here are some of the tests I had on this subject that confirm this bug :

Sequence{3, 4.0, null, 'test'}->includes(null) returns false\ conversely Sequence{3, 4.0, null, 'test'}->excludes(null) returns true

Sequence{3, null, 4.0, null, 'test'}->count(null) returns 0 instead of 2

Sequence{3, 4, 'test'}->includesAll(OrderedSet{'test', null}) returns true

Sequence{3, 4, null, 'test'}->excludesAll(OrderedSet{'TEST', null}) returns true

Note that even though these examples use Sequence, the same can be observed for all four collection types.

I'll raise another one for this, but if we are to fix this bug, we need to fix its "opposite" : collections can contain the invalid value.

eclipse-ocl-bot commented 5 hours ago

By Laurent Goubet on Aug 18, 2009 08:07

I'll raise another one for this, but if we are to fix this bug, we need to fix its "opposite" : collections can contain the invalid value.

bug 286929

eclipse-ocl-bot commented 5 hours ago

By Alexander Igdalov on Aug 20, 2009 09:50

(In reply to comment #1)

Can you clarify in what sense equivalent?

I've just single stepped the AST creation for:

inv: Set{1, null} = null

and the CollectionLiteralExp definitely has 2 CollectionItem elements.

Yes, the AST is correct. This is the problem of the evaluator. See EvaluationVisitorImpl.visitCollectionLiteralExp() line 2160.

eclipse-ocl-bot commented 5 hours ago

By Ed Willink on Feb 01, 2011 02:48

new evaluator allows null in collections.

eclipse-ocl-bot commented 5 hours ago

By Ed Willink on May 27, 2011 02:20

Closing since fixed in mature code too.

eclipse-ocl-bot commented 5 hours ago

By Ed Willink on May 27, 2011 06:41

Resolved for Indigo is 3.1.0 not 3.2.0.