Look over collections with root

Issue #251 new
Görel Hedin created an issue

Look over how collections with root are defined. Is it possible to get strange behavior when contributing to a node outside the root subtree?

Example: Suppose we have Decls and Uses, and an attribute localUses in Decl with the root Module (an ancestor to Decl). Could other Uses by mistake contribute to localUses? Should/could the evaluation algorithm take care of this? Can we give an error message?

Need to create some test cases for this. Need to think about how this should work.

Comments (6)

  1. Jesper Öqvist

    Collection contributions should not contribute to nodes outside the subtree rooted at the nearest collection root node. That seems like a clear misuse of collection attributes.

    The current unreleased version of JastAdd discards contributions that have a target node outside the subtree rooted at the closest collection root because there is now a map on the root node that tracks contributors rather than collections on each target node, which was the behavior in version 2.1.13. We could add a debug check, when using the --debug flag, which reports an error if such a contribution is found during runtime.

  2. Görel Hedin reporter

    Notes after our discussion:

    It's a good idea to have a debug flag.

    The new implementation (in 2.2.0) looks correct. But there is a potential inefficiency if there are recursive roots. The root contributor maps will then collect some irrelevant contributors. In particular, an upper root map will collect all the contributors that relate to lower root maps. We could look into this at some point.

  3. Jesper Öqvist

    I have added a new runtime debug check and test for the debug check. The runtime check tests that the source and target nodes of a contribution are under some common collection root node.

  4. Jesper Öqvist

    Add collection attribute runtime debug check

    Added a runtime debug check for collection attributes, checking that a contribution contributes to a target node that is under a common collection root node with the source node.

    Removed target null check in collection attribute code - the target of a contribution should always be non null.

    see #251 (bitbucket)

    → <<cset 9ddf1fc12e29>>

  5. Log in to comment