Skip to content

Fix sibling nested structs leaking into each other on import (#56) - #57

Merged
jhughes-dev merged 2 commits into
mainfrom
fix-sibling-struct-import-56
Oct 30, 2026
Merged

jhughes-dev merged 2 commits into
mainfrom
fix-sibling-struct-import-56

Conversation

@aylindmello

Copy link
Copy Markdown
Collaborator

Fixes #56.

Problem

When a struct, dictionary, or containers.Map with nested struct/dictionary values was converted to YAMLData/TOMLData (via yamldata, tomldata, writeyaml, writetoml, or dot assignment), each nested value was imported into a copy of the parent object. Later siblings therefore picked up copies of earlier ones, silently corrupting written files.

Fix

importFrom now starts from a fresh, empty object of the same class before importing, so parent state never carries into a nested value.

Tests

  • New tests/siblingStructImportTest.m (10 tests × YAML/TOML): two/three siblings, field order, deeper nesting, non-struct siblings, dictionaries, containers.Map, dot assignment into a populated object, single-element struct next to a table, and write/read round trips.
  • All 20 new cases fail without the fix and pass with it; full suite passes (440/440).
  • Updated stale header comment in tests/dataConstructorTest.m.

🤖 Generated with Claude Code

aylindmello and others added 2 commits October 30, 2026 09:07
Verify that importing a struct, dictionary, or containers.Map with
nested struct/dictionary values keeps each value independent of its
siblings, including through writetoml/writeyaml round trips.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@aylindmello aylindmello self-assigned this Oct 30, 2026
@jhughes-dev
jhughes-dev merged commit a41d135 into main Oct 30, 2026
14 checks passed
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.

[struct import / writetoml / writeyaml] — Writing a struct with sibling scalar-struct fields — later siblings get copies of earlier siblings

2 participants