Sitelet https://github.com/starkware-libs/cairo/pull/10118
Skip to content

bugfix(corelib): Disable ability to dict-new on illegal types. - #10118

Merged
orizi merged 1 commit into
mainfrom
orizi/06-17-bugfix_corelib_disable_ability_to_dict-new_on_illegal_types
Jun 17, 2026
Merged

orizi merged 1 commit into
mainfrom
orizi/06-17-bugfix_corelib_disable_ability_to_dict-new_on_illegal_types

Conversation

@orizi

@orizi orizi commented Jun 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds the Felt252DictValue<T> trait bound to the Felt252DictDefault implementation, ensuring that Default<Felt252Dict<T>> is only implemented for types that are valid dictionary value types.


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

Why is this change needed?

The Felt252DictDefault implementation was missing the Felt252DictValue<T> constraint, meaning Default<Felt252Dict<T>> could theoretically be invoked for types that are not valid dictionary value types. This constraint is required for correctness, as Felt252Dict<T> is only meaningful when T implements Felt252DictValue.


What was the behavior or documentation before?

Felt252DictDefault<T> implemented Default<Felt252Dict<T>> for any T, without requiring T to implement Felt252DictValue.


What is the behavior or documentation after?

Felt252DictDefault<T> now requires T: Felt252DictValue<T>, aligning the Default implementation with the actual constraints needed to construct and use a Felt252Dict<T>.


Related issue or discussion (if any)

#10098


Additional context

This is a minimal, targeted constraint fix with no behavioral change for valid usage, but it closes a gap where the trait bound was inconsistently applied compared to the rest of the Felt252Dict API.

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

orizi commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@orizi
orizi marked this pull request as ready for review June 17, 2026 07:36
@cursor

cursor Bot commented Jun 17, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Single trait-bound change in corelib with no runtime behavior change for already-valid dictionary types.

Overview
Adds Felt252DictValue<T> to the Default<Felt252Dict<T>> impl on Felt252DictDefault, matching Felt252DictImpl, Felt252DictEntryImpl, Destruct, and FromIterator.

Default::default() for Felt252Dict<T> is no longer available for types that cannot be dictionary values (those without Felt252DictValue). Valid usage such as Felt252Dict<u8> is unchanged at runtime; this only tightens type-checking at compile time.

Reviewed by Cursor Bugbot for commit 6867fc5. Bugbot is set up for automated code reviews on this repo. Configure here.

@orizi orizi linked an issue Jun 17, 2026 that may be closed by this pull request

@TomerStarkware TomerStarkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

:lgtm:

@TomerStarkware reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).

@orizi
orizi added this pull request to the merge queue Jun 17, 2026
Merged via the queue into main with commit dc0d81a Jun 17, 2026
55 checks passed
@orizi
orizi deleted the orizi/06-17-bugfix_corelib_disable_ability_to_dict-new_on_illegal_types branch June 17, 2026 15:13
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.

bug: Unbounded dict Default triggers sierra-gen ICE

3 participants