Skip to content

Conversation

@xunilrj
Copy link
Contributor

@xunilrj xunilrj commented Nov 13, 2025

Description

This PR is continuation of #7483.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

Note

Blocks types with const generics in configurables and ABI method args/returns via new TypeId::has_const_generics, and adds tests to enforce errors.

  • Type system:
    • Add TypeId::has_const_generics(engines) to detect const generics in nested types (sway-core/src/type_system/id.rs).
  • Compiler/semantics:
    • Enforce no const generics in configurables via TyConfigurableDecl::forbid_const_generics() and invoke during type check (semantic_analysis/.../configurable.rs, .../declaration.rs).
    • Enforce no const generics in ABI method parameters/returns using TypeId::has_const_generics and remove ad-hoc checker (language/ty/declaration/abi.rs).
  • Tests:
    • Extend should_fail/unsupported_const_generics to cover configurables and ABI cases; update snapshot (test/.../stdout.snap).

Written by Cursor Bugbot for commit eb61590. This will update automatically on new commits. Configure here.

@xunilrj xunilrj self-assigned this Nov 13, 2025
@xunilrj xunilrj requested a review from a team as a code owner November 13, 2025 13:36
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 13, 2025

CodSpeed Performance Report

Merging #7494 will not alter performance

Comparing xunilrj/forbid-const-generics-configurables (eb61590) with master (d7d5099)

Summary

✅ 25 untouched

@xunilrj xunilrj requested a review from a team December 2, 2025 18:28
@cursor
Copy link

cursor bot commented Dec 10, 2025

PR Summary

Forbids const-generic types in configurable declarations, adds TypeId::has_const_generics, and updates ABI checks and failing tests accordingly.

  • Type system / Semantics:
    • Add TypeId::has_const_generics(engines) in sway-core/src/type_system/id.rs to detect const generics across nested types.
    • Replace ad-hoc checks in TyAbiDecl::forbid_const_generics() with type_id.has_const_generics(engines) in sway-core/src/language/ty/declaration/abi.rs.
    • Add TyConfigurableDecl::forbid_const_generics() in sway-core/src/semantic_analysis/ast_node/declaration/configurable.rs and invoke it during ConfigurableDeclaration type-checking in sway-core/src/semantic_analysis/ast_node/declaration/declaration.rs to reject configurables with const generics.
  • Tests:
    • Extend test/src/e2e_vm_tests/test_programs/should_fail/unsupported_const_generics/src/main.sw to include a configurable using const generics.
    • Update stdout.snap to reflect the new error and shifted line numbers.

Written by Cursor Bugbot for commit 62d6288. This will update automatically on new commits. Configure here.

@ironcev ironcev enabled auto-merge (squash) December 10, 2025 14:21
@ironcev ironcev merged commit dc81a40 into master Dec 10, 2025
46 of 47 checks passed
@ironcev ironcev deleted the xunilrj/forbid-const-generics-configurables branch December 10, 2025 14:58
@xunilrj xunilrj mentioned this pull request Dec 10, 2025
8 tasks
xunilrj added a commit that referenced this pull request Dec 11, 2025
## Description

Continuation of #7494.

## Checklist

- [x] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
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.

5 participants