Skip to content

Add tuple support - #682

Merged
mristin merged 1 commit into
mainfrom
mristin/Support-tuples
Sep 9, 2026
Merged

mristin merged 1 commit into
mainfrom
mristin/Support-tuples

Conversation

@mristin

@mristin mristin commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

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.

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.
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 34387644954

Coverage increased (+0.2%) to 84.851%

Details

  • Coverage increased (+0.2%) from the base build.
  • Patch coverage: Could not be determined — this PR's diff is too large for GitHub to return (406 error at GitHub).
  • 3122 coverage regressions across 66 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

3122 previously-covered lines in 66 files lost coverage.

Top 10 Files by Coverage Loss Lines Losing Coverage Coverage
aas_core_codegen/intermediate/type_inference.py 267 68.23%
aas_core_codegen/intermediate/_translate.py 237 84.91%
aas_core_codegen/cpp/transpilation.py 170 60.79%
aas_core_codegen/java/transpilation.py 147 65.43%
aas_core_codegen/parse/_translate.py 141 84.32%
aas_core_codegen/golang/transpilation.py 134 67.07%
aas_core_codegen/typescript/transpilation.py 133 67.31%
aas_core_codegen/csharp/transpilation.py 120 68.71%
aas_core_codegen/python/transpilation.py 114 64.57%
aas_core_codegen/parse/tree.py 103 77.11%

Coverage Stats

Coverage Status
Relevant Lines: 38385
Covered Lines: 32570
Line Coverage: 84.85%
Coverage Strength: 2.55 hits per line

💛 - Coveralls

@mristin
mristin merged commit 9e02e7b into main Sep 9, 2026
5 checks passed
@mristin
mristin deleted the mristin/Support-tuples branch September 9, 2026 18:24
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.
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.

2 participants