Fix relative path resolution in group labels (issue #1063) #1186
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relative path components (
..,.) in group labels were not being resolved against parent path context, causing widgets that should be shared across groups to be duplicated.Previously,
hgroup("../FREQ", ...)treated"../FREQ"as a literal group name. Now both forms resolve identically, enabling proper widget sharing.Changes
compiler/propagate/labels.cpp: Added
normalizeGroupPath()that parses group labels for relative path components, resolves them against current path using existingconcatPath()logic, and encodes the final name with group type (h/v/t). Handles edge cases: multiple..levels, going beyond root, namespace prefixes.compiler/propagate/propagate.cpp: Updated
isBoxVGroup,isBoxHGroup,isBoxTGrouphandlers to callnormalizeGroupPath()instead of directly consing labels onto path.tests/codegen-tests/: Added regression tests verifying both forms produce identical UI.
Fixes #1063
Original prompt
Problem
Relative paths used inside groups are not being resolved correctly by the label propagation pass. Example reported in issue #1063:
In this repro the explicit path in vslider works ("../h:FREQ/Freq") but using hgroup("../FREQ", vslider("Freq",...)) does not, indicating that relative ".." segments are not being resolved against the group parent path correctly. The bug appears to be in normalizePath in compiler/propagate/labels.cpp or in the caller logic that joins parent and child paths before normalization.
Goal
Implement a correct and robust path normalization/joining strategy so relative labels (./, ../, and plain relative names) are resolved against the parent/group path, handle namespace prefixes (like "h:") properly, and add a regression unit test that reproduces and guards against future regressions.
Scope of changes
Modify compiler/propagate/labels.cpp to ensure normalization happens after joining base (parent) and child paths. Improve normalizePath so it:
Update all callers in the propagate/labels pass to join base and child path first (e.g., parent + '/' + child) and call normalizePath on the joined path, rather than normalizing child in isolation.
Add a regression test under tests/ (or the project test harness) that compiles the minimal repro and asserts that the resolved label for the vslider inside hgroup("../FREQ", vslider("Freq", ...)) matches the expected canonical path used by the working string literal case. The test should check that both forms resolve to the same resolved label and that grouping sharing works as the working case demonstrates.
Implementation details (actionable)
In compiler/propagate/labels.cpp:
Tests
Build and run test suite to ensure no regressions.
Expected behavior
Notes and constraints
Files likely to change
Deliverables
This pull request was created as a result of the following prompt from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.