Skip to content

Fix Go SDK compilation for subtype slice arguments - #847

Closed
chris-koo wants to merge 1 commit into
eclipse-aascw:mainfrom
chris-koo:chriskoo/fix-golang-readonly-slice-arguments
Closed

chris-koo wants to merge 1 commit into
eclipse-aascw:mainfrom
chris-koo:chriskoo/fix-golang-readonly-slice-arguments

Conversation

@chris-koo

Copy link
Copy Markdown

Generated Go verification fails to compile when a descendant-interface
slice is passed to a function expecting a base-interface slice, for example
[]ISomeItem to []IAbstractItem.

We convert only mismatching slices passed to read-only transpiled verification
functions. The conversion preserves nil and evaluates each argument once.
We extend the shared regression model for non-optional and optional calls
and regenerate the affected parse, intermediate, and SDK goldens.

Refs #840. Following the review of #841, this PR isolates the compilation fix.

Validation

  • Full pre-commit suite passes on Linux with Python 3.12, including 937 unit
    tests, doctests, metadata checks, and the README help check.
  • Go fast check and live tests pass for list_of_classes.
  • An additional manual Go test passes for nil, empty, and nonempty slices.
  • The new regression test case reproduces the compilation failure with the
    unchanged upstream generator.
  • The V3.2 SDK generated from the local codegen source passes go build ./....

We convert descendant-interface slices passed to read-only verification
functions, allowing ``[]ISomeItem`` arguments for ``[]IAbstractItem``.
We preserve nil and avoid copies for matching slice types.

We cover non-optional and optional calls in the shared regression model
and regenerate the affected parse, intermediate, and SDK goldens.
@mristin

mristin commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Thanks, @chris-koo ! I looked at the code. Do I understand that correctly -- you make an in-situ copy of the list to satisfy the invariance in Go? Isn't that something that caller needs to do, not the called code?

Could we maybe discuss this change in a phone call live rather than over GitHub?

@mristin

mristin commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Superseded by #852.

@mristin mristin closed this Oct 15, 2026
@mristin

mristin commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Just a note to this PR: it created a copy on every invocation, which is potentially inefficient. #852 uses generics, analogous to what we did with implementation-specific Go snippets for AAS V3.1 so that no copies need be created.

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