Skip to content

Support list literals and append - #849

Merged
mristin merged 1 commit into
mainfrom
mristin/support-list-literals-and-append
Oct 15, 2026
Merged

mristin merged 1 commit into
mainfrom
mristin/support-list-literals-and-append

Conversation

@mristin

@mristin mristin commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

We support list literals, e.g., for prime in [2, 3, 5, 7]:, and append on local lists, e.g., result.append(len(text)), in all the targets, so that the meta-model can build lists in the verification functions. An empty list literal needs a declared type, e.g., result: List[int] = [].

We allow append only on a local list variable which is never aliased. Go appends with items = append(items, item), which gives a new slice whenever the array beneath has to grow, and C++ copies the lists on assignment, so the aliases would diverge from Python.

We also infer in Go the is-pointer of the collection of a generator, which crashed on all(... for x in f(self.y)).

We support list literals, *e.g.*, ``for prime in [2, 3, 5, 7]:``, and
``append`` on local lists, *e.g.*, ``result.append(len(text))``, in all
the targets, so that the meta-model can build lists in the verification
functions. An empty list literal needs a declared type, *e.g.*,
``result: List[int] = []``.

We allow ``append`` only on a local list variable which is never
aliased. Go appends with ``items = append(items, item)``, which gives
a new slice whenever the array beneath has to grow, and C++ copies the
lists on assignment, so the aliases would diverge from Python.

We also infer in Go the is-pointer of the collection of a generator,
which crashed on ``all(... for x in f(self.y))``.
@mristin
mristin merged commit 64ef074 into main Oct 15, 2026
5 checks passed
@mristin
mristin deleted the mristin/support-list-literals-and-append branch October 15, 2026 20:08
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 38797701430

Coverage decreased (-0.02%) to 90.127%

Details

  • Coverage decreased (-0.02%) from the base build.
  • Patch coverage: 50 uncovered changes across 12 files (356 of 406 lines covered, 87.68%).
  • No coverage regressions found.

Uncovered Changes

Top 10 Files by Coverage Impact Changed Covered %
aas_core_codegen/csharp/transpilation.py 29 22 75.86%
aas_core_codegen/golang/transpilation.py 32 25 78.13%
aas_core_codegen/java/transpilation.py 39 32 82.05%
aas_core_codegen/intermediate/type_inference.py 165 159 96.36%
aas_core_codegen/typescript/transpilation.py 20 15 75.0%
aas_core_codegen/cpp/transpilation.py 33 29 87.88%
aas_core_codegen/golang/pointering.py 14 11 78.57%
aas_core_codegen/python/transpilation.py 16 13 81.25%
aas_core_codegen/cpp/optionaling.py 10 8 80.0%
aas_core_codegen/java/optional.py 10 8 80.0%
Total (13 files) 406 356 87.68%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 50613
Covered Lines: 45616
Line Coverage: 90.13%
Coverage Strength: 2.7 hits per line

💛 - Coveralls

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