Add tuple support - #682
Merged
Merged
Conversation
AAS query languages need fixed-arity, heterogeneously-typed sequences to represent operator arguments, which the existing meta-model type system could not express: only lists (homogeneous, variable-length) and single values were available. This adds a ``Tuple[...]`` type annotation to the meta-model and generates matching support across all targets.
Coverage Report for CI Build 34387644954Coverage increased (+0.2%) to 84.851%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions3122 previously-covered lines in 66 files lost coverage.
Coverage Stats
💛 - Coveralls |
mristin
added a commit
that referenced
this pull request
Sep 17, 2026
`unrolling.py` was written for type annotations which nest: a visitor over `TypeAnnotationUnion` building a tree of `Node`s, which `render` then turned into nested loops. Five generators carried a copy, and only three of them ever imported one -- `cpp/` and `golang/` had been orphaned for a while, and still had to be given `_unroll_tuple_type_annotation` when the tuples landed in #682. The three live copies were used in exactly one place each, the body of `descend` and `descend_once`. Nothing else in a code generator unrolls anything: 51 sites across the six languages assert `AtomicTypeAnnotationAsTuple` on the items of a list, in de/serialization, in verification, in enhancing and in copying. A property which needed the unroller would therefore have died on one of those asserts long before it reached the descent. So the generality was unreachable everywhere it was paid for, and `descend` is written here the way Go and Java already wrote it -- an `if`/`elif` over the annotation, with the optional wrapped around the whole property once at the end: elif isinstance( type_anno.our_type, (intermediate.AbstractClass, intermediate.ConcreteClass) ): prop_blocks.append(Stripped(f"yield self.{prop_name}")) if recurse: prop_blocks.append( Stripped(f"yield from self.{prop_name}.descend()") ) Two conditions turn out to have been vacuous. `map_descendability` gives `True` for every `OurTypeAnnotation` over a class or a named union, and the enumerations and the constrained primitives have already returned by the time it is consulted, so `_descendability[type_annotation]` only ever held; the C# `else` behind it emitted `// Recursive descent ends here.`, which appears in no recorded output. C# also threaded an `item_level` through five signatures, and a `key_value_level` left over from the dictionaries which the meta-model never got, to pick between two loop variable names. A list holds atomic values, so the descent nests one loop deep and the two names are constants. The generated code is unchanged, byte for byte, against every recorded file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AAS query languages need fixed-arity, heterogeneously-typed sequences to represent operator arguments, which the existing meta-model type system could not express: only lists (homogeneous, variable-length) and single values were available.
This adds a
Tuple[...]type annotation to the meta-model and generates matching support across all targets.