Skip to content

Fix OCL constraint failure on superclass attributes#464

Closed
ArmenSl wants to merge 1 commit intodevelopmentfrom
fix/198-ocl-superclass-attributes
Closed

Fix OCL constraint failure on superclass attributes#464
ArmenSl wants to merge 1 commit intodevelopmentfrom
fix/198-ocl-superclass-attributes

Conversation

@ArmenSl
Copy link
Copy Markdown
Collaborator

@ArmenSl ArmenSl commented Mar 17, 2026

Summary

Fixes #198

One-line fix: changed context.attributes to context.all_attributes() in the OCL parser's checkInAttributes() method (besser/BUML/notations/ocl/FactoryInstance.py line 9).

The method only checked direct attributes of a class, so constraints referencing inherited attributes (e.g., self.boss.salary where salary is on a superclass) would fail with "Property not found".

Test plan

  • All 12 existing OCL parser tests pass
  • 11 new tests added covering:
    • Direct attributes on context class
    • Direct attributes on child class
    • Inherited attribute on self (self.salary on Employee, salary is on Person)
    • Inherited attribute after navigation (self.boss.salary)
    • Inherited attribute in if-then-else
    • Inherited attribute in forAll iterator
    • Inherited attribute in exists iterator
    • Mixed direct + inherited attributes after navigation

The OCL parser's checkInAttributes() used context.attributes which only
returns direct attributes. Changed to context.all_attributes() to include
inherited attributes from parent classes.

This fixes constraints like self.boss.salary where salary is defined on
a superclass of the navigated type.

Added 11 tests covering inherited attributes on self, after navigation,
in if-then-else, forAll, exists, and mixed with direct attributes.
@ArmenSl ArmenSl requested a review from FitashUlHaq March 17, 2026 11:05
@ArmenSl
Copy link
Copy Markdown
Collaborator Author

ArmenSl commented Apr 1, 2026

Closing this — the fix is superseded by the new visitor-based OCL implementation (branch fix/issue_9_bocl). The old FactoryInstance.py (listener pattern) has been removed entirely, and the new visitor.py already uses all_attributes() from the start, so inherited attributes work correctly.

@ArmenSl ArmenSl closed this Apr 1, 2026
@ArmenSl ArmenSl deleted the fix/198-ocl-superclass-attributes branch April 1, 2026 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant