fix(net): evict stale reverse-map entry when casting and renaming an unbound net - #1222
detail-app[bot] wants to merge 2 commits into
Conversation
| if !prior_was_bound | ||
| && let Some(old_name) = existing.name.named() | ||
| && old_name != base_name | ||
| { | ||
| self.net_name_to_id.shift_remove(old_name); |
There was a problem hiding this comment.
🟡 Container-held net names become reusable
When a named net survives inside a container, casting and renaming it removes its old net_name_to_id entry. was_bound only tracks direct net exports, so container-held references look disposable. Another net can reuse the live name, violating uniqueness.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Stale comment
Not approved: this changes evaluator net-name uniqueness (user-visible language behavior), so it is not a small fixup and still needs human review. Cursor Bugbot and Cursor Security Agent both passed with no findings that require human review; reviewers were not assigned.
Sent by Cursor Approval Agent: Pull Request Router and Approver
cd8d345 to
66c5b67
Compare
| if !prior_was_bound | ||
| && let Some(old_name) = existing.name.named() | ||
| && old_name != base_name | ||
| { | ||
| self.net_name_to_id.shift_remove(old_name); |
There was a problem hiding this comment.
🟡 Nested casts reserve discarded names
When an unbound intermediate cast inherits a bound ancestor, prior_was_bound keeps the intermediate name reserved. The intermediate value does not survive the outer cast. Reusing its name then raises a false duplicate-name error.
Prompt for agents
Track whether the immediately cast NetValue was itself exported, separately from the inherited was_bound marker that identifies a bound ancestor. In NetTypeGen::instantiate, nested casts currently clone was_bound from their base, so Power2(Power(sig, name="MID"), name="PWR") reports the unbound MID value as bound when register_net decides whether to release MID. Preserve names for actual surviving bound values, but release names belonging only to discarded intermediate cast results. Add an end-to-end regression where sig is bound, an unbound inner cast is renamed again by an outer cast, and a fresh net successfully reuses the inner cast's name.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Stale comment
Not approved: this still changes evaluator net-name uniqueness (user-visible language behavior), so it is not a small fixup and needs human review. Cursor Bugbot passed with no findings that require human review; Cursor Security Agent was not present. Reviewers were not assigned.
Sent by Cursor Approval Agent: Pull Request Router and Approver
66c5b67 to
1d0e9fc
Compare
There was a problem hiding this comment.
Stale comment
Not approved: this still changes evaluator net-name uniqueness (user-visible language behavior), so it is not a small fixup and needs human review. Cursor Bugbot passed with no findings that require human review; Cursor Security Agent was not present. Reviewers were not assigned.
Sent by Cursor Approval Agent: Pull Request Router and Approver
1d0e9fc to
42c873c
Compare
There was a problem hiding this comment.
Stale comment
Not approved: this still changes evaluator net-name uniqueness (user-visible language behavior), so it is not a small fixup and needs human review. Cursor Bugbot passed with no findings that require human review; Cursor Security Agent was not present. Reviewers were not assigned.
Sent by Cursor Approval Agent: Pull Request Router and Approver
42c873c to
bc9f894
Compare
There was a problem hiding this comment.
Not approved: this still changes evaluator net-name uniqueness (user-visible language behavior), so it is not a small fixup and needs human review. Cursor Bugbot passed with no findings that require human review; Cursor Security Agent was not present. Reviewers were not assigned.
Sent by Cursor Approval Agent: Pull Request Router and Approver


Release the old name when a cast renames an unbound net, and remove all reserved names when a template net is unregistered. Keep bound names reserved and validate duplicate names before changing registry state. Add focused regression coverage and record the fix under Unreleased.
Note
Medium Risk
Changes core net registration and uniqueness rules used during evaluation and netlist export; behavior shifts for cast/rename edge cases but is covered by new tests.
Overview
Fixes module net-name bookkeeping so casting/renaming an unbound net drops the old string from
net_name_to_id, letting a newNet("SIG")(or similar) take that name while duplicate checks still run before updating state.Bound casts (e.g.
Power(sig, name="PWR")on a named net) still reserve the original name and reject reuse.register_netgains aprior_was_boundflag wired from net registration and passesfalsefor interface template clones.unregister_netnow clears every reverse-map entry for a net id (needed when one id held multiple cast aliases) instead of removing a single name. Unit and integration tests cover failed duplicate renames, template/interface reuse, and netlisting bothPWRandSIG.Reviewed by Cursor Bugbot for commit bc9f894. Bugbot is set up for automated code reviews on this repo. Configure here.