Skip to content

refactor(sv)!: bind assignment patterns without rewriting source - #1467

Merged
mergify[bot] merged 1 commit into
masterfrom
stack/tignear/refactor/sv-native-bindings/bind-assignment-patterns-without-rewriting-source--6d1a9211
Oct 18, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
stack/tignear/refactor/sv-native-bindings/bind-assignment-patterns-without-rewriting-source--6d1a9211

Conversation

@tignear

@tignear tignear commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Parameter assignment patterns now travel as structured bindings from the caller into the receiving declaration. This preserves declaration defaults, independent instance bindings, caller-resolved types and constants, and the receiver's sizing context without serializing expressions into replacement SystemVerilog.

Remove pattern text substitution and reparsing from specialization. Add shared regressions for isolated instance bindings and enclosing arithmetic, with retained Icarus unsupported-syntax evidence.

Validation: analyzer/frontend unit tests; full SV backend suite; DPI and unpacked-array suites; formatting; clippy on analyzer, frontend and test suite. Verilator passes both new shared regressions; Icarus rejects their unsupported parameter-pattern syntax, recorded under the existing limitations.

BREAKING CHANGE: ParameterOverride::pattern_text becomes bound_pattern, ParsedSource::analyze_module accepts structured pattern bindings, and with_pattern_parameter_overrides is removed.

@tignear

tignear commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 refactor(sv)!: bind assignment patterns without rewriting source #1467 👈
2 refactor(sv)!: lower interfaces from original syntax #1468
3 fix(sv): preserve interface bindings during declaration analysis #1474

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T02:16:13.561373Z b4519bc New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 18, 2026
Parameter assignment patterns now travel as structured bindings from the caller into the receiving declaration. This preserves declaration defaults, independent instance bindings, caller-resolved types and constants, and the receiver's sizing context without serializing expressions into replacement SystemVerilog.

Remove pattern text substitution and reparsing from specialization. Add shared regressions for isolated instance bindings and enclosing arithmetic, with retained Icarus unsupported-syntax evidence.

Validation: analyzer/frontend unit tests; full SV backend suite; DPI and unpacked-array suites; formatting; clippy on analyzer, frontend and test suite. Verilator passes both new shared regressions; Icarus rejects their unsupported parameter-pattern syntax, recorded under the existing limitations.

BREAKING CHANGE: ParameterOverride::pattern_text becomes bound_pattern, ParsedSource::analyze_module accepts structured pattern bindings, and with_pattern_parameter_overrides is removed.

Change-Id: I6d1a921182f71c4e4bcebfc945366be9d27c872d
@tignear
tignear force-pushed the stack/tignear/refactor/sv-native-bindings/bind-assignment-patterns-without-rewriting-source--6d1a9211 branch from c39aa09 to b4519bc Compare October 18, 2026 02:11
@tignear

tignear commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Revision history

# Type Changes Reason Date
1 initial c39aa09 2026-10-18 02:10 UTC
2 content c39aa09 → b4519bc Fix CI retained-report consistency: register the new reviewed Icarus pattern exclusions and synchronize their metadata. 2026-10-18 02:10 UTC

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b4519bc46b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +278 to +284
shapes = vec![
VariableDimensions {
unpacked: rest.to_vec(),
..shape.clone()
};
count
];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate pattern arity before allocating target elements

When a large unpacked parameter is overridden by a wrong-sized positional or repeated pattern, this eagerly clones one VariableDimensions and creates one key for every declared element before the arity checks at lines 353–369 can reject the override. A declaration such as a billion-element unpacked array with a one-item override can therefore abort compilation from allocation failure instead of returning the intended unsupported-pattern error; check list/repetition cardinality before materializing these vectors or construct the shapes lazily.

Useful? React with 👍 / 👎.

Comment on lines +379 to +384
keys.iter()
.map(|key| {
items
.iter()
.rev()
.find(|(k, _)| k == key)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Index keyed pattern entries instead of repeatedly scanning them

For a valid keyed override with n explicit entries, lowering first calls keys.contains for every item and then scans the full item list again for every target key, making specialization quadratic in the array size. Generated parameter tables with thousands of keyed entries can consequently spend tens or hundreds of millions of comparisons here, whereas the previous slot-based lowering was linear; build a key-to-value map or indexed slot vector once.

Useful? React with 👍 / 👎.

Comment on lines +22 to +25
|| identifier_locate(RefNode::ParameterIdentifier(&param.nodes.0)).is_some_and(|loc| {
scope::imported()
.pattern_parameter_bindings
.contains_key(&loc.offset)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep enclosing pattern expressions as constant parameters

When an override merely contains a typed pattern inside a larger scalar expression, such as .P(int'{default: 1} + 1), from_param stores it as Items::Value, but this predicate classifies every bound pattern as an array parameter. parameters_from_declaration consequently omits P from the parameter/constant environment and array_parameters turns it into a signal, so dependent parameter defaults, port ranges, and generate conditions that reference P become unresolved even though the old rewritten scalar initializer remained a compile-time constant. Distinguish fully bound scalar Items::Value overrides from shape-dependent patterns and apply them through the normal value-override path.

Useful? React with 👍 / 👎.

@mergify mergify Bot added the queued Mergify queue entry label Oct 18, 2026
@mergify

mergify Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 39 minutes 27 seconds in the queue, including 24 minutes 34 seconds running CI.

Required conditions to merge
  • check-success = Conventional Commit title
  • check-success = Queue validation
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Lint & Format
    • check-neutral = @github-actions/Lint & Format
    • check-skipped = @github-actions/Lint & Format
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-neutral = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-skipped = @github-actions/NAPI Build (Linux ARM64 GNU)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Windows)
    • check-neutral = @github-actions/NAPI Build (Windows)
    • check-skipped = @github-actions/NAPI Build (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Rust Test & NAPI Build
    • check-neutral = @github-actions/Rust Test & NAPI Build
    • check-skipped = @github-actions/Rust Test & NAPI Build
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Ubuntu)
    • check-neutral = @github-actions/JS Test (Ubuntu)
    • check-skipped = @github-actions/JS Test (Ubuntu)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Windows)
    • check-neutral = @github-actions/JS Test (Windows)
    • check-skipped = @github-actions/JS Test (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Conventional Commit title
    • check-neutral = @github-actions/Conventional Commit title
    • check-skipped = @github-actions/Conventional Commit title

@mergify
mergify Bot merged commit 57c687b into master Oct 18, 2026
29 checks passed
@mergify
mergify Bot deleted the stack/tignear/refactor/sv-native-bindings/bind-assignment-patterns-without-rewriting-source--6d1a9211 branch October 18, 2026 03:30
@mergify mergify Bot removed the queued Mergify queue entry label Oct 18, 2026
tignear added a commit that referenced this pull request Oct 18, 2026
Interface-dependent caller declarations were analyzed before their bindings
existed, while unrelated declarations could be delayed merely because an
identifier matched a later interface instance. For example, pkg::later must
remain available to I #(W) first() even when I later() follows it.

Collect independent caller declarations and restore dependent ones as local
interfaces become bound. Use the existing scope-aware reference collector so
package-qualified names, structure members and nested lexical bindings do not
create false dependencies. Propagate dependencies through ANSI ports and their
inherited types, and resolve caller type queries before entering an interface.

Preserve lexical roots in packed-structure dimension queries; reject collisions
between module declarations (including enum literals) and imported interface
symbols without rejecting subroutine-local shadowing. Select requested interface
contracts before analyzing unsupported prototypes. All work uses original CSTs.

Covers the four review findings on #1468 and six on #1474, including
#1474 (comment).
Shared cases exercise dependent declarations/ports, dimensions, and independent
package/member/local bindings on all five Celox backends. API regressions cover
collisions and selective collection. Retain narrow evidence for existing Icarus
hierarchical-constant and structure-dimension limitations; the latest binding
regression passes both Verilator and Icarus without exclusions.

Sync the remaining stack onto master after #1467 merged. Preserve both generate
import resolution and interface scopes in the overlapping analyzer paths, and
keep master's time-scale API alongside the interface-plan API. Validate #1468
independently before validating this top member.

Validation after syncing: analyzer/frontend units (371 passed, 4 existing
ignores), full SV suite (2827 passed, 110 existing ignores), DPI (68), lifetime /
unit-scope / arrays (33), mixed frontend (7), retained reports (3), formatting
and affected-crate clippy with -D warnings. The lower member independently
passes its units, full SV suite (2797), related integrations, retained reports
and clippy. The new shared case also passes Verilator and Icarus.

Change-Id: I6ad012f664d5e6f9dadc0ed7001dccf5247eae8b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-ready Request merging through Mergify after required checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant