Skip to content

Fix duplicate names in composite components #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

gpeairs
Copy link
Member

@gpeairs gpeairs commented Jul 21, 2025

As a consequence of #63, a composite component's subcomponents would not get unique names for their geometry coordinate systems if rendered directly to a Cell (i.e., if render! were called without build!, which replaces comp with geometry(comp) in references). Even prior to that, Path components would get turned into coordinate systems with the path's name, not the unique geometry name, and this would happen whether build! was called first or not.

This fix does a couple things to ensure different components get rendered as coordinate systems with unique names (whether build! is called or not). First, when we encounter a component while rendering to a Cell, we use its coordsys_name (unique by construction, usually name(geometry(comp))) rather than its (non-unique) name(comp) to name the Cell that holds its rendered elements and references.

This doesn't quite solve the Path problem because of the slightly hacky _geometry!(cs, path), which adds the path itself to an intermediate coordinate system path._geometry with a unique name. (We do this for some complicated and subtle reasons where I couldn't find a better solution.) So if we defined coordsys_name(path) = name(geometry(path)), then we'd still end up with a stack of two identically named Cells -- the wrapper from path._geometry, and (in its references) the one containing the path's rendered elements and references. To get around this, coordsys_name(::Path) checks whether path._geometry contains the Path already. If it does, then we use uniquename(name(path)) for the second cell. This is also a little hacky, but as long as we understand that this new function coordsys_name is meant only for this rendering context I don't see it causing any problems.

Copy link

codecov bot commented Jul 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

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.

1 participant