Skip to content

--allow-toplevel-iface-ports: Apply $static_assert iface param overrides - #1910

Merged
MikePopoloski merged 1 commit into
MikePopoloski:masterfrom
AndrewNolte:AndrewNolte/stack/24
Aug 6, 2026
Merged

--allow-toplevel-iface-ports: Apply $static_assert iface param overrides#1910
MikePopoloski merged 1 commit into
MikePopoloski:masterfrom
AndrewNolte:AndrewNolte/stack/24

Conversation

@AndrewNolte

@AndrewNolte AndrewNolte commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Stacked PRs:


View individual changes

--allow-toplevel-iface-ports: Apply $static_assert iface param overrides

This allows users to pin iface port params, allowing for better LSP features outside of a design context.
The body will be inspected for $static_asserts, and will use those to fill in the expected parameter values for iface ports.
Related issue: hudson-trading/slang-server#401

AndrewNolte added a commit to AndrewNolte/slang that referenced this pull request Jul 27, 2026
This allows users to pin iface port params, allowing for better LSP features outside of a design context.
The body will be inspected for $static_asserts, and will use those to fill in the expected parameter values for iface ports.

stack-info: PR: MikePopoloski#1910, branch: AndrewNolte/stack/24
@AndrewNolte
AndrewNolte force-pushed the AndrewNolte/stack/24 branch from 9929b41 to 9d1724b Compare July 27, 2026 15:08
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.28169% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.01%. Comparing base (99197ea) to head (6c9bf23).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
source/ast/symbols/InstanceSymbols.cpp 80.00% 28 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1910      +/-   ##
==========================================
- Coverage   96.05%   96.01%   -0.04%     
==========================================
  Files         247      247              
  Lines       56717    56855     +138     
==========================================
+ Hits        54482    54592     +110     
- Misses       2235     2263      +28     
Files with missing lines Coverage Δ
source/ast/symbols/ParameterBuilder.h 100.00% <100.00%> (ø)
source/ast/symbols/InstanceSymbols.cpp 94.91% <80.00%> (-2.02%) ⬇️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 99197ea...6c9bf23. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AndrewNolte
AndrewNolte marked this pull request as draft July 29, 2026 14:00
AndrewNolte added a commit to AndrewNolte/slang that referenced this pull request Jul 29, 2026
This allows users to pin iface port params, allowing for better LSP features outside of a design context.
The body will be inspected for $static_asserts, and will use those to fill in the expected parameter values for iface ports.
Related issue: hudson-trading/slang-server#401

stack-info: PR: MikePopoloski#1910, branch: AndrewNolte/stack/24
@AndrewNolte
AndrewNolte force-pushed the AndrewNolte/stack/24 branch from 9d1724b to b4d7a64 Compare July 29, 2026 14:00
@AndrewNolte
AndrewNolte marked this pull request as ready for review July 29, 2026 14:00
@AndrewNolte
AndrewNolte marked this pull request as draft July 29, 2026 20:22
@AndrewNolte
AndrewNolte force-pushed the AndrewNolte/stack/24 branch from 26fd3fe to d6ada10 Compare July 29, 2026 20:22
AndrewNolte added a commit to AndrewNolte/slang that referenced this pull request Jul 29, 2026
This allows users to pin iface port params, allowing for better LSP features outside of a design context.
The body will be inspected for $static_asserts, and will use those to fill in the expected parameter values for iface ports.
Related issue: hudson-trading/slang-server#401

stack-info: PR: MikePopoloski#1910, branch: AndrewNolte/stack/24
@AndrewNolte
AndrewNolte marked this pull request as ready for review July 29, 2026 20:22
Comment thread source/ast/symbols/ParameterBuilder.h Outdated
/// Useful for propagating an already-elaborated value (e.g. copied from another instance, or
/// derived from a constraint) onto the parameter of a freshly built instance.
void addValueOverride(std::string_view name, ConstantValue value) {
resolvedOverrides.emplace(name, std::move(value));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

These are stored as a variant and the caller already has a variant, so you may as well have one method that takes a variant and not force the caller to unwrap it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had added these as values/types for a focused-instance selection feature, but I'll switch to one method here. I think we should be able to do that feature with cloning/recreating syntax nodes.

Comment thread source/ast/symbols/ParameterBuilder.cpp Outdated
// A pre-resolved type override takes precedence and is applied directly, since it has
// already been resolved and doesn't depend on any instance context. Localparams can't be
// overridden, so fall through to normal resolution for those.
if (auto it = resolvedOverrides.find(decl.name);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I don't love adding another map lookup for every param we create, when this will almost never be used. Can this extra value be stored alongside other stuff in the assignments map so we get it as part of the main lookup?

Comment thread source/ast/symbols/InstanceSymbols.cpp Outdated
SmallVector<IfaceParamConstraint> constraints;
SmallVector<IfaceParamOverride> paramOverrides;
if (bodySyntax) {
collectIfaceParamConstraints(ifacePort, *bodySyntax, constraints);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

These two methods are only ever called back to back, so you can just make them one method instead, and avoid exposing the intermediary IfaceParamConstraint type.

Comment thread source/ast/symbols/InstanceSymbols.cpp Outdated
SmallVectorBase<IfaceParamConstraint>& constraints) {
auto& def = *port.interfaceDef;

for (auto member : topBody.members) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

For every iface port we loop over every body member. Probably this should be one loop to find all static asserts and then reusing them for each iface port.

This allows users to pin iface port params, allowing for better LSP features outside of a design context.
The body will be inspected for $static_asserts, and will use those to fill in the expected parameter values for iface ports.
Related issue: hudson-trading/slang-server#401

stack-info: PR: MikePopoloski#1910, branch: AndrewNolte/stack/24
@AndrewNolte
AndrewNolte marked this pull request as draft August 6, 2026 04:13
@AndrewNolte
AndrewNolte force-pushed the AndrewNolte/stack/24 branch from 41c582c to 6c9bf23 Compare August 6, 2026 04:13
@AndrewNolte
AndrewNolte marked this pull request as ready for review August 6, 2026 04:13
@AndrewNolte
AndrewNolte marked this pull request as draft August 6, 2026 13:57
@AndrewNolte
AndrewNolte marked this pull request as ready for review August 6, 2026 13:57
@MikePopoloski
MikePopoloski merged commit a3d50cf into MikePopoloski:master Aug 6, 2026
19 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.

2 participants