Skip to content

fix(net): evict stale reverse-map entry when casting and renaming an unbound net - #1222

Open
detail-app[bot] wants to merge 2 commits into
mainfrom
detail/bug-fix/fix-net-evict-stale-reverse-map-entry-when-casting-26c9cd
Open

detail-app[bot] wants to merge 2 commits into
mainfrom
detail/bug-fix/fix-net-evict-stale-reverse-map-entry-when-casting-26c9cd

Conversation

@detail-app

@detail-app detail-app Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

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 new Net("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_net gains a prior_was_bound flag wired from net registration and passes false for interface template clones.

unregister_net now 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 both PWR and SIG.

Reviewed by Cursor Bugbot for commit bc9f894. Bugbot is set up for automated code reviews on this repo. Configure here.

@detail-app
detail-app Bot requested a review from LK September 6, 2026 02:28
@detail-app detail-app Bot assigned LK Sep 6, 2026
@detail-app detail-app Bot added the detail label Sep 6, 2026

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This report is out of date. Scroll down for Devin Review's latest report on this PR.

Devin Review found 1 potential issue.

Devin Review

Comment on lines +829 to +833
if !prior_was_bound
&& let Some(old_name) = existing.name.named()
&& old_name != base_name
{
self.net_name_to_id.shift_remove(old_name);

@devin-ai-integration devin-ai-integration Bot Sep 6, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@akhilles
akhilles force-pushed the detail/bug-fix/fix-net-evict-stale-reverse-map-entry-when-casting-26c9cd branch from cd8d345 to 66c5b67 Compare September 7, 2026 04:24

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Devin Review

Comment on lines +816 to +820
if !prior_was_bound
&& let Some(old_name) = existing.name.named()
&& old_name != base_name
{
self.net_name_to_id.shift_remove(old_name);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@akhilles
akhilles force-pushed the detail/bug-fix/fix-net-evict-stale-reverse-map-entry-when-casting-26c9cd branch from 66c5b67 to 1d0e9fc Compare September 7, 2026 15:22

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@akhilles
akhilles force-pushed the detail/bug-fix/fix-net-evict-stale-reverse-map-entry-when-casting-26c9cd branch from 1d0e9fc to 42c873c Compare September 7, 2026 16:02

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@detail-app
detail-app Bot force-pushed the detail/bug-fix/fix-net-evict-stale-reverse-map-entry-when-casting-26c9cd branch from 42c873c to bc9f894 Compare September 8, 2026 07:28

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants