Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(class): throw error when class is extending itself #767

Merged

Conversation

stefanblaginov
Copy link
Contributor

@stefanblaginov stefanblaginov commented Nov 27, 2023

Closes #750

Changes

Adds validation for cases where a class (an asset, event, concept, participant or transaction) is extending itself. The validations are performed when:

  • parse-ing CTO to JSON AST.
  • print-ing JSON AST to CTO.
  • Loading JSON AST into the model manager.

The following will be caught by the anti-self-extension validation:

concept Self_Extending extends Self_Extending {}
{
  "$class": "[email protected]",
  "name": "Self_Extending",
  "isAbstract": false,
  "properties": [],
  "superType": {
    "$class": "[email protected]",
    "name": "Self_Extending"
  }
}

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to main from fork:branchname

Stefan Blaginov added 6 commits November 27, 2023 19:24
Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>
…amodel form

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>
…certo-cto)

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>
@stefanblaginov stefanblaginov marked this pull request as ready for review November 27, 2023 19:39
@stefanblaginov stefanblaginov force-pushed the stefanblaginov/fix-self-extending branch 2 times, most recently from 3817599 to 34209b0 Compare November 27, 2023 20:16
@mttrbrts mttrbrts merged commit 886a91b into accordproject:main Nov 28, 2023
11 checks passed
@stefanblaginov stefanblaginov deleted the stefanblaginov/fix-self-extending branch November 28, 2023 10:28
@stefanblaginov stefanblaginov restored the stefanblaginov/fix-self-extending branch November 28, 2023 10:28
@stefanblaginov stefanblaginov deleted the stefanblaginov/fix-self-extending branch November 28, 2023 10:29
mttrbrts pushed a commit to mttrbrts/composer-concerto that referenced this pull request Mar 10, 2024
…#767)

* fix(parser): throw error when concept is extending itself in CTO

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>

* fix(parser): throw error when concept is extending itself in JSON metamodel form

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>

* fix(parser): throw error when concept is extending itself in the AST

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>

* refactor(validation): alphabetical rearrangement

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>

* test(self-extending): remove redundant tests (codepath covered in concerto-cto)

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>

* test(fix): remove unneeded import

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>

---------

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>
Co-authored-by: Stefan Blaginov <[email protected]>
mttrbrts pushed a commit to mttrbrts/composer-concerto that referenced this pull request Mar 11, 2024
…#767)

* fix(parser): throw error when concept is extending itself in CTO

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>

* fix(parser): throw error when concept is extending itself in JSON metamodel form

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>

* fix(parser): throw error when concept is extending itself in the AST

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>

* refactor(validation): alphabetical rearrangement

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>

* test(self-extending): remove redundant tests (codepath covered in concerto-cto)

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>

* test(fix): remove unneeded import

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>

---------

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>
Co-authored-by: Stefan Blaginov <[email protected]>
mttrbrts added a commit that referenced this pull request Mar 11, 2024
* fix(build): include unions in index

Signed-off-by: Matt Roberts <[email protected]>

* chore(deps): upgrade codegen to latest release

Signed-off-by: Matt Roberts <[email protected]>

---------

Signed-off-by: Matt Roberts <[email protected]>

* fix(class): throw error when class is extending itself (#767)

* fix(parser): throw error when concept is extending itself in CTO

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>

* fix(parser): throw error when concept is extending itself in JSON metamodel form

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>

* fix(parser): throw error when concept is extending itself in the AST

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>

* refactor(validation): alphabetical rearrangement

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>

* test(self-extending): remove redundant tests (codepath covered in concerto-cto)

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>

* test(fix): remove unneeded import

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>

---------

Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>
Co-authored-by: Stefan Blaginov <[email protected]>

* fix(class-declaration): throw with undefined ast properties (#771)

Signed-off-by: Ertugrul Karademir <[email protected]>

* fix(error): adding type to error in string validator in introspect (#773)

* fix(error): adding type to error in string validator in introspect

Signed-off-by: Santanu Roy <[email protected]>
Co-authored-by: Santanu Roy <[email protected]>

* refactor(declarations): move declaration uniqueness check to model file (#794)

* refactor(declarations): Move unique name check to model file.

Signed-off-by: Ertugrul Karademir <[email protected]>

* refactor(test): move validation checks for duplicate class to model file

Signed-off-by: Ertugrul Karademir <[email protected]>

* test: empty commit to trigger test

Signed-off-by: Ertugrul Karademir <[email protected]>

---------

Signed-off-by: Ertugrul Karademir <[email protected]>

* perf(core): don't use arrays to check uniqueness (#802)

refactor: don't use arrays to check uniqueness

Signed-off-by: Ertugrul Karademir <[email protected]>

* perf(core): remove usage of arrays while forming duplicate item errors (#804)

* refactor: don't use arrays to check uniqueness

Signed-off-by: Ertugrul Karademir <[email protected]>

* refactor: also refactor unique property name check

Signed-off-by: Ertugrul Karademir <[email protected]>

* refactor: remove array for decorator uniqueness check

Signed-off-by: Ertugrul Karademir <[email protected]>

* refactor: remove uniqueness check from scalar declarations as well

Signed-off-by: Ertugrul Karademir <[email protected]>

---------

Signed-off-by: Ertugrul Karademir <[email protected]>

---------

Signed-off-by: Matt Roberts <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Stefan Blaginov <[email protected]>
Signed-off-by: Ertugrul Karademir <[email protected]>
Signed-off-by: Santanu Roy <[email protected]>
Co-authored-by: Stefan Blaginov <[email protected]>
Co-authored-by: Stefan Blaginov <[email protected]>
Co-authored-by: Ertugrul Karademir <[email protected]>
Co-authored-by: Santanu Roy <[email protected]>
Co-authored-by: Santanu Roy <[email protected]>
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.

Should not be able to create a concept whose super type is itself
2 participants