From dda345735854c83a7943bbc0f91406903b4cb78e Mon Sep 17 00:00:00 2001 From: Tim Fischer Date: Sat, 1 Aug 2026 17:07:39 +0200 Subject: [PATCH 1/2] fix(rewriter): preserve scoped nested renames --- crates/bender-slang/cpp/rewriter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/bender-slang/cpp/rewriter.cpp b/crates/bender-slang/cpp/rewriter.cpp index e2aaf717..53126ebc 100644 --- a/crates/bender-slang/cpp/rewriter.cpp +++ b/crates/bender-slang/cpp/rewriter.cpp @@ -198,6 +198,8 @@ class ReferenceRewriter : public SyntaxRewriter { ScopedNameSyntax* newNode = deepClone(node, alloc); newNode->left = newLeft; + rewrite_scoped_names_inplace(*newNode->right); + replace(node, *newNode); refRenamed++; } From ce6d9190ef5b0b5239b846a292eff5adaacfb7d5 Mon Sep 17 00:00:00 2001 From: Tim Fischer Date: Sat, 1 Aug 2026 17:07:57 +0200 Subject: [PATCH 2/2] tests: add test case for scoped nested renames --- tests/pickle.rs | 10 ++++++++++ tests/pickle/src/common_pkg.sv | 2 ++ tests/pickle/src/core.sv | 3 +++ 3 files changed, 15 insertions(+) diff --git a/tests/pickle.rs b/tests/pickle.rs index 912e2cdd..3d5a0243 100644 --- a/tests/pickle.rs +++ b/tests/pickle.rs @@ -146,6 +146,16 @@ mod tests { assert!(!renamed.contains("common_pkg::Idle")); } + #[test] + fn pickle_rename_renames_scoped_packed_dimensions() { + let renamed = run_pickle(&["--prefix", "p_", "--suffix", "_s", "--expand-macros"]); + + // A packed dimension is parsed as part of the scoped type name it follows, + // so a scoped name inside it must be renamed along with the type itself. + assert!(renamed.contains("p_common_pkg_s::state_t [p_common_pkg_s::NumStates-1:0]")); + assert!(!renamed.contains("common_pkg::NumStates-1:0")); + } + #[test] fn pickle_rename_renames_scoped_instantiation_params() { let renamed = run_pickle(&[ diff --git a/tests/pickle/src/common_pkg.sv b/tests/pickle/src/common_pkg.sv index 7a2d02d5..6f35f717 100644 --- a/tests/pickle/src/common_pkg.sv +++ b/tests/pickle/src/common_pkg.sv @@ -1,5 +1,7 @@ package common_pkg; + parameter int unsigned NumStates = 3; + typedef enum logic [1:0] { Idle = 2'b00, Busy = 2'b01, diff --git a/tests/pickle/src/core.sv b/tests/pickle/src/core.sv index 30c0baa4..87de7e77 100644 --- a/tests/pickle/src/core.sv +++ b/tests/pickle/src/core.sv @@ -1,5 +1,8 @@ module core #( parameter common_pkg::state_t DefaultState = common_pkg::Idle ) (); + // Scoped type name carrying a packed dimension that is itself a scoped name. + common_pkg::state_t [common_pkg::NumStates-1:0] state_history; + leaf u_leaf(); endmodule