Skip to content

Add unsafe_type_cast dylint detector#41

Merged
maxkup19 merged 2 commits into
mainfrom
dylint/unsafe-type-cast
Mar 15, 2026
Merged

Add unsafe_type_cast dylint detector#41
maxkup19 merged 2 commits into
mainfrom
dylint/unsafe-type-cast

Conversation

@maxkup19

Copy link
Copy Markdown
Contributor

Summary

  • Adds a new unsafe_type_cast dylint detector that flags potentially unsafe integer type casts in Solana programs
  • Detects narrowing casts (e.g., u64 → u32) that silently truncate values and signed-to-unsigned casts (e.g., i64 → u64) that can produce unexpected results
  • Skips macro expansions, small literal casts, and safe widening casts to minimize false positives

Detects narrowing integer casts (e.g., u64 → u32) and signed-to-unsigned
casts that could silently truncate values or produce unexpected results
in Solana programs. Suggests try_into() as the safe alternative.
@maxkup19
maxkup19 merged commit 87bc85c into main Mar 15, 2026
2 checks passed
@maxkup19
maxkup19 deleted the dylint/unsafe-type-cast branch March 15, 2026 22:25
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.

1 participant