Skip to content

Small SDC fixes#63

Merged
akashlevy merged 1 commit into
mainfrom
small_sdc_fixes
Jul 6, 2026
Merged

Small SDC fixes#63
akashlevy merged 1 commit into
mainfrom
small_sdc_fixes

Conversation

@greptile-apps

greptile-apps Bot commented Jul 6, 2026

Copy link
Copy Markdown

Greptile Summary

Three SDC compatibility fixes: foreach_in_collection now correctly quotes loop variables via [list ...] so values with spaces or special characters no longer break the iterator; append_to_collection auto-initializes an unset target variable instead of erroring; and a suppress_message stub is added so SDC files using that command don't abort.

  • tcl/Collections.tcluplevel 1 set … replaced with uplevel 1 [list set …] in both the collection and plain-list paths of foreach_in_collection, and append_to_collection gains a guard that initializes the target variable to {} when it doesn't yet exist.
  • tcl/Extras.tcl — New suppress_message stub follows the same warn-and-continue pattern used by other unsupported SDC commands.
  • test/ — New remove_input_delay regression added to the public suite; collections.tcl gains an auto-init test case; both golden files are updated accordingly.

Confidence Score: 4/5

Safe to merge; all three fixes are targeted and well-tested with new golden-output regression cases.

The [list] quoting fix and append_to_collection auto-init are correct and covered by updated tests. The plain-list path of foreach_in_collection still doesn't handle break/continue from the body the way the collection path does, which is a pre-existing gap that this PR touches but doesn't close. The suppress_message stub may generate noisy output in large SDC files, but it's non-blocking.

tcl/Collections.tcl — the plain-list branch of foreach_in_collection warrants a closer look for break/continue propagation.

Important Files Changed

Filename Overview
tcl/Collections.tcl Two fixes: uplevel [list ...] quoting for special-character safety in foreach_in_collection, and auto-initialization of unset variables in append_to_collection. The plain-list path of foreach_in_collection still lacks break/continue/error handling that the collection path has.
tcl/Extras.tcl Adds a suppress_message stub that warns and returns. Consistent with existing stubs but may produce verbose output if called many times in a production SDC file.
test/collections.tcl Adds a test case for the auto-initialization behavior of append_to_collection on an unset variable; assertions cover both existence and format of the resulting collection.
test/remove_input_delay.tcl New regression test covering remove_input_delay/remove_output_delay and their reset_* aliases with both direct collection arguments and list-wrapped collections across single-bit ports and multi-bit buses.
test/regression_vars.tcl Adds remove_input_delay to the public regression suite in correct alphabetical order.
test/collections.ok Expected output updated to include results of the new auto-initialization test case; 34 ports listed matches get_ports req_* count.
test/remove_input_delay.ok New golden output file for the remove_input_delay regression; all 10 scenarios show correct before/after delay counts.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["append_to_collection called"] --> B{"upvar target\nvariable exists?"}
    B -- "No (NEW)" --> C["auto-init: set coll {}"]
    B -- "Yes" --> D{"is_collection?"}
    C --> D
    D -- "Yes (native collection)" --> E["collection_append_inplace\n(in-place mutation)"]
    D -- "No (Tcl list)" --> F["collection_plus\n(functional update)"]

    G["foreach_in_collection called"] --> H{"is_collection?"}
    H -- "Yes" --> I["iterator path\nwith catch for break/continue/error"]
    H -- "No" --> J["foreach path\nuplevel [list set var val] (FIXED)\nbody called without catch"]
    I --> K["uplevel [list set var val] (FIXED)\nuplevel body with catch"]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["append_to_collection called"] --> B{"upvar target\nvariable exists?"}
    B -- "No (NEW)" --> C["auto-init: set coll {}"]
    B -- "Yes" --> D{"is_collection?"}
    C --> D
    D -- "Yes (native collection)" --> E["collection_append_inplace\n(in-place mutation)"]
    D -- "No (Tcl list)" --> F["collection_plus\n(functional update)"]

    G["foreach_in_collection called"] --> H{"is_collection?"}
    H -- "Yes" --> I["iterator path\nwith catch for break/continue/error"]
    H -- "No" --> J["foreach path\nuplevel [list set var val] (FIXED)\nbody called without catch"]
    I --> K["uplevel [list set var val] (FIXED)\nuplevel body with catch"]
Loading

Reviews (1): Last reviewed commit: "Small SDC fixes" | Re-trigger Greptile

Comment thread tcl/Extras.tcl
Comment thread tcl/Collections.tcl
Comment thread tcl/Collections.tcl
Comment thread tcl/Collections.tcl
@akashlevy akashlevy merged commit a4b9c29 into main Jul 6, 2026
9 checks passed
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