Skip to content

Report underlying type changes of user-defined value types - #1317

Draft
ericglau wants to merge 3 commits into
OpenZeppelin:masterfrom
ericglau:udvt-underlying-type
Draft

ericglau wants to merge 3 commits into
OpenZeppelin:masterfrom
ericglau:udvt-underlying-type

Conversation

@ericglau

@ericglau ericglau commented Nov 6, 2026

Copy link
Copy Markdown
Member

Fixes #1316

Reports an error when the underlying type of a user-defined value type changes, including when its size stays the same, such as from uint128 to int128. Stored values can read differently with the new type, and a type change of a plain variable is already reported.

If the change is intended and safe for the stored values, it can be allowed by annotating the variable or struct member with its previous type, with the previous underlying type in place of the user-defined value type:

  • @custom:oz-retyped-from uint128 on Amount a
  • @custom:oz-retyped-from mapping(address => uint128) on mapping(address => Amount) m

The error message suggests the exact annotation. An annotation that names the user-defined value type itself, which is the same in both versions, does not allow the change.

🤖 Generated with Claude Code

ericglau and others added 3 commits November 6, 2026 17:20
Fixes OpenZeppelin#1316

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 6, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
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.

Storage check allows changing a user-defined value type's underlying type when the size is unchanged

1 participant