From e8aafe0b8c78c6c76f6174c176b0a7b4224934eb Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Sat, 19 Jul 2025 10:34:42 +0000 Subject: [PATCH 01/20] bet --- Cargo.lock | 1 + Cargo.toml | 2 +- crates/lint/Cargo.toml | 1 + crates/lint/src/sol/med/mod.rs | 8 +- crates/lint/src/sol/med/unsafe_typecast.rs | 187 +++++++++++++++++++++ crates/lint/testdata/UnsafeTypecast.sol | 106 ++++++++++++ crates/lint/testdata/UnsafeTypecast.stderr | 176 +++++++++++++++++++ 7 files changed, 479 insertions(+), 2 deletions(-) create mode 100644 crates/lint/src/sol/med/unsafe_typecast.rs create mode 100644 crates/lint/testdata/UnsafeTypecast.sol create mode 100644 crates/lint/testdata/UnsafeTypecast.stderr diff --git a/Cargo.lock b/Cargo.lock index 221be209fc728..5aa60823aa170 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3925,6 +3925,7 @@ dependencies = [ "foundry-compilers", "foundry-config", "heck", + "num-bigint", "rayon", "solar-ast", "solar-data-structures", diff --git a/Cargo.toml b/Cargo.toml index 848376fcd052a..29b71890f1d39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -353,7 +353,7 @@ jiff = "0.2" heck = "0.5" uuid = "1.17.0" flate2 = "1.1" - +num-bigint = "0.4" ## Pinned dependencies. Enabled for the workspace in crates/test-utils. # Use unicode-rs which has a smaller binary size than the default ICU4X as the IDNA backend, used diff --git a/crates/lint/Cargo.toml b/crates/lint/Cargo.toml index c48dcfb85e0ed..7eb666436bf7f 100644 --- a/crates/lint/Cargo.toml +++ b/crates/lint/Cargo.toml @@ -28,3 +28,4 @@ solar-sema.workspace = true heck.workspace = true rayon.workspace = true thiserror.workspace = true +num-bigint.workspace = true diff --git a/crates/lint/src/sol/med/mod.rs b/crates/lint/src/sol/med/mod.rs index 35e55f594fa8f..5034e849ce601 100644 --- a/crates/lint/src/sol/med/mod.rs +++ b/crates/lint/src/sol/med/mod.rs @@ -3,4 +3,10 @@ use crate::sol::{EarlyLintPass, LateLintPass, SolLint}; mod div_mul; use div_mul::DIVIDE_BEFORE_MULTIPLY; -register_lints!((DivideBeforeMultiply, early, (DIVIDE_BEFORE_MULTIPLY))); +mod unsafe_typecast; +use unsafe_typecast::UNSAFE_TYPECAST; + +register_lints!( + (DivideBeforeMultiply, early, (DIVIDE_BEFORE_MULTIPLY)), + (UnsafeTypecast, late, (UNSAFE_TYPECAST)) +); diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs new file mode 100644 index 0000000000000..9f194931c6ae5 --- /dev/null +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -0,0 +1,187 @@ +use super::UnsafeTypecast; +use crate::{ + linter::{LateLintPass, LintContext}, + sol::{Severity, SolLint}, +}; +use solar_sema::hir::{self, ExprKind, TypeKind}; + +declare_forge_lint!( + UNSAFE_TYPECAST, + Severity::Med, + "unsafe-typecast", + "typecasts that can truncate values should be avoided" +); + +impl<'hir> LateLintPass<'hir> for UnsafeTypecast { + fn check_expr( + &mut self, + ctx: &LintContext<'_>, + hir: &'hir hir::Hir<'hir>, + expr: &'hir hir::Expr<'hir>, + ) { + // Check for type cast expressions: Type(value) + if let ExprKind::Call(call_expr, args, _) = &expr.kind { + // Check if this is a type cast (function call where the function is a type) + if let ExprKind::Type(target_type) = &call_expr.kind { + // We need exactly one argument for a type cast + if args.len() == 1 { + if let Some(first_arg) = args.exprs().next() { + if is_unsafe_typecast_hir(hir, first_arg, target_type) { + ctx.emit(&UNSAFE_TYPECAST, expr.span); + } + } + } + } + } + } +} + +/// Checks if a typecast from the source expression to target type is unsafe. +fn is_unsafe_typecast_hir( + hir: &hir::Hir<'_>, + source_expr: &hir::Expr<'_>, + target_type: &hir::Type<'_>, +) -> bool { + // Get target elementary type + let target_elem_type = match &target_type.kind { + TypeKind::Elementary(elem_type) => elem_type, + _ => return false, + }; + + // Determine source type from the expression + let source_elem_type = match infer_source_type(hir, source_expr) { + Some(elem_type) => elem_type, + None => return false, + }; + + is_unsafe_elementary_typecast(&source_elem_type, target_elem_type) +} + +/// Infers the elementary type of a source expression. +/// For cast chains, returns the ultimate source type, not intermediate cast results. +fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option { + match &expr.kind { + // Type cast: Type(value) - recursively check the inner value + ExprKind::Call(call_expr, args, _) => { + if let ExprKind::Type(ty) = &call_expr.kind { + if args.len() == 1 { + if let TypeKind::Elementary(_elem_type) = &ty.kind { + // For type casts, recursively check the source of the inner expression + // This allows us to see through cast chains like uint160(address_var) + if let Some(first_arg) = args.exprs().next() { + return infer_source_type(hir, first_arg); + } + } + } + } + // For other function calls, try to infer from context or return None + None + } + + // ... rest of the function remains the same + ExprKind::Lit(lit) => { + match &lit.kind { + solar_ast::LitKind::Number(num) => { + if is_negative_number_literal(num) { + Some(hir::ElementaryType::Int(solar_ast::TypeSize::ZERO)) + } else { + Some(hir::ElementaryType::UInt(solar_ast::TypeSize::ZERO)) + } + } + solar_ast::LitKind::Address(_) => Some(hir::ElementaryType::Address(false)), + solar_ast::LitKind::Str(..) => Some(hir::ElementaryType::String), + solar_ast::LitKind::Bool(_) => Some(hir::ElementaryType::Bool), + _ => None, + } + } + + ExprKind::Ident(resolutions) => { + if let Some(first_res) = resolutions.first() { + match first_res { + hir::Res::Item(hir::ItemId::Variable(var_id)) => { + let variable = hir.variable(*var_id); + if let TypeKind::Elementary(elem_type) = &variable.ty.kind { + return Some(*elem_type); + } + } + _ => {} + } + } + None + } + + ExprKind::Unary(op, inner_expr) => { + match op.kind { + solar_ast::UnOpKind::Neg => { + match infer_source_type(hir, inner_expr) { + Some(hir::ElementaryType::UInt(size)) => { + Some(hir::ElementaryType::Int(size)) + } + Some(signed_type @ hir::ElementaryType::Int(_)) => { + Some(signed_type) + } + _ => { + Some(hir::ElementaryType::Int(solar_ast::TypeSize::ZERO)) + } + } + } + _ => { + infer_source_type(hir, inner_expr) + } + } + } + + _ => None, + } +} + +/// Helper function to detect negative number literals +fn is_negative_number_literal(num: &num_bigint::BigInt) -> bool { + num.sign().eq(&num_bigint::Sign::Minus) +} + +/// Checks if a type cast from source_type to target_type is unsafe. +fn is_unsafe_elementary_typecast( + source_type: &hir::ElementaryType, + target_type: &hir::ElementaryType, +) -> bool { + use hir::ElementaryType; + use solar_ast::TypeSize; + + match (source_type, target_type) { + // Numeric downcasts (smaller target size) + (ElementaryType::UInt(source_size), ElementaryType::UInt(target_size)) => { + source_size.bits() > target_size.bits() + } + (ElementaryType::Int(source_size), ElementaryType::Int(target_size)) => { + source_size.bits() > target_size.bits() + } + + // Signed to unsigned conversion (potential loss of sign) + (ElementaryType::Int(_), ElementaryType::UInt(_)) => true, + + // Unsigned to signed conversion with same or smaller size + (ElementaryType::UInt(source_size), ElementaryType::Int(target_size)) => { + source_size.bits() >= target_size.bits() + } + + // Fixed bytes to smaller fixed bytes + (ElementaryType::FixedBytes(source_size), ElementaryType::FixedBytes(target_size)) => { + source_size.bytes() > target_size.bytes() + } + + // Dynamic bytes to fixed bytes (potential truncation) + (ElementaryType::Bytes, ElementaryType::FixedBytes(_)) => true, + + // String to fixed bytes (potential truncation) + (ElementaryType::String, ElementaryType::FixedBytes(_)) => true, + + // Address to smaller uint (truncation) - address is 160 bits + (ElementaryType::Address(_), ElementaryType::UInt(target_size)) => target_size.bits() < 160, + + // Address to int (sign issues) + (ElementaryType::Address(_), ElementaryType::Int(_)) => true, + + _ => false, + } +} \ No newline at end of file diff --git a/crates/lint/testdata/UnsafeTypecast.sol b/crates/lint/testdata/UnsafeTypecast.sol new file mode 100644 index 0000000000000..4083e93a06ad3 --- /dev/null +++ b/crates/lint/testdata/UnsafeTypecast.sol @@ -0,0 +1,106 @@ +contract UnsafeTypecast { + function numericDowncasts() public { + // Unsafe: uint256 -> uint128 + uint256 a = 1000; + uint128 b = uint128(a); //~WARN: typecasts that can truncate values should be avoided + + // Unsafe: uint256 -> uint64 + uint64 c = uint64(a); //~WARN: typecasts that can truncate values should be avoided + + // Unsafe: uint256 -> uint8 + uint8 d = uint8(a); //~WARN: typecasts that can truncate values should be avoided + + // Unsafe: int256 -> int128 + int256 e = -1000; + int128 f = int128(e); //~WARN: typecasts that can truncate values should be avoided + + // Unsafe: int256 -> int8 + int8 g = int8(e); //~WARN: typecasts that can truncate values should be avoided + + // Safe: uint128 -> uint256 (upcast) + uint256 h = uint256(b); + + // Safe: int128 -> int256 (upcast) + int256 i = int256(f); + + // Safe: same size + uint256 j = uint256(a); + } + + function signedUnsignedConversions() public { + // Unsafe: int256 -> uint256 (potential loss of sign) + int256 a = -1000; + uint256 b = uint256(a); //~WARN: typecasts that can truncate values should be avoided + + // Unsafe: int128 -> uint256 (potential loss of sign) + int128 c = -100; + uint256 d = uint256(c); //~WARN: typecasts that can truncate values should be avoided + + // Unsafe: uint256 -> int256 (potential overflow) + uint256 e = 1000; + int256 f = int256(e); //~WARN: typecasts that can truncate values should be avoided + + // Unsafe: uint256 -> int128 (potential overflow and truncation) + int128 g = int128(e); //~WARN: typecasts that can truncate values should be avoided + + // Unsafe: uint128 -> int128 (potential overflow) + uint128 h = 100; + int128 i = int128(h); //~WARN: typecasts that can truncate values should be avoided + } + + function bytesConversions() public { + // Unsafe: bytes32 -> bytes16 (truncation) + bytes32 a = "hello world"; + bytes16 b = bytes16(a); //~WARN: typecasts that can truncate values should be avoided + + // Unsafe: bytes32 -> bytes8 (truncation) + bytes8 c = bytes8(a); //~WARN: typecasts that can truncate values should be avoided + + // Unsafe: bytes -> bytes32 (potential truncation) + bytes memory d = "hello world"; + bytes32 e = bytes32(d); //~WARN: typecasts that can truncate values should be avoided + + // Unsafe: string -> bytes32 (potential truncation) + string memory f = "hello world"; + bytes32 g = bytes32(bytes(f)); //~WARN: typecasts that can truncate values should be avoided + + // Safe: bytes16 -> bytes32 (upcast) + bytes32 h = bytes32(b); + + // Safe: same size + bytes32 i = bytes32(a); + } + + function addressConversions() public { + // Unsafe: address -> uint128 (truncation) + address a = 0x1234567890123456789012345678901234567890; + uint128 b = uint128(uint160(a)); //~WARN: typecasts that can truncate values should be avoided + + // Unsafe: address -> int256 (sign issues) + int256 c = int256(uint160(a)); //~WARN: typecasts that can truncate values should be avoided + + // Unsafe: address -> uint8 (severe truncation) + uint8 d = uint8(uint160(a)); //~WARN: typecasts that can truncate values should be avoided + + // Safe: address -> uint160 (exact fit) + uint160 e = uint160(a); + + // Safe: address -> uint256 (upcast) + uint256 f = uint256(uint160(a)); + } + + function literalCasts() public { + // Unsafe: literal downcasts + uint128 a = uint128(1000000000000000000000000000000000000000); //~WARN: typecasts that can truncate values should be avoided + uint64 b = uint64(1000000000000000000000); //~WARN: typecasts that can truncate values should be avoided + int128 c = int128(-1000000000000000000000000000000000000000); //~WARN: typecasts that can truncate values should be avoided + + // Unsafe: signed/unsigned conversions + uint256 d = uint256(-1000); //~WARN: typecasts that can truncate values should be avoided + int256 e = int256(1000000000000000000000000000000000000000); //~WARN: typecasts that can truncate values should be avoided + + // Safe: literal upcasts + uint256 f = uint256(1000); + int256 g = int256(-1000); + } +} \ No newline at end of file diff --git a/crates/lint/testdata/UnsafeTypecast.stderr b/crates/lint/testdata/UnsafeTypecast.stderr new file mode 100644 index 0000000000000..12af59d9ad70d --- /dev/null +++ b/crates/lint/testdata/UnsafeTypecast.stderr @@ -0,0 +1,176 @@ +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +5 | uint128 b = uint128(a); + | ---------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +8 | uint64 c = uint64(a); + | --------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +11 | uint8 d = uint8(a); + | -------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +15 | int128 f = int128(e); + | --------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +18 | int8 g = int8(e); + | ------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +33 | uint256 b = uint256(a); + | ---------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +37 | uint256 d = uint256(c); + | ---------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +41 | int256 f = int256(e); + | --------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +44 | int128 g = int128(e); + | --------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +48 | int128 i = int128(h); + | --------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +54 | bytes16 b = bytes16(a); + | ---------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +57 | bytes8 c = bytes8(a); + | --------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +61 | bytes32 e = bytes32(d); + | ---------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +65 | bytes32 g = bytes32(bytes(f)); + | ----------------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +77 | uint128 b = uint128(uint160(a)); + | ------------------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +80 | int256 c = int256(uint160(a)); + | ------------------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +83 | uint8 d = uint8(uint160(a)); + | ----------------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +94 | uint128 a = uint128(1000000000000000000000000000000000000000); + | ------------------------------------------------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +95 | uint64 b = uint64(1000000000000000000000); + | ------------------------------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +96 | int128 c = int128(-1000000000000000000000000000000000000000); + | ------------------------------------------------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +99 | uint256 d = uint256(-1000); + | -------------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +100 | int256 e = int256(1000000000000000000000000000000000000000); + | ------------------------------------------------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + From befa78a30a9a28495f323a6bc3be49d669c38840 Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Wed, 23 Jul 2025 06:57:43 +0000 Subject: [PATCH 02/20] add more tests, emit fix --- crates/lint/src/sol/med/unsafe_typecast.rs | 67 +- crates/lint/testdata/UnsafeTypecast.sol | 136 +++ crates/lint/testdata/UnsafeTypecast.stderr | 1094 +++++++++++++++++++- 3 files changed, 1214 insertions(+), 83 deletions(-) diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs index 9f194931c6ae5..9ee5382afad87 100644 --- a/crates/lint/src/sol/med/unsafe_typecast.rs +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -1,6 +1,6 @@ use super::UnsafeTypecast; use crate::{ - linter::{LateLintPass, LintContext}, + linter::{LateLintPass, LintContext, Snippet}, sol::{Severity, SolLint}, }; use solar_sema::hir::{self, ExprKind, TypeKind}; @@ -27,7 +27,8 @@ impl<'hir> LateLintPass<'hir> for UnsafeTypecast { if args.len() == 1 { if let Some(first_arg) = args.exprs().next() { if is_unsafe_typecast_hir(hir, first_arg, target_type) { - ctx.emit(&UNSAFE_TYPECAST, expr.span); + let suggestion = get_suggestion(); + ctx.emit_with_fix(&UNSAFE_TYPECAST, expr.span, suggestion); } } } @@ -36,6 +37,14 @@ impl<'hir> LateLintPass<'hir> for UnsafeTypecast { } } +// Returns the suggested fix based on the unsafe typecast expression +fn get_suggestion() -> Snippet { + Snippet::Block { + desc: Some("Consider disabling this lint only if you're certain the cast is safe:"), + code: "// Ensure the value fits in the target type before casting\n// forge-lint: disable-next-line(unsafe-typecast)\n// Cast is safe because [explain why]".to_string(), + } +} + /// Checks if a typecast from the source expression to target type is unsafe. fn is_unsafe_typecast_hir( hir: &hir::Hir<'_>, @@ -79,21 +88,19 @@ fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option { - match &lit.kind { - solar_ast::LitKind::Number(num) => { - if is_negative_number_literal(num) { - Some(hir::ElementaryType::Int(solar_ast::TypeSize::ZERO)) - } else { - Some(hir::ElementaryType::UInt(solar_ast::TypeSize::ZERO)) - } + ExprKind::Lit(lit) => match &lit.kind { + solar_ast::LitKind::Number(num) => { + if is_negative_number_literal(num) { + Some(hir::ElementaryType::Int(solar_ast::TypeSize::ZERO)) + } else { + Some(hir::ElementaryType::UInt(solar_ast::TypeSize::ZERO)) } - solar_ast::LitKind::Address(_) => Some(hir::ElementaryType::Address(false)), - solar_ast::LitKind::Str(..) => Some(hir::ElementaryType::String), - solar_ast::LitKind::Bool(_) => Some(hir::ElementaryType::Bool), - _ => None, } - } + solar_ast::LitKind::Address(_) => Some(hir::ElementaryType::Address(false)), + solar_ast::LitKind::Str(..) => Some(hir::ElementaryType::String), + solar_ast::LitKind::Bool(_) => Some(hir::ElementaryType::Bool), + _ => None, + }, ExprKind::Ident(resolutions) => { if let Some(first_res) = resolutions.first() { @@ -110,26 +117,14 @@ fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option { - match op.kind { - solar_ast::UnOpKind::Neg => { - match infer_source_type(hir, inner_expr) { - Some(hir::ElementaryType::UInt(size)) => { - Some(hir::ElementaryType::Int(size)) - } - Some(signed_type @ hir::ElementaryType::Int(_)) => { - Some(signed_type) - } - _ => { - Some(hir::ElementaryType::Int(solar_ast::TypeSize::ZERO)) - } - } - } - _ => { - infer_source_type(hir, inner_expr) - } - } - } + ExprKind::Unary(op, inner_expr) => match op.kind { + solar_ast::UnOpKind::Neg => match infer_source_type(hir, inner_expr) { + Some(hir::ElementaryType::UInt(size)) => Some(hir::ElementaryType::Int(size)), + Some(signed_type @ hir::ElementaryType::Int(_)) => Some(signed_type), + _ => Some(hir::ElementaryType::Int(solar_ast::TypeSize::ZERO)), + }, + _ => infer_source_type(hir, inner_expr), + }, _ => None, } @@ -184,4 +179,4 @@ fn is_unsafe_elementary_typecast( _ => false, } -} \ No newline at end of file +} diff --git a/crates/lint/testdata/UnsafeTypecast.sol b/crates/lint/testdata/UnsafeTypecast.sol index 4083e93a06ad3..d870f77451236 100644 --- a/crates/lint/testdata/UnsafeTypecast.sol +++ b/crates/lint/testdata/UnsafeTypecast.sol @@ -1,4 +1,140 @@ contract UnsafeTypecast { + function upcastSafeUint() public pure { + uint8 a = type(uint8).max; + uint16 b = uint16(a); + uint24 c = uint24(b); + uint32 d = uint32(c); + uint40 e = uint40(d); + uint48 f = uint48(e); + uint56 g = uint56(f); + uint64 h = uint64(g); + uint72 i = uint72(h); + uint80 j = uint80(i); + uint88 k = uint88(j); + uint96 l = uint96(k); + uint104 m = uint104(l); + uint112 n = uint112(m); + uint120 o = uint120(n); + uint128 p = uint128(o); + uint136 q = uint136(p); + uint144 r = uint144(q); + uint152 s = uint152(r); + uint160 t = uint160(s); + uint168 u = uint168(t); + uint176 v = uint176(u); + uint184 w = uint184(v); + uint192 x = uint192(w); + uint200 y = uint200(x); + uint208 z = uint208(y); + uint216 A = uint216(z); + uint224 B = uint224(A); + uint232 C = uint232(B); + uint240 D = uint240(C); + uint248 E = uint248(D); + uint256 F = uint256(E); + } + function upcastSafeInt() public pure { + int8 a = type(int8).max; + int16 b = int16(a); + int24 c = int24(b); + int32 d = int32(c); + int40 e = int40(d); + int48 f = int48(e); + int56 g = int56(f); + int64 h = int64(g); + int72 i = int72(h); + int80 j = int80(i); + int88 k = int88(j); + int96 l = int96(k); + int104 m = int104(l); + int112 n = int112(m); + int120 o = int120(n); + int128 p = int128(o); + int136 q = int136(p); + int144 r = int144(q); + int152 s = int152(r); + int160 t = int160(s); + int168 u = int168(t); + int176 v = int176(u); + int184 w = int184(v); + int192 x = int192(w); + int200 y = int200(x); + int208 z = int208(y); + int216 A = int216(z); + int224 B = int224(A); + int232 C = int232(B); + int240 D = int240(C); + int248 E = int248(D); + int256 F = int256(E); + } + function downcastSafeUint() public pure { + uint256 a = type(uint256).max; + uint248 b = uint248(a); //~WARN: typecasts that can truncate values should be avoided + uint240 c = uint240(b); //~WARN: typecasts that can truncate values should be avoided + uint232 d = uint232(c); //~WARN: typecasts that can truncate values should be avoided + uint224 e = uint224(d); //~WARN: typecasts that can truncate values should be avoided + uint216 f = uint216(e); //~WARN: typecasts that can truncate values should be avoided + uint208 g = uint208(f); //~WARN: typecasts that can truncate values should be avoided + uint200 h = uint200(g); //~WARN: typecasts that can truncate values should be avoided + uint192 i = uint192(h); //~WARN: typecasts that can truncate values should be avoided + uint184 j = uint184(i); //~WARN: typecasts that can truncate values should be avoided + uint176 k = uint176(j); //~WARN: typecasts that can truncate values should be avoided + uint168 l = uint168(k); //~WARN: typecasts that can truncate values should be avoided + uint160 m = uint160(l); //~WARN: typecasts that can truncate values should be avoided + uint152 n = uint152(m); //~WARN: typecasts that can truncate values should be avoided + uint144 o = uint144(n); //~WARN: typecasts that can truncate values should be avoided + uint136 p = uint136(o); //~WARN: typecasts that can truncate values should be avoided + uint128 q = uint128(p); //~WARN: typecasts that can truncate values should be avoided + uint120 r = uint120(q); //~WARN: typecasts that can truncate values should be avoided + uint112 s = uint112(r); //~WARN: typecasts that can truncate values should be avoided + uint104 t = uint104(s); //~WARN: typecasts that can truncate values should be avoided + uint96 u = uint96(t); //~WARN: typecasts that can truncate values should be avoided + uint88 v = uint88(u); //~WARN: typecasts that can truncate values should be avoided + uint80 w = uint80(v); //~WARN: typecasts that can truncate values should be avoided + uint72 x = uint72(w); //~WARN: typecasts that can truncate values should be avoided + uint64 y = uint64(x); //~WARN: typecasts that can truncate values should be avoided + uint56 z = uint56(y); //~WARN: typecasts that can truncate values should be avoided + uint48 A = uint48(z); //~WARN: typecasts that can truncate values should be avoided + uint40 B = uint40(A); //~WARN: typecasts that can truncate values should be avoided + uint32 C = uint32(B); //~WARN: typecasts that can truncate values should be avoided + uint24 D = uint24(C); //~WARN: typecasts that can truncate values should be avoided + uint16 E = uint16(D); //~WARN: typecasts that can truncate values should be avoided + uint8 F = uint8(E); //~WARN: typecasts that can truncate values should be avoided + } + function downcastSafeInt() public pure { + int256 a = type(int256).max; + int248 b = int248(a); //~WARN: typecasts that can truncate values should be avoided + int240 c = int240(b); //~WARN: typecasts that can truncate values should be avoided + int232 d = int232(c); //~WARN: typecasts that can truncate values should be avoided + int224 e = int224(d); //~WARN: typecasts that can truncate values should be avoided + int216 f = int216(e); //~WARN: typecasts that can truncate values should be avoided + int208 g = int208(f); //~WARN: typecasts that can truncate values should be avoided + int200 h = int200(g); //~WARN: typecasts that can truncate values should be avoided + int192 i = int192(h); //~WARN: typecasts that can truncate values should be avoided + int184 j = int184(i); //~WARN: typecasts that can truncate values should be avoided + int176 k = int176(j); //~WARN: typecasts that can truncate values should be avoided + int168 l = int168(k); //~WARN: typecasts that can truncate values should be avoided + int160 m = int160(l); //~WARN: typecasts that can truncate values should be avoided + int152 n = int152(m); //~WARN: typecasts that can truncate values should be avoided + int144 o = int144(n); //~WARN: typecasts that can truncate values should be avoided + int136 p = int136(o); //~WARN: typecasts that can truncate values should be avoided + int128 q = int128(p); //~WARN: typecasts that can truncate values should be avoided + int120 r = int120(q); //~WARN: typecasts that can truncate values should be avoided + int112 s = int112(r); //~WARN: typecasts that can truncate values should be avoided + int104 t = int104(s); //~WARN: typecasts that can truncate values should be avoided + int96 u = int96(t); //~WARN: typecasts that can truncate values should be avoided + int88 v = int88(u); //~WARN: typecasts that can truncate values should be avoided + int80 w = int80(v); //~WARN: typecasts that can truncate values should be avoided + int72 x = int72(w); //~WARN: typecasts that can truncate values should be avoided + int64 y = int64(x); //~WARN: typecasts that can truncate values should be avoided + int56 z = int56(y); //~WARN: typecasts that can truncate values should be avoided + int48 A = int48(z); //~WARN: typecasts that can truncate values should be avoided + int40 B = int40(A); //~WARN: typecasts that can truncate values should be avoided + int32 C = int32(B); //~WARN: typecasts that can truncate values should be avoided + int24 D = int24(C); //~WARN: typecasts that can truncate values should be avoided + int16 E = int16(D); //~WARN: typecasts that can truncate values should be avoided + int8 F = int8(E); //~WARN: typecasts that can truncate values should be avoided + } function numericDowncasts() public { // Unsafe: uint256 -> uint128 uint256 a = 1000; diff --git a/crates/lint/testdata/UnsafeTypecast.stderr b/crates/lint/testdata/UnsafeTypecast.stderr index 12af59d9ad70d..a1ae6a598b1dd 100644 --- a/crates/lint/testdata/UnsafeTypecast.stderr +++ b/crates/lint/testdata/UnsafeTypecast.stderr @@ -1,176 +1,1176 @@ warning[unsafe-typecast]: typecasts that can truncate values should be avoided - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -5 | uint128 b = uint128(a); - | ---------- - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +72 | uint248 b = uint248(a); + | ---------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -8 | uint64 c = uint64(a); - | --------- - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +73 | uint240 c = uint240(b); + | ---------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -11 | uint8 d = uint8(a); - | -------- +74 | uint232 d = uint232(c); + | ---------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -15 | int128 f = int128(e); - | --------- +75 | uint224 e = uint224(d); + | ---------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -18 | int8 g = int8(e); - | ------- +76 | uint216 f = uint216(e); + | ---------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -33 | uint256 b = uint256(a); +77 | uint208 g = uint208(f); | ---------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -37 | uint256 d = uint256(c); +78 | uint200 h = uint200(g); | ---------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -41 | int256 f = int256(e); - | --------- +79 | uint192 i = uint192(h); + | ---------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -44 | int128 g = int128(e); - | --------- +80 | uint184 j = uint184(i); + | ---------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -48 | int128 i = int128(h); - | --------- +81 | uint176 k = uint176(j); + | ---------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -54 | bytes16 b = bytes16(a); +82 | uint168 l = uint168(k); | ---------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -57 | bytes8 c = bytes8(a); - | --------- +83 | uint160 m = uint160(l); + | ---------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +84 | uint152 n = uint152(m); + | ---------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +85 | uint144 o = uint144(n); + | ---------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +86 | uint136 p = uint136(o); + | ---------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -61 | bytes32 e = bytes32(d); +87 | uint128 q = uint128(p); | ---------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -65 | bytes32 g = bytes32(bytes(f)); - | ----------------- +88 | uint120 r = uint120(q); + | ---------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -77 | uint128 b = uint128(uint160(a)); - | ------------------- +89 | uint112 s = uint112(r); + | ---------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -80 | int256 c = int256(uint160(a)); - | ------------------ +90 | uint104 t = uint104(s); + | ---------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -83 | uint8 d = uint8(uint160(a)); - | ----------------- +91 | uint96 u = uint96(t); + | --------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -94 | uint128 a = uint128(1000000000000000000000000000000000000000); - | ------------------------------------------------- +92 | uint88 v = uint88(u); + | --------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -95 | uint64 b = uint64(1000000000000000000000); - | ------------------------------ +93 | uint80 w = uint80(v); + | --------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -96 | int128 c = int128(-1000000000000000000000000000000000000000); - | ------------------------------------------------- +94 | uint72 x = uint72(w); + | --------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -99 | uint256 d = uint256(-1000); - | -------------- +95 | uint64 y = uint64(x); + | --------- | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +96 | uint56 z = uint56(y); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +97 | uint48 A = uint48(z); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +98 | uint40 B = uint40(A); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +99 | uint32 C = uint32(B); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +100 | uint24 D = uint24(C); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +101 | uint16 E = uint16(D); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +102 | uint8 F = uint8(E); + | -------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +106 | int248 b = int248(a); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +107 | int240 c = int240(b); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +108 | int232 d = int232(c); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +109 | int224 e = int224(d); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +110 | int216 f = int216(e); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +111 | int208 g = int208(f); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +112 | int200 h = int200(g); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +113 | int192 i = int192(h); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +114 | int184 j = int184(i); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +115 | int176 k = int176(j); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +116 | int168 l = int168(k); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +117 | int160 m = int160(l); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +118 | int152 n = int152(m); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +119 | int144 o = int144(n); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +120 | int136 p = int136(o); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +121 | int128 q = int128(p); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +122 | int120 r = int120(q); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +123 | int112 s = int112(r); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +124 | int104 t = int104(s); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +125 | int96 u = int96(t); + | -------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +126 | int88 v = int88(u); + | -------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +127 | int80 w = int80(v); + | -------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +128 | int72 x = int72(w); + | -------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +129 | int64 y = int64(x); + | -------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +130 | int56 z = int56(y); + | -------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +131 | int48 A = int48(z); + | -------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +132 | int40 B = int40(A); + | -------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +133 | int32 C = int32(B); + | -------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +134 | int24 D = int24(C); + | -------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +135 | int16 E = int16(D); + | -------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +136 | int8 F = int8(E); + | ------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +141 | uint128 b = uint128(a); + | ---------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +144 | uint64 c = uint64(a); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +147 | uint8 d = uint8(a); + | -------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +151 | int128 f = int128(e); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +154 | int8 g = int8(e); + | ------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +169 | uint256 b = uint256(a); + | ---------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +173 | uint256 d = uint256(c); + | ---------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +177 | int256 f = int256(e); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +180 | int128 g = int128(e); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +184 | int128 i = int128(h); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +190 | bytes16 b = bytes16(a); + | ---------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +193 | bytes8 c = bytes8(a); + | --------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +197 | bytes32 e = bytes32(d); + | ---------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +201 | bytes32 g = bytes32(bytes(f)); + | ----------------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +213 | uint128 b = uint128(uint160(a)); + | ------------------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +216 | int256 c = int256(uint160(a)); + | ------------------ + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +219 | uint8 d = uint8(uint160(a)); + | ----------------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +230 | uint128 a = uint128(1000000000000000000000000000000000000000); + | ------------------------------------------------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +231 | uint64 b = uint64(1000000000000000000000); + | ------------------------------ + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +232 | int128 c = int128(-1000000000000000000000000000000000000000); + | ------------------------------------------------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be avoided + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +235 | uint256 d = uint256(-1000); + | -------------- + | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -100 | int256 e = int256(1000000000000000000000000000000000000000); +236 | int256 e = int256(1000000000000000000000000000000000000000); | ------------------------------------------------ | + = note: Consider disabling this lint only if you're certain the cast is safe: + + - // Ensure the value fits in the target type before casting + - // forge-lint: disable-next-line(unsafe-typecast) + - // Cast is safe because [explain why] + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast From 45f5bda2c8a3d395016345543ed67b23aee2a81f Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Wed, 23 Jul 2025 07:00:53 +0000 Subject: [PATCH 03/20] remove unused deps --- Cargo.lock | 1 - Cargo.toml | 1 - crates/lint/Cargo.toml | 1 - 3 files changed, 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 542a86418a140..3fe504399f294 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3924,7 +3924,6 @@ dependencies = [ "foundry-compilers", "foundry-config", "heck", - "num-bigint", "rayon", "solar-ast", "solar-data-structures", diff --git a/Cargo.toml b/Cargo.toml index 29b71890f1d39..616ae20bbc596 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -353,7 +353,6 @@ jiff = "0.2" heck = "0.5" uuid = "1.17.0" flate2 = "1.1" -num-bigint = "0.4" ## Pinned dependencies. Enabled for the workspace in crates/test-utils. # Use unicode-rs which has a smaller binary size than the default ICU4X as the IDNA backend, used diff --git a/crates/lint/Cargo.toml b/crates/lint/Cargo.toml index 7eb666436bf7f..c48dcfb85e0ed 100644 --- a/crates/lint/Cargo.toml +++ b/crates/lint/Cargo.toml @@ -28,4 +28,3 @@ solar-sema.workspace = true heck.workspace = true rayon.workspace = true thiserror.workspace = true -num-bigint.workspace = true From dff52fa6eaa57f6d19c3da70a306ae95a0926fef Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Wed, 23 Jul 2025 07:08:54 +0000 Subject: [PATCH 04/20] test: remove compiler error test --- Cargo.lock | 1 + Cargo.toml | 1 + crates/lint/Cargo.toml | 1 + crates/lint/src/sol/med/unsafe_typecast.rs | 1 - crates/lint/testdata/UnsafeTypecast.sol | 14 --- crates/lint/testdata/UnsafeTypecast.stderr | 104 ++------------------- 6 files changed, 13 insertions(+), 109 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3fe504399f294..542a86418a140 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3924,6 +3924,7 @@ dependencies = [ "foundry-compilers", "foundry-config", "heck", + "num-bigint", "rayon", "solar-ast", "solar-data-structures", diff --git a/Cargo.toml b/Cargo.toml index 616ae20bbc596..29b71890f1d39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -353,6 +353,7 @@ jiff = "0.2" heck = "0.5" uuid = "1.17.0" flate2 = "1.1" +num-bigint = "0.4" ## Pinned dependencies. Enabled for the workspace in crates/test-utils. # Use unicode-rs which has a smaller binary size than the default ICU4X as the IDNA backend, used diff --git a/crates/lint/Cargo.toml b/crates/lint/Cargo.toml index c48dcfb85e0ed..7eb666436bf7f 100644 --- a/crates/lint/Cargo.toml +++ b/crates/lint/Cargo.toml @@ -28,3 +28,4 @@ solar-sema.workspace = true heck.workspace = true rayon.workspace = true thiserror.workspace = true +num-bigint.workspace = true diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs index 9ee5382afad87..81b34a0284126 100644 --- a/crates/lint/src/sol/med/unsafe_typecast.rs +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -87,7 +87,6 @@ fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option match &lit.kind { solar_ast::LitKind::Number(num) => { if is_negative_number_literal(num) { diff --git a/crates/lint/testdata/UnsafeTypecast.sol b/crates/lint/testdata/UnsafeTypecast.sol index d870f77451236..beee0a02ea1f2 100644 --- a/crates/lint/testdata/UnsafeTypecast.sol +++ b/crates/lint/testdata/UnsafeTypecast.sol @@ -168,17 +168,10 @@ contract UnsafeTypecast { int256 a = -1000; uint256 b = uint256(a); //~WARN: typecasts that can truncate values should be avoided - // Unsafe: int128 -> uint256 (potential loss of sign) - int128 c = -100; - uint256 d = uint256(c); //~WARN: typecasts that can truncate values should be avoided - // Unsafe: uint256 -> int256 (potential overflow) uint256 e = 1000; int256 f = int256(e); //~WARN: typecasts that can truncate values should be avoided - // Unsafe: uint256 -> int128 (potential overflow and truncation) - int128 g = int128(e); //~WARN: typecasts that can truncate values should be avoided - // Unsafe: uint128 -> int128 (potential overflow) uint128 h = 100; int128 i = int128(h); //~WARN: typecasts that can truncate values should be avoided @@ -212,8 +205,6 @@ contract UnsafeTypecast { address a = 0x1234567890123456789012345678901234567890; uint128 b = uint128(uint160(a)); //~WARN: typecasts that can truncate values should be avoided - // Unsafe: address -> int256 (sign issues) - int256 c = int256(uint160(a)); //~WARN: typecasts that can truncate values should be avoided // Unsafe: address -> uint8 (severe truncation) uint8 d = uint8(uint160(a)); //~WARN: typecasts that can truncate values should be avoided @@ -226,11 +217,6 @@ contract UnsafeTypecast { } function literalCasts() public { - // Unsafe: literal downcasts - uint128 a = uint128(1000000000000000000000000000000000000000); //~WARN: typecasts that can truncate values should be avoided - uint64 b = uint64(1000000000000000000000); //~WARN: typecasts that can truncate values should be avoided - int128 c = int128(-1000000000000000000000000000000000000000); //~WARN: typecasts that can truncate values should be avoided - // Unsafe: signed/unsigned conversions uint256 d = uint256(-1000); //~WARN: typecasts that can truncate values should be avoided int256 e = int256(1000000000000000000000000000000000000000); //~WARN: typecasts that can truncate values should be avoided diff --git a/crates/lint/testdata/UnsafeTypecast.stderr b/crates/lint/testdata/UnsafeTypecast.stderr index a1ae6a598b1dd..39d94dce9c5db 100644 --- a/crates/lint/testdata/UnsafeTypecast.stderr +++ b/crates/lint/testdata/UnsafeTypecast.stderr @@ -953,21 +953,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be avoided warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -173 | uint256 d = uint256(c); - | ---------- - | - = note: Consider disabling this lint only if you're certain the cast is safe: - - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - - // Cast is safe because [explain why] - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be avoided - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -177 | int256 f = int256(e); +173 | int256 f = int256(e); | --------- | = note: Consider disabling this lint only if you're certain the cast is safe: @@ -981,7 +967,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be avoided warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -180 | int128 g = int128(e); +177 | int128 i = int128(h); | --------- | = note: Consider disabling this lint only if you're certain the cast is safe: @@ -995,21 +981,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be avoided warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -184 | int128 i = int128(h); - | --------- - | - = note: Consider disabling this lint only if you're certain the cast is safe: - - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - - // Cast is safe because [explain why] - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be avoided - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -190 | bytes16 b = bytes16(a); +183 | bytes16 b = bytes16(a); | ---------- | = note: Consider disabling this lint only if you're certain the cast is safe: @@ -1023,7 +995,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be avoided warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -193 | bytes8 c = bytes8(a); +186 | bytes8 c = bytes8(a); | --------- | = note: Consider disabling this lint only if you're certain the cast is safe: @@ -1037,7 +1009,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be avoided warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -197 | bytes32 e = bytes32(d); +190 | bytes32 e = bytes32(d); | ---------- | = note: Consider disabling this lint only if you're certain the cast is safe: @@ -1051,7 +1023,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be avoided warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -201 | bytes32 g = bytes32(bytes(f)); +194 | bytes32 g = bytes32(bytes(f)); | ----------------- | = note: Consider disabling this lint only if you're certain the cast is safe: @@ -1065,7 +1037,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be avoided warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -213 | uint128 b = uint128(uint160(a)); +206 | uint128 b = uint128(uint160(a)); | ------------------- | = note: Consider disabling this lint only if you're certain the cast is safe: @@ -1079,21 +1051,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be avoided warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -216 | int256 c = int256(uint160(a)); - | ------------------ - | - = note: Consider disabling this lint only if you're certain the cast is safe: - - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - - // Cast is safe because [explain why] - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be avoided - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -219 | uint8 d = uint8(uint160(a)); +210 | uint8 d = uint8(uint160(a)); | ----------------- | = note: Consider disabling this lint only if you're certain the cast is safe: @@ -1107,49 +1065,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be avoided warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -230 | uint128 a = uint128(1000000000000000000000000000000000000000); - | ------------------------------------------------- - | - = note: Consider disabling this lint only if you're certain the cast is safe: - - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - - // Cast is safe because [explain why] - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be avoided - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -231 | uint64 b = uint64(1000000000000000000000); - | ------------------------------ - | - = note: Consider disabling this lint only if you're certain the cast is safe: - - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - - // Cast is safe because [explain why] - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be avoided - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -232 | int128 c = int128(-1000000000000000000000000000000000000000); - | ------------------------------------------------- - | - = note: Consider disabling this lint only if you're certain the cast is safe: - - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - - // Cast is safe because [explain why] - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be avoided - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -235 | uint256 d = uint256(-1000); +221 | uint256 d = uint256(-1000); | -------------- | = note: Consider disabling this lint only if you're certain the cast is safe: @@ -1163,7 +1079,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be avoided warning[unsafe-typecast]: typecasts that can truncate values should be avoided --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -236 | int256 e = int256(1000000000000000000000000000000000000000); +222 | int256 e = int256(1000000000000000000000000000000000000000); | ------------------------------------------------ | = note: Consider disabling this lint only if you're certain the cast is safe: From 47e80e44a878377a35fc4ebe833e0b2d8a5f6cdb Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Wed, 23 Jul 2025 07:20:30 +0000 Subject: [PATCH 05/20] lint --- crates/lint/src/sol/med/unsafe_typecast.rs | 49 +++++++++------------- 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs index 81b34a0284126..5f51e8f949233 100644 --- a/crates/lint/src/sol/med/unsafe_typecast.rs +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -22,16 +22,13 @@ impl<'hir> LateLintPass<'hir> for UnsafeTypecast { // Check for type cast expressions: Type(value) if let ExprKind::Call(call_expr, args, _) = &expr.kind { // Check if this is a type cast (function call where the function is a type) - if let ExprKind::Type(target_type) = &call_expr.kind { - // We need exactly one argument for a type cast - if args.len() == 1 { - if let Some(first_arg) = args.exprs().next() { - if is_unsafe_typecast_hir(hir, first_arg, target_type) { - let suggestion = get_suggestion(); - ctx.emit_with_fix(&UNSAFE_TYPECAST, expr.span, suggestion); - } - } - } + if let ExprKind::Type(target_type) = &call_expr.kind + && args.len() == 1 + && let Some(first_arg) = args.exprs().next() + && is_unsafe_typecast_hir(hir, first_arg, target_type) + { + let suggestion = get_suggestion(); + ctx.emit_with_fix(&UNSAFE_TYPECAST, expr.span, suggestion); } } } @@ -72,16 +69,14 @@ fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option { - if let ExprKind::Type(ty) = &call_expr.kind { - if args.len() == 1 { - if let TypeKind::Elementary(_elem_type) = &ty.kind { - // For type casts, recursively check the source of the inner expression - // This allows us to see through cast chains like uint160(address_var) - if let Some(first_arg) = args.exprs().next() { - return infer_source_type(hir, first_arg); - } - } - } + if let ExprKind::Type(ty) = &call_expr.kind + && args.len() == 1 + && let TypeKind::Elementary(_elem_type) = &ty.kind + && let Some(first_arg) = args.exprs().next() + { + // For type casts, recursively check the source of the inner expression + // This allows us to see through cast chains like uint160(address_var) + return infer_source_type(hir, first_arg); } // For other function calls, try to infer from context or return None None @@ -102,15 +97,10 @@ fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option { - if let Some(first_res) = resolutions.first() { - match first_res { - hir::Res::Item(hir::ItemId::Variable(var_id)) => { - let variable = hir.variable(*var_id); - if let TypeKind::Elementary(elem_type) = &variable.ty.kind { - return Some(*elem_type); - } - } - _ => {} + if let Some(hir::Res::Item(hir::ItemId::Variable(var_id))) = resolutions.first() { + let variable = hir.variable(*var_id); + if let TypeKind::Elementary(elem_type) = &variable.ty.kind { + return Some(*elem_type); } } None @@ -140,7 +130,6 @@ fn is_unsafe_elementary_typecast( target_type: &hir::ElementaryType, ) -> bool { use hir::ElementaryType; - use solar_ast::TypeSize; match (source_type, target_type) { // Numeric downcasts (smaller target size) From 3614115d4cacb91936f396816318acd38d5cae70 Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Thu, 24 Jul 2025 07:40:10 +0000 Subject: [PATCH 06/20] refactor --- Cargo.lock | 1 - Cargo.toml | 1 - crates/lint/Cargo.toml | 1 - crates/lint/src/sol/med/unsafe_typecast.rs | 70 ++++++++-------------- crates/lint/testdata/UnsafeTypecast.sol | 13 +--- crates/lint/testdata/UnsafeTypecast.stderr | 28 --------- 6 files changed, 27 insertions(+), 87 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 542a86418a140..3fe504399f294 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3924,7 +3924,6 @@ dependencies = [ "foundry-compilers", "foundry-config", "heck", - "num-bigint", "rayon", "solar-ast", "solar-data-structures", diff --git a/Cargo.toml b/Cargo.toml index 29b71890f1d39..616ae20bbc596 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -353,7 +353,6 @@ jiff = "0.2" heck = "0.5" uuid = "1.17.0" flate2 = "1.1" -num-bigint = "0.4" ## Pinned dependencies. Enabled for the workspace in crates/test-utils. # Use unicode-rs which has a smaller binary size than the default ICU4X as the IDNA backend, used diff --git a/crates/lint/Cargo.toml b/crates/lint/Cargo.toml index 7eb666436bf7f..c48dcfb85e0ed 100644 --- a/crates/lint/Cargo.toml +++ b/crates/lint/Cargo.toml @@ -28,4 +28,3 @@ solar-sema.workspace = true heck.workspace = true rayon.workspace = true thiserror.workspace = true -num-bigint.workspace = true diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs index 5f51e8f949233..ab74393d7d4d9 100644 --- a/crates/lint/src/sol/med/unsafe_typecast.rs +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -20,16 +20,14 @@ impl<'hir> LateLintPass<'hir> for UnsafeTypecast { expr: &'hir hir::Expr<'hir>, ) { // Check for type cast expressions: Type(value) - if let ExprKind::Call(call_expr, args, _) = &expr.kind { - // Check if this is a type cast (function call where the function is a type) - if let ExprKind::Type(target_type) = &call_expr.kind - && args.len() == 1 - && let Some(first_arg) = args.exprs().next() - && is_unsafe_typecast_hir(hir, first_arg, target_type) - { - let suggestion = get_suggestion(); - ctx.emit_with_fix(&UNSAFE_TYPECAST, expr.span, suggestion); - } + if let ExprKind::Call(call_expr, args, _) = &expr.kind + && let ExprKind::Type(target_type) = &call_expr.kind + && args.len() == 1 + && let Some(first_arg) = args.exprs().next() + && is_unsafe_typecast_hir(hir, first_arg, target_type) + { + let suggestion = get_suggestion(); + ctx.emit_with_fix(&UNSAFE_TYPECAST, expr.span, suggestion); } } } @@ -49,15 +47,13 @@ fn is_unsafe_typecast_hir( target_type: &hir::Type<'_>, ) -> bool { // Get target elementary type - let target_elem_type = match &target_type.kind { - TypeKind::Elementary(elem_type) => elem_type, - _ => return false, + let TypeKind::Elementary(target_elem_type) = &target_type.kind else { + return false; }; // Determine source type from the expression - let source_elem_type = match infer_source_type(hir, source_expr) { - Some(elem_type) => elem_type, - None => return false, + let Some(source_elem_type) = infer_source_type(hir, source_expr) else { + return false; }; is_unsafe_elementary_typecast(&source_elem_type, target_elem_type) @@ -74,27 +70,20 @@ fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option match &lit.kind { - solar_ast::LitKind::Number(num) => { - if is_negative_number_literal(num) { - Some(hir::ElementaryType::Int(solar_ast::TypeSize::ZERO)) - } else { - Some(hir::ElementaryType::UInt(solar_ast::TypeSize::ZERO)) - } - } - solar_ast::LitKind::Address(_) => Some(hir::ElementaryType::Address(false)), - solar_ast::LitKind::Str(..) => Some(hir::ElementaryType::String), - solar_ast::LitKind::Bool(_) => Some(hir::ElementaryType::Bool), - _ => None, - }, + ExprKind::Lit(_) => { + // Return None for all literal types since the compiler performs type checking + // during assignment. + // For example, assigning `uint8 foo = 300;` will fail with + // "value 300 does not fit into type uint8" since uint8 max is 255. + // This eliminates the need for runtime literal type inference and the bigint + // dependency. ref: https://solang.readthedocs.io/en/latest/language/types.html + None + } ExprKind::Ident(resolutions) => { if let Some(hir::Res::Item(hir::ItemId::Variable(var_id))) = resolutions.first() { @@ -119,11 +108,6 @@ fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option bool { - num.sign().eq(&num_bigint::Sign::Minus) -} - /// Checks if a type cast from source_type to target_type is unsafe. fn is_unsafe_elementary_typecast( source_type: &hir::ElementaryType, @@ -133,10 +117,8 @@ fn is_unsafe_elementary_typecast( match (source_type, target_type) { // Numeric downcasts (smaller target size) - (ElementaryType::UInt(source_size), ElementaryType::UInt(target_size)) => { - source_size.bits() > target_size.bits() - } - (ElementaryType::Int(source_size), ElementaryType::Int(target_size)) => { + (ElementaryType::UInt(source_size), ElementaryType::UInt(target_size)) + | (ElementaryType::Int(source_size), ElementaryType::Int(target_size)) => { source_size.bits() > target_size.bits() } @@ -154,10 +136,8 @@ fn is_unsafe_elementary_typecast( } // Dynamic bytes to fixed bytes (potential truncation) - (ElementaryType::Bytes, ElementaryType::FixedBytes(_)) => true, - - // String to fixed bytes (potential truncation) - (ElementaryType::String, ElementaryType::FixedBytes(_)) => true, + (ElementaryType::Bytes, ElementaryType::FixedBytes(_)) + | (ElementaryType::String, ElementaryType::FixedBytes(_)) => true, // Address to smaller uint (truncation) - address is 160 bits (ElementaryType::Address(_), ElementaryType::UInt(target_size)) => target_size.bits() < 160, diff --git a/crates/lint/testdata/UnsafeTypecast.sol b/crates/lint/testdata/UnsafeTypecast.sol index beee0a02ea1f2..39bda3a9ce27d 100644 --- a/crates/lint/testdata/UnsafeTypecast.sol +++ b/crates/lint/testdata/UnsafeTypecast.sol @@ -67,7 +67,7 @@ contract UnsafeTypecast { int248 E = int248(D); int256 F = int256(E); } - function downcastSafeUint() public pure { + function downcastUnsafeUint() public pure { uint256 a = type(uint256).max; uint248 b = uint248(a); //~WARN: typecasts that can truncate values should be avoided uint240 c = uint240(b); //~WARN: typecasts that can truncate values should be avoided @@ -101,7 +101,7 @@ contract UnsafeTypecast { uint16 E = uint16(D); //~WARN: typecasts that can truncate values should be avoided uint8 F = uint8(E); //~WARN: typecasts that can truncate values should be avoided } - function downcastSafeInt() public pure { + function downcastUnsafeInt() public pure { int256 a = type(int256).max; int248 b = int248(a); //~WARN: typecasts that can truncate values should be avoided int240 c = int240(b); //~WARN: typecasts that can truncate values should be avoided @@ -216,13 +216,4 @@ contract UnsafeTypecast { uint256 f = uint256(uint160(a)); } - function literalCasts() public { - // Unsafe: signed/unsigned conversions - uint256 d = uint256(-1000); //~WARN: typecasts that can truncate values should be avoided - int256 e = int256(1000000000000000000000000000000000000000); //~WARN: typecasts that can truncate values should be avoided - - // Safe: literal upcasts - uint256 f = uint256(1000); - int256 g = int256(-1000); - } } \ No newline at end of file diff --git a/crates/lint/testdata/UnsafeTypecast.stderr b/crates/lint/testdata/UnsafeTypecast.stderr index 39d94dce9c5db..76059c32849a7 100644 --- a/crates/lint/testdata/UnsafeTypecast.stderr +++ b/crates/lint/testdata/UnsafeTypecast.stderr @@ -1062,31 +1062,3 @@ warning[unsafe-typecast]: typecasts that can truncate values should be avoided = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -221 | uint256 d = uint256(-1000); - | -------------- - | - = note: Consider disabling this lint only if you're certain the cast is safe: - - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - - // Cast is safe because [explain why] - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be avoided - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -222 | int256 e = int256(1000000000000000000000000000000000000000); - | ------------------------------------------------ - | - = note: Consider disabling this lint only if you're certain the cast is safe: - - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - - // Cast is safe because [explain why] - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - From e7febc7d2dea4a4d00ac3654bdb3fe3a203699e4 Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Mon, 28 Jul 2025 10:34:00 +0700 Subject: [PATCH 07/20] Update crates/lint/src/sol/med/unsafe_typecast.rs Co-authored-by: clandestine.eth <96172957+0xClandestine@users.noreply.github.com> --- crates/lint/src/sol/med/unsafe_typecast.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs index ab74393d7d4d9..fba0af7a24c51 100644 --- a/crates/lint/src/sol/med/unsafe_typecast.rs +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -35,8 +35,8 @@ impl<'hir> LateLintPass<'hir> for UnsafeTypecast { // Returns the suggested fix based on the unsafe typecast expression fn get_suggestion() -> Snippet { Snippet::Block { - desc: Some("Consider disabling this lint only if you're certain the cast is safe:"), - code: "// Ensure the value fits in the target type before casting\n// forge-lint: disable-next-line(unsafe-typecast)\n// Cast is safe because [explain why]".to_string(), + desc: Some("Consider disabling this lint if you're certain the cast is safe:"), + code: "// Cast is safe because [explain why]".to_string()\n// forge-lint: disable-next-line(unsafe-typecast), } } From 7b541f9002e56fc46640b4a72119ee55b6902ffc Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Tue, 29 Jul 2025 15:49:27 +0700 Subject: [PATCH 08/20] refactor --- crates/lint/src/sol/med/unsafe_typecast.rs | 47 +- crates/lint/testdata/UnsafeTypecast.sol | 347 +++-- crates/lint/testdata/UnsafeTypecast.stderr | 1504 ++++++++++++++------ 3 files changed, 1346 insertions(+), 552 deletions(-) diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs index fba0af7a24c51..3cbfbd677a02b 100644 --- a/crates/lint/src/sol/med/unsafe_typecast.rs +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -9,7 +9,7 @@ declare_forge_lint!( UNSAFE_TYPECAST, Severity::Med, "unsafe-typecast", - "typecasts that can truncate values should be avoided" + "typecasts that can truncate values should be checked" ); impl<'hir> LateLintPass<'hir> for UnsafeTypecast { @@ -36,7 +36,7 @@ impl<'hir> LateLintPass<'hir> for UnsafeTypecast { fn get_suggestion() -> Snippet { Snippet::Block { desc: Some("Consider disabling this lint if you're certain the cast is safe:"), - code: "// Cast is safe because [explain why]".to_string()\n// forge-lint: disable-next-line(unsafe-typecast), + code: "// Cast is safe because [explain why]\n// forge-lint: disable-next-line(unsafe-typecast)".to_string(), } } @@ -62,12 +62,14 @@ fn is_unsafe_typecast_hir( /// Infers the elementary type of a source expression. /// For cast chains, returns the ultimate source type, not intermediate cast results. fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option { + use hir::{ElementaryType, ExprKind, ItemId, Lit as HirLit, Res, TypeKind}; + use solar_ast::LitKind; + match &expr.kind { - // Type cast: Type(value) - recursively check the inner value + // Recursive cast: Type(val) ExprKind::Call(call_expr, args, _) => { if let ExprKind::Type(ty) = &call_expr.kind && args.len() == 1 - && let TypeKind::Elementary(_elem_type) = &ty.kind && let Some(first_arg) = args.exprs().next() { return infer_source_type(hir, first_arg); @@ -75,18 +77,9 @@ fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option { - // Return None for all literal types since the compiler performs type checking - // during assignment. - // For example, assigning `uint8 foo = 300;` will fail with - // "value 300 does not fit into type uint8" since uint8 max is 255. - // This eliminates the need for runtime literal type inference and the bigint - // dependency. ref: https://solang.readthedocs.io/en/latest/language/types.html - None - } - + // Identifiers (variables) ExprKind::Ident(resolutions) => { - if let Some(hir::Res::Item(hir::ItemId::Variable(var_id))) = resolutions.first() { + if let Some(Res::Item(ItemId::Variable(var_id))) = resolutions.first() { let variable = hir.variable(*var_id); if let TypeKind::Elementary(elem_type) = &variable.ty.kind { return Some(*elem_type); @@ -95,11 +88,29 @@ fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option match kind { + LitKind::Str(_, bytes, _) => { + let byte_len = bytes.len().try_into().unwrap(); + Some(ElementaryType::FixedBytes(solar_ast::TypeSize::new_fb_bytes(byte_len))) + } + + LitKind::Address(_) => Some(ElementaryType::Address(false)), + + LitKind::Bool(_) => Some(ElementaryType::Bool), + + // Treat number literals as wide unsigned ints (won’t trigger linter) + LitKind::Number(_) => None, + LitKind::Rational(_) => None, + LitKind::Err(_) => None, + }, + + // Unary operations (e.g. -x) ExprKind::Unary(op, inner_expr) => match op.kind { solar_ast::UnOpKind::Neg => match infer_source_type(hir, inner_expr) { - Some(hir::ElementaryType::UInt(size)) => Some(hir::ElementaryType::Int(size)), - Some(signed_type @ hir::ElementaryType::Int(_)) => Some(signed_type), - _ => Some(hir::ElementaryType::Int(solar_ast::TypeSize::ZERO)), + Some(ElementaryType::UInt(size)) => Some(ElementaryType::Int(size)), + Some(signed_type @ ElementaryType::Int(_)) => Some(signed_type), + _ => Some(ElementaryType::Int(solar_ast::TypeSize::ZERO)), }, _ => infer_source_type(hir, inner_expr), }, diff --git a/crates/lint/testdata/UnsafeTypecast.sol b/crates/lint/testdata/UnsafeTypecast.sol index 39bda3a9ce27d..9c19c1515b221 100644 --- a/crates/lint/testdata/UnsafeTypecast.sol +++ b/crates/lint/testdata/UnsafeTypecast.sol @@ -33,6 +33,7 @@ contract UnsafeTypecast { uint248 E = uint248(D); uint256 F = uint256(E); } + function upcastSafeInt() public pure { int8 a = type(int8).max; int16 b = int16(a); @@ -67,153 +68,223 @@ contract UnsafeTypecast { int248 E = int248(D); int256 F = int256(E); } + function downcastUnsafeUint() public pure { uint256 a = type(uint256).max; - uint248 b = uint248(a); //~WARN: typecasts that can truncate values should be avoided - uint240 c = uint240(b); //~WARN: typecasts that can truncate values should be avoided - uint232 d = uint232(c); //~WARN: typecasts that can truncate values should be avoided - uint224 e = uint224(d); //~WARN: typecasts that can truncate values should be avoided - uint216 f = uint216(e); //~WARN: typecasts that can truncate values should be avoided - uint208 g = uint208(f); //~WARN: typecasts that can truncate values should be avoided - uint200 h = uint200(g); //~WARN: typecasts that can truncate values should be avoided - uint192 i = uint192(h); //~WARN: typecasts that can truncate values should be avoided - uint184 j = uint184(i); //~WARN: typecasts that can truncate values should be avoided - uint176 k = uint176(j); //~WARN: typecasts that can truncate values should be avoided - uint168 l = uint168(k); //~WARN: typecasts that can truncate values should be avoided - uint160 m = uint160(l); //~WARN: typecasts that can truncate values should be avoided - uint152 n = uint152(m); //~WARN: typecasts that can truncate values should be avoided - uint144 o = uint144(n); //~WARN: typecasts that can truncate values should be avoided - uint136 p = uint136(o); //~WARN: typecasts that can truncate values should be avoided - uint128 q = uint128(p); //~WARN: typecasts that can truncate values should be avoided - uint120 r = uint120(q); //~WARN: typecasts that can truncate values should be avoided - uint112 s = uint112(r); //~WARN: typecasts that can truncate values should be avoided - uint104 t = uint104(s); //~WARN: typecasts that can truncate values should be avoided - uint96 u = uint96(t); //~WARN: typecasts that can truncate values should be avoided - uint88 v = uint88(u); //~WARN: typecasts that can truncate values should be avoided - uint80 w = uint80(v); //~WARN: typecasts that can truncate values should be avoided - uint72 x = uint72(w); //~WARN: typecasts that can truncate values should be avoided - uint64 y = uint64(x); //~WARN: typecasts that can truncate values should be avoided - uint56 z = uint56(y); //~WARN: typecasts that can truncate values should be avoided - uint48 A = uint48(z); //~WARN: typecasts that can truncate values should be avoided - uint40 B = uint40(A); //~WARN: typecasts that can truncate values should be avoided - uint32 C = uint32(B); //~WARN: typecasts that can truncate values should be avoided - uint24 D = uint24(C); //~WARN: typecasts that can truncate values should be avoided - uint16 E = uint16(D); //~WARN: typecasts that can truncate values should be avoided - uint8 F = uint8(E); //~WARN: typecasts that can truncate values should be avoided + uint248 b = uint248(a); //~WARN: typecasts that can truncate values should be checked + uint240 c = uint240(b); //~WARN: typecasts that can truncate values should be checked + uint232 d = uint232(c); //~WARN: typecasts that can truncate values should be checked + uint224 e = uint224(d); //~WARN: typecasts that can truncate values should be checked + uint216 f = uint216(e); //~WARN: typecasts that can truncate values should be checked + uint208 g = uint208(f); //~WARN: typecasts that can truncate values should be checked + uint200 h = uint200(g); //~WARN: typecasts that can truncate values should be checked + uint192 i = uint192(h); //~WARN: typecasts that can truncate values should be checked + uint184 j = uint184(i); //~WARN: typecasts that can truncate values should be checked + uint176 k = uint176(j); //~WARN: typecasts that can truncate values should be checked + uint168 l = uint168(k); //~WARN: typecasts that can truncate values should be checked + uint160 m = uint160(l); //~WARN: typecasts that can truncate values should be checked + uint152 n = uint152(m); //~WARN: typecasts that can truncate values should be checked + uint144 o = uint144(n); //~WARN: typecasts that can truncate values should be checked + uint136 p = uint136(o); //~WARN: typecasts that can truncate values should be checked + uint128 q = uint128(p); //~WARN: typecasts that can truncate values should be checked + uint120 r = uint120(q); //~WARN: typecasts that can truncate values should be checked + uint112 s = uint112(r); //~WARN: typecasts that can truncate values should be checked + uint104 t = uint104(s); //~WARN: typecasts that can truncate values should be checked + uint96 u = uint96(t); //~WARN: typecasts that can truncate values should be checked + uint88 v = uint88(u); //~WARN: typecasts that can truncate values should be checked + uint80 w = uint80(v); //~WARN: typecasts that can truncate values should be checked + uint72 x = uint72(w); //~WARN: typecasts that can truncate values should be checked + uint64 y = uint64(x); //~WARN: typecasts that can truncate values should be checked + uint56 z = uint56(y); //~WARN: typecasts that can truncate values should be checked + uint48 A = uint48(z); //~WARN: typecasts that can truncate values should be checked + uint40 B = uint40(A); //~WARN: typecasts that can truncate values should be checked + uint32 C = uint32(B); //~WARN: typecasts that can truncate values should be checked + uint24 D = uint24(C); //~WARN: typecasts that can truncate values should be checked + uint16 E = uint16(D); //~WARN: typecasts that can truncate values should be checked + uint8 F = uint8(E); //~WARN: typecasts that can truncate values should be checked } + function downcastUnsafeInt() public pure { int256 a = type(int256).max; - int248 b = int248(a); //~WARN: typecasts that can truncate values should be avoided - int240 c = int240(b); //~WARN: typecasts that can truncate values should be avoided - int232 d = int232(c); //~WARN: typecasts that can truncate values should be avoided - int224 e = int224(d); //~WARN: typecasts that can truncate values should be avoided - int216 f = int216(e); //~WARN: typecasts that can truncate values should be avoided - int208 g = int208(f); //~WARN: typecasts that can truncate values should be avoided - int200 h = int200(g); //~WARN: typecasts that can truncate values should be avoided - int192 i = int192(h); //~WARN: typecasts that can truncate values should be avoided - int184 j = int184(i); //~WARN: typecasts that can truncate values should be avoided - int176 k = int176(j); //~WARN: typecasts that can truncate values should be avoided - int168 l = int168(k); //~WARN: typecasts that can truncate values should be avoided - int160 m = int160(l); //~WARN: typecasts that can truncate values should be avoided - int152 n = int152(m); //~WARN: typecasts that can truncate values should be avoided - int144 o = int144(n); //~WARN: typecasts that can truncate values should be avoided - int136 p = int136(o); //~WARN: typecasts that can truncate values should be avoided - int128 q = int128(p); //~WARN: typecasts that can truncate values should be avoided - int120 r = int120(q); //~WARN: typecasts that can truncate values should be avoided - int112 s = int112(r); //~WARN: typecasts that can truncate values should be avoided - int104 t = int104(s); //~WARN: typecasts that can truncate values should be avoided - int96 u = int96(t); //~WARN: typecasts that can truncate values should be avoided - int88 v = int88(u); //~WARN: typecasts that can truncate values should be avoided - int80 w = int80(v); //~WARN: typecasts that can truncate values should be avoided - int72 x = int72(w); //~WARN: typecasts that can truncate values should be avoided - int64 y = int64(x); //~WARN: typecasts that can truncate values should be avoided - int56 z = int56(y); //~WARN: typecasts that can truncate values should be avoided - int48 A = int48(z); //~WARN: typecasts that can truncate values should be avoided - int40 B = int40(A); //~WARN: typecasts that can truncate values should be avoided - int32 C = int32(B); //~WARN: typecasts that can truncate values should be avoided - int24 D = int24(C); //~WARN: typecasts that can truncate values should be avoided - int16 E = int16(D); //~WARN: typecasts that can truncate values should be avoided - int8 F = int8(E); //~WARN: typecasts that can truncate values should be avoided + int248 b = int248(a); //~WARN: typecasts that can truncate values should be checked + int240 c = int240(b); //~WARN: typecasts that can truncate values should be checked + int232 d = int232(c); //~WARN: typecasts that can truncate values should be checked + int224 e = int224(d); //~WARN: typecasts that can truncate values should be checked + int216 f = int216(e); //~WARN: typecasts that can truncate values should be checked + int208 g = int208(f); //~WARN: typecasts that can truncate values should be checked + int200 h = int200(g); //~WARN: typecasts that can truncate values should be checked + int192 i = int192(h); //~WARN: typecasts that can truncate values should be checked + int184 j = int184(i); //~WARN: typecasts that can truncate values should be checked + int176 k = int176(j); //~WARN: typecasts that can truncate values should be checked + int168 l = int168(k); //~WARN: typecasts that can truncate values should be checked + int160 m = int160(l); //~WARN: typecasts that can truncate values should be checked + int152 n = int152(m); //~WARN: typecasts that can truncate values should be checked + int144 o = int144(n); //~WARN: typecasts that can truncate values should be checked + int136 p = int136(o); //~WARN: typecasts that can truncate values should be checked + int128 q = int128(p); //~WARN: typecasts that can truncate values should be checked + int120 r = int120(q); //~WARN: typecasts that can truncate values should be checked + int112 s = int112(r); //~WARN: typecasts that can truncate values should be checked + int104 t = int104(s); //~WARN: typecasts that can truncate values should be checked + int96 u = int96(t); //~WARN: typecasts that can truncate values should be checked + int88 v = int88(u); //~WARN: typecasts that can truncate values should be checked + int80 w = int80(v); //~WARN: typecasts that can truncate values should be checked + int72 x = int72(w); //~WARN: typecasts that can truncate values should be checked + int64 y = int64(x); //~WARN: typecasts that can truncate values should be checked + int56 z = int56(y); //~WARN: typecasts that can truncate values should be checked + int48 A = int48(z); //~WARN: typecasts that can truncate values should be checked + int40 B = int40(A); //~WARN: typecasts that can truncate values should be checked + int32 C = int32(B); //~WARN: typecasts that can truncate values should be checked + int24 D = int24(C); //~WARN: typecasts that can truncate values should be checked + int16 E = int16(D); //~WARN: typecasts that can truncate values should be checked + int8 F = int8(E); //~WARN: typecasts that can truncate values should be checked } - function numericDowncasts() public { - // Unsafe: uint256 -> uint128 - uint256 a = 1000; - uint128 b = uint128(a); //~WARN: typecasts that can truncate values should be avoided - - // Unsafe: uint256 -> uint64 - uint64 c = uint64(a); //~WARN: typecasts that can truncate values should be avoided - - // Unsafe: uint256 -> uint8 - uint8 d = uint8(a); //~WARN: typecasts that can truncate values should be avoided - - // Unsafe: int256 -> int128 - int256 e = -1000; - int128 f = int128(e); //~WARN: typecasts that can truncate values should be avoided - - // Unsafe: int256 -> int8 - int8 g = int8(e); //~WARN: typecasts that can truncate values should be avoided - - // Safe: uint128 -> uint256 (upcast) - uint256 h = uint256(b); - - // Safe: int128 -> int256 (upcast) - int256 i = int256(f); - - // Safe: same size - uint256 j = uint256(a); + + function upcastSafeBytes() public pure { + bytes1 a = 0x12; + bytes2 b = bytes2(a); + bytes4 c = bytes4(b); + bytes8 d = bytes8(c); + bytes16 e = bytes16(d); + bytes24 f = bytes24(e); + bytes28 g = bytes28(f); + bytes30 h = bytes30(g); + bytes31 i = bytes31(h); + bytes32 j = bytes32(i); + + // Safe: same size copies + bytes1 aa = bytes1(a); + bytes2 bb = bytes2(b); + bytes4 cc = bytes4(c); + bytes8 dd = bytes8(d); + bytes16 ee = bytes16(e); + bytes24 ff = bytes24(f); + bytes28 gg = bytes28(g); + bytes30 hh = bytes30(h); + bytes31 ii = bytes31(i); + bytes32 jj = bytes32(j); } - - function signedUnsignedConversions() public { - // Unsafe: int256 -> uint256 (potential loss of sign) - int256 a = -1000; - uint256 b = uint256(a); //~WARN: typecasts that can truncate values should be avoided - - // Unsafe: uint256 -> int256 (potential overflow) - uint256 e = 1000; - int256 f = int256(e); //~WARN: typecasts that can truncate values should be avoided - - // Unsafe: uint128 -> int128 (potential overflow) - uint128 h = 100; - int128 i = int128(h); //~WARN: typecasts that can truncate values should be avoided + + function numericDowncastsUnsafe() public pure { + uint256 a = 2**255 + 1000; + + uint248 a_u248 = uint248(a); //~WARN: typecasts that can truncate values should be checked + uint240 a_u240 = uint240(a); //~WARN: typecasts that can truncate values should be checked + uint224 a_u224 = uint224(a); //~WARN: typecasts that can truncate values should be checked + uint192 a_u192 = uint192(a); //~WARN: typecasts that can truncate values should be checked + uint160 a_u160 = uint160(a); //~WARN: typecasts that can truncate values should be checked + uint128 a_u128 = uint128(a); //~WARN: typecasts that can truncate values should be checked + uint64 a_u64 = uint64(a); //~WARN: typecasts that can truncate values should be checked + uint32 a_u32 = uint32(a); //~WARN: typecasts that can truncate values should be checked + uint16 a_u16 = uint16(a); //~WARN: typecasts that can truncate values should be checked + uint8 a_u8 = uint8(a); //~WARN: typecasts that can truncate values should be checked + + int256 i = -2**255 + 1000; + int248 i_i248 = int248(i); //~WARN: typecasts that can truncate values should be checked + int240 i_i240 = int240(i); //~WARN: typecasts that can truncate values should be checked + int224 i_i224 = int224(i); //~WARN: typecasts that can truncate values should be checked + int192 i_i192 = int192(i); //~WARN: typecasts that can truncate values should be checked + int160 i_i160 = int160(i); //~WARN: typecasts that can truncate values should be checked + int128 i_i128 = int128(i); //~WARN: typecasts that can truncate values should be checked + int64 i_i64 = int64(i); //~WARN: typecasts that can truncate values should be checked + int32 i_i32 = int32(i); //~WARN: typecasts that can truncate values should be checked + int16 i_i16 = int16(i); //~WARN: typecasts that can truncate values should be checked + int8 i_i8 = int8(i); //~WARN: typecasts that can truncate values should be checked } - - function bytesConversions() public { - // Unsafe: bytes32 -> bytes16 (truncation) + + function numericUpcastsSafe() public pure { + int256 i = -2**255 + 1000; + uint256 a = 2**255 + 1000; + + uint128 s_u128 = 1234; + uint256 s_u256 = uint256(s_u128); // Safe + + int128 s_i128 = -1234; + int256 s_i256 = int256(s_i128); // Safe + + uint256 s_u256_copy = uint256(a); + int256 s_i256_copy = int256(i); + } + + function downcastUnsafeBytes() public pure { bytes32 a = "hello world"; - bytes16 b = bytes16(a); //~WARN: typecasts that can truncate values should be avoided - - // Unsafe: bytes32 -> bytes8 (truncation) - bytes8 c = bytes8(a); //~WARN: typecasts that can truncate values should be avoided - - // Unsafe: bytes -> bytes32 (potential truncation) - bytes memory d = "hello world"; - bytes32 e = bytes32(d); //~WARN: typecasts that can truncate values should be avoided - - // Unsafe: string -> bytes32 (potential truncation) - string memory f = "hello world"; - bytes32 g = bytes32(bytes(f)); //~WARN: typecasts that can truncate values should be avoided - - // Safe: bytes16 -> bytes32 (upcast) - bytes32 h = bytes32(b); - - // Safe: same size - bytes32 i = bytes32(a); + + bytes31 b = bytes31(a); //~WARN: typecasts that can truncate values should be checked + bytes30 c = bytes30(b); //~WARN: typecasts that can truncate values should be checked + bytes28 d = bytes28(c); //~WARN: typecasts that can truncate values should be checked + bytes24 e = bytes24(d); //~WARN: typecasts that can truncate values should be checked + bytes20 f = bytes20(e); //~WARN: typecasts that can truncate values should be checked + bytes16 g = bytes16(f); //~WARN: typecasts that can truncate values should be checked + bytes12 h = bytes12(g); //~WARN: typecasts that can truncate values should be checked + bytes8 i = bytes8(h); //~WARN: typecasts that can truncate values should be checked + bytes4 j = bytes4(i); //~WARN: typecasts that can truncate values should be checked + bytes2 k = bytes2(j); //~WARN: typecasts that can truncate values should be checked + bytes1 l = bytes1(k); //~WARN: typecasts that can truncate values should be checked + + bytes memory dyn = "hello world"; + bytes32 fromDyn = bytes32(dyn); //~WARN: typecasts that can truncate values should be checked + + string memory s = "hello world"; + bytes32 fromStr = bytes32(bytes(s)); //~WARN: typecasts that can truncate values should be checked + } + + function signedUnsignedConversions() public pure { + int256 a = -1; + uint256 b = uint256(a); //~WARN: typecasts that can truncate values should be checked + + int128 a128 = -500; + uint128 b128 = uint128(a128); //~WARN: typecasts that can truncate values should be checked + + uint256 c = type(uint256).max; + int256 d = int256(c); //~WARN: typecasts that can truncate values should be checked + + uint128 c128 = type(uint128).max; + int128 d128 = int128(c128); //~WARN: typecasts that can truncate values should be checked + + int128 safePos = 1234; + uint128 u_safe = uint128(safePos); //~WARN: typecasts that can truncate values should be checked + + uint8 small = 5; + int8 signedSmall = int8(small); //~WARN: typecasts that can truncate values should be checked + } + + function upcastSafeAddress() public pure { + address a = 0x1234567890123456789012345678901234567890; + + uint160 b = uint160(a); // Safe + uint176 c = uint176(b); // Safe + uint192 d = uint192(c); // Safe + uint224 e = uint224(d); // Safe + uint256 f = uint256(e); // Safe + } + + function downcastUnsafeAddress() public pure { + address a = 0x1234567890123456789012345678901234567890; + uint160 base = uint160(a); + + uint152 b = uint152(base); //~WARN: typecasts that can truncate values should be checked + uint144 c = uint144(base); //~WARN: typecasts that can truncate values should be checked + uint136 d = uint136(base); //~WARN: typecasts that can truncate values should be checked + uint128 e = uint128(base); //~WARN: typecasts that can truncate values should be checked + uint120 f = uint120(base); //~WARN: typecasts that can truncate values should be checked + uint112 g = uint112(base); //~WARN: typecasts that can truncate values should be checked + uint104 h = uint104(base); //~WARN: typecasts that can truncate values should be checked + uint96 i = uint96(base); //~WARN: typecasts that can truncate values should be checked + uint88 j = uint88(base); //~WARN: typecasts that can truncate values should be checked } - - function addressConversions() public { - // Unsafe: address -> uint128 (truncation) + + function downcastUnsafeAddress2() public pure { address a = 0x1234567890123456789012345678901234567890; - uint128 b = uint128(uint160(a)); //~WARN: typecasts that can truncate values should be avoided - - - // Unsafe: address -> uint8 (severe truncation) - uint8 d = uint8(uint160(a)); //~WARN: typecasts that can truncate values should be avoided - - // Safe: address -> uint160 (exact fit) - uint160 e = uint160(a); - - // Safe: address -> uint256 (upcast) - uint256 f = uint256(uint160(a)); + uint160 base = uint160(a); + + uint80 k = uint80(base); //~WARN: typecasts that can truncate values should be checked + uint72 l = uint72(base); //~WARN: typecasts that can truncate values should be checked + uint64 m = uint64(base); //~WARN: typecasts that can truncate values should be checked + uint56 n = uint56(base); //~WARN: typecasts that can truncate values should be checked + uint48 o = uint48(base); //~WARN: typecasts that can truncate values should be checked + uint40 p = uint40(base); //~WARN: typecasts that can truncate values should be checked + uint32 q = uint32(base); //~WARN: typecasts that can truncate values should be checked + uint24 r = uint24(base); //~WARN: typecasts that can truncate values should be checked + uint16 s = uint16(base); //~WARN: typecasts that can truncate values should be checked + uint8 t = uint8(base); //~WARN: typecasts that can truncate values should be checked } - -} \ No newline at end of file +} diff --git a/crates/lint/testdata/UnsafeTypecast.stderr b/crates/lint/testdata/UnsafeTypecast.stderr index 76059c32849a7..4634d89f9ac92 100644 --- a/crates/lint/testdata/UnsafeTypecast.stderr +++ b/crates/lint/testdata/UnsafeTypecast.stderr @@ -1,1064 +1,1776 @@ -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +170 | uint248 a_u248 = uint248(a); + | ------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +171 | uint240 a_u240 = uint240(a); + | ------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +172 | uint224 a_u224 = uint224(a); + | ------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +173 | uint192 a_u192 = uint192(a); + | ------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +174 | uint160 a_u160 = uint160(a); + | ------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +175 | uint128 a_u128 = uint128(a); + | ------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +176 | uint64 a_u64 = uint64(a); + | ----- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +177 | uint32 a_u32 = uint32(a); + | ----- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +178 | uint16 a_u16 = uint16(a); + | ----- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +179 | uint8 a_u8 = uint8(a); + | ---- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +182 | int248 i_i248 = int248(i); + | ------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +183 | int240 i_i240 = int240(i); + | ------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +184 | int224 i_i224 = int224(i); + | ------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +185 | int192 i_i192 = int192(i); + | ------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +186 | int160 i_i160 = int160(i); + | ------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +187 | int128 i_i128 = int128(i); + | ------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +188 | int64 i_i64 = int64(i); + | ----- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +189 | int32 i_i32 = int32(i); + | ----- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +190 | int16 i_i16 = int16(i); + | ----- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +191 | int8 i_i8 = int8(i); + | ---- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +198 | uint128 s_u128 = 1234; + | ------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +199 | uint256 s_u256 = uint256(s_u128); // Safe + | ------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +201 | int128 s_i128 = -1234; + | ------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +202 | int256 s_i256 = int256(s_i128); // Safe + | ------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +204 | uint256 s_u256_copy = uint256(a); + | ----------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +205 | int256 s_i256_copy = int256(i); + | ----------- + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +note[mixed-case-variable]: mutable variables should use mixedCase + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +244 | uint128 u_safe = uint128(safePos); + | ------ + | + = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable + +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -72 | uint248 b = uint248(a); +74 | uint248 b = uint248(a); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -73 | uint240 c = uint240(b); +75 | uint240 c = uint240(b); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -74 | uint232 d = uint232(c); +76 | uint232 d = uint232(c); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -75 | uint224 e = uint224(d); +77 | uint224 e = uint224(d); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -76 | uint216 f = uint216(e); +78 | uint216 f = uint216(e); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -77 | uint208 g = uint208(f); +79 | uint208 g = uint208(f); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -78 | uint200 h = uint200(g); +80 | uint200 h = uint200(g); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -79 | uint192 i = uint192(h); +81 | uint192 i = uint192(h); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -80 | uint184 j = uint184(i); +82 | uint184 j = uint184(i); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -81 | uint176 k = uint176(j); +83 | uint176 k = uint176(j); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -82 | uint168 l = uint168(k); +84 | uint168 l = uint168(k); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -83 | uint160 m = uint160(l); +85 | uint160 m = uint160(l); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -84 | uint152 n = uint152(m); +86 | uint152 n = uint152(m); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -85 | uint144 o = uint144(n); +87 | uint144 o = uint144(n); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -86 | uint136 p = uint136(o); +88 | uint136 p = uint136(o); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -87 | uint128 q = uint128(p); +89 | uint128 q = uint128(p); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -88 | uint120 r = uint120(q); +90 | uint120 r = uint120(q); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -89 | uint112 s = uint112(r); +91 | uint112 s = uint112(r); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -90 | uint104 t = uint104(s); +92 | uint104 t = uint104(s); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be avoided - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -91 | uint96 u = uint96(t); - | --------- - | - = note: Consider disabling this lint only if you're certain the cast is safe: - - - // Ensure the value fits in the target type before casting - // forge-lint: disable-next-line(unsafe-typecast) - - // Cast is safe because [explain why] = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -92 | uint88 v = uint88(u); +93 | uint96 u = uint96(t); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be avoided - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -93 | uint80 w = uint80(v); - | --------- - | - = note: Consider disabling this lint only if you're certain the cast is safe: - - - // Ensure the value fits in the target type before casting - // forge-lint: disable-next-line(unsafe-typecast) - - // Cast is safe because [explain why] = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -94 | uint72 x = uint72(w); +94 | uint88 v = uint88(u); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -95 | uint64 y = uint64(x); +95 | uint80 w = uint80(v); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -96 | uint56 z = uint56(y); +96 | uint72 x = uint72(w); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -97 | uint48 A = uint48(z); +97 | uint64 y = uint64(x); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -98 | uint40 B = uint40(A); +98 | uint56 z = uint56(y); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -99 | uint32 C = uint32(B); +99 | uint48 A = uint48(z); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -100 | uint24 D = uint24(C); +100 | uint40 B = uint40(A); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -101 | uint16 E = uint16(D); +101 | uint32 C = uint32(B); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -102 | uint8 F = uint8(E); - | -------- +102 | uint24 D = uint24(C); + | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -106 | int248 b = int248(a); +103 | uint16 E = uint16(D); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -107 | int240 c = int240(b); - | --------- +104 | uint8 F = uint8(E); + | -------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -108 | int232 d = int232(c); +109 | int248 b = int248(a); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -109 | int224 e = int224(d); +110 | int240 c = int240(b); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -110 | int216 f = int216(e); +111 | int232 d = int232(c); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -111 | int208 g = int208(f); +112 | int224 e = int224(d); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -112 | int200 h = int200(g); +113 | int216 f = int216(e); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -113 | int192 i = int192(h); +114 | int208 g = int208(f); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -114 | int184 j = int184(i); +115 | int200 h = int200(g); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -115 | int176 k = int176(j); +116 | int192 i = int192(h); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -116 | int168 l = int168(k); +117 | int184 j = int184(i); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -117 | int160 m = int160(l); +118 | int176 k = int176(j); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -118 | int152 n = int152(m); +119 | int168 l = int168(k); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -119 | int144 o = int144(n); +120 | int160 m = int160(l); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -120 | int136 p = int136(o); +121 | int152 n = int152(m); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -121 | int128 q = int128(p); +122 | int144 o = int144(n); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -122 | int120 r = int120(q); +123 | int136 p = int136(o); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -123 | int112 s = int112(r); +124 | int128 q = int128(p); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -124 | int104 t = int104(s); +125 | int120 r = int120(q); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -125 | int96 u = int96(t); - | -------- +126 | int112 s = int112(r); + | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -126 | int88 v = int88(u); - | -------- +127 | int104 t = int104(s); + | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -127 | int80 w = int80(v); +128 | int96 u = int96(t); | -------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -128 | int72 x = int72(w); +129 | int88 v = int88(u); | -------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -129 | int64 y = int64(x); +130 | int80 w = int80(v); | -------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -130 | int56 z = int56(y); +131 | int72 x = int72(w); | -------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -131 | int48 A = int48(z); +132 | int64 y = int64(x); | -------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -132 | int40 B = int40(A); +133 | int56 z = int56(y); | -------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -133 | int32 C = int32(B); +134 | int48 A = int48(z); | -------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -134 | int24 D = int24(C); +135 | int40 B = int40(A); | -------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -135 | int16 E = int16(D); +136 | int32 C = int32(B); | -------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -136 | int8 F = int8(E); - | ------- +137 | int24 D = int24(C); + | -------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting - - // forge-lint: disable-next-line(unsafe-typecast) - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -141 | uint128 b = uint128(a); - | ---------- +138 | int16 E = int16(D); + | -------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting + - // Cast is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +139 | int8 F = int8(E); + | ------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -144 | uint64 c = uint64(a); - | --------- +170 | uint248 a_u248 = uint248(a); + | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting + - // Cast is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +171 | uint240 a_u240 = uint240(a); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -147 | uint8 d = uint8(a); - | -------- +172 | uint224 a_u224 = uint224(a); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | - = note: Consider disabling this lint only if you're certain the cast is safe: +173 | uint192 a_u192 = uint192(a); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting + - // Cast is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +174 | uint160 a_u160 = uint160(a); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -151 | int128 f = int128(e); - | --------- +175 | uint128 a_u128 = uint128(a); + | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting + - // Cast is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +176 | uint64 a_u64 = uint64(a); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -154 | int8 g = int8(e); - | ------- +177 | uint32 a_u32 = uint32(a); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +178 | uint16 a_u16 = uint16(a); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +179 | uint8 a_u8 = uint8(a); + | -------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +182 | int248 i_i248 = int248(i); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +183 | int240 i_i240 = int240(i); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +184 | int224 i_i224 = int224(i); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +185 | int192 i_i192 = int192(i); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +186 | int160 i_i160 = int160(i); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +187 | int128 i_i128 = int128(i); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +188 | int64 i_i64 = int64(i); + | -------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +189 | int32 i_i32 = int32(i); + | -------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting + - // Cast is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +190 | int16 i_i16 = int16(i); + | -------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +191 | int8 i_i8 = int8(i); + | ------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +211 | bytes31 b = bytes31(a); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +212 | bytes30 c = bytes30(b); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +213 | bytes28 d = bytes28(c); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +214 | bytes24 e = bytes24(d); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +215 | bytes20 f = bytes20(e); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +216 | bytes16 g = bytes16(f); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -169 | uint256 b = uint256(a); +217 | bytes12 h = bytes12(g); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting + - // Cast is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +218 | bytes8 i = bytes8(h); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -173 | int256 f = int256(e); +219 | bytes4 j = bytes4(i); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting + - // Cast is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +220 | bytes2 k = bytes2(j); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -177 | int128 i = int128(h); +221 | bytes1 l = bytes1(k); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +224 | bytes32 fromDyn = bytes32(dyn); + | ------------ + | + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting + - // Cast is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +227 | bytes32 fromStr = bytes32(bytes(s)); + | ----------------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -183 | bytes16 b = bytes16(a); +232 | uint256 b = uint256(a); | ---------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting + - // Cast is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +235 | uint128 b128 = uint128(a128); + | ------------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -186 | bytes8 c = bytes8(a); +238 | int256 d = int256(c); | --------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting + - // Cast is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +241 | int128 d128 = int128(c128); + | ------------ + | + = note: Consider disabling this lint if you're certain the cast is safe: + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -190 | bytes32 e = bytes32(d); - | ---------- +244 | uint128 u_safe = uint128(safePos); + | ---------------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +247 | int8 signedSmall = int8(small); + | ----------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +264 | uint152 b = uint152(base); + | ------------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +265 | uint144 c = uint144(base); + | ------------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +266 | uint136 d = uint136(base); + | ------------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +267 | uint128 e = uint128(base); + | ------------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | - = note: Consider disabling this lint only if you're certain the cast is safe: +268 | uint120 f = uint120(base); + | ------------- + | + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting + - // Cast is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +269 | uint112 g = uint112(base); + | ------------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -194 | bytes32 g = bytes32(bytes(f)); - | ----------------- +270 | uint104 h = uint104(base); + | ------------- | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +271 | uint96 i = uint96(base); + | ------------ + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +272 | uint88 j = uint88(base); + | ------------ + | + = note: Consider disabling this lint if you're certain the cast is safe: + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -206 | uint128 b = uint128(uint160(a)); - | ------------------- +279 | uint80 k = uint80(base); + | ------------ | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting + - // Cast is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +280 | uint72 l = uint72(base); + | ------------ + | + = note: Consider disabling this lint if you're certain the cast is safe: + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast -warning[unsafe-typecast]: typecasts that can truncate values should be avoided +warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -210 | uint8 d = uint8(uint160(a)); - | ----------------- +281 | uint64 m = uint64(base); + | ------------ | - = note: Consider disabling this lint only if you're certain the cast is safe: + = note: Consider disabling this lint if you're certain the cast is safe: - - // Ensure the value fits in the target type before casting + - // Cast is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +282 | uint56 n = uint56(base); + | ------------ + | + = note: Consider disabling this lint if you're certain the cast is safe: + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +283 | uint48 o = uint48(base); + | ------------ + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +284 | uint40 p = uint40(base); + | ------------ + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +285 | uint32 q = uint32(base); + | ------------ + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +286 | uint24 r = uint24(base); + | ------------ + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +287 | uint16 s = uint16(base); + | ------------ + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +288 | uint8 t = uint8(base); + | ----------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast From a541299c7ccdf9f4c149cfd47a022e4dfe4ce61a Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Tue, 29 Jul 2025 16:01:27 +0700 Subject: [PATCH 09/20] refactor --- crates/lint/src/sol/med/unsafe_typecast.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs index 3cbfbd677a02b..0e1843bf2fd34 100644 --- a/crates/lint/src/sol/med/unsafe_typecast.rs +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -62,13 +62,13 @@ fn is_unsafe_typecast_hir( /// Infers the elementary type of a source expression. /// For cast chains, returns the ultimate source type, not intermediate cast results. fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option { - use hir::{ElementaryType, ExprKind, ItemId, Lit as HirLit, Res, TypeKind}; + use hir::{ElementaryType, ItemId, Lit as HirLit, Res}; use solar_ast::LitKind; match &expr.kind { // Recursive cast: Type(val) ExprKind::Call(call_expr, args, _) => { - if let ExprKind::Type(ty) = &call_expr.kind + if let ExprKind::Type(_ty) = &call_expr.kind && args.len() == 1 && let Some(first_arg) = args.exprs().next() { From df675c867f4a39135049cf90655f3f3141c156b8 Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Tue, 29 Jul 2025 17:28:24 +0700 Subject: [PATCH 10/20] Update crates/lint/src/sol/med/unsafe_typecast.rs Co-authored-by: 0xrusowsky <90208954+0xrusowsky@users.noreply.github.com> --- crates/lint/src/sol/med/unsafe_typecast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs index 0e1843bf2fd34..d620c718a7971 100644 --- a/crates/lint/src/sol/med/unsafe_typecast.rs +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -99,7 +99,7 @@ fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option Some(ElementaryType::Bool), - // Treat number literals as wide unsigned ints (won’t trigger linter) + // Unnecessary check, as assigning literal values which cannot fit into a type throws a compiler error. LitKind::Number(_) => None, LitKind::Rational(_) => None, LitKind::Err(_) => None, From 88165725aa79b66d010cc69eeb2e14b9e8ea4b10 Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Tue, 29 Jul 2025 18:02:06 +0700 Subject: [PATCH 11/20] bet --- Cargo.toml | 1 + crates/lint/src/sol/med/unsafe_typecast.rs | 3 +- crates/lint/testdata/UnsafeTypecast.sol | 2 + crates/lint/testdata/UnsafeTypecast.stderr | 476 ++++++--------------- 4 files changed, 134 insertions(+), 348 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cb5879b1eb11f..2aa5c2a3ff5e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -353,6 +353,7 @@ jiff = "0.2" heck = "0.5" uuid = "1.17.0" flate2 = "1.1" + ## Pinned dependencies. Enabled for the workspace in crates/test-utils. # Use unicode-rs which has a smaller binary size than the default ICU4X as the IDNA backend, used diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs index 0e1843bf2fd34..2107e5018f959 100644 --- a/crates/lint/src/sol/med/unsafe_typecast.rs +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -26,8 +26,7 @@ impl<'hir> LateLintPass<'hir> for UnsafeTypecast { && let Some(first_arg) = args.exprs().next() && is_unsafe_typecast_hir(hir, first_arg, target_type) { - let suggestion = get_suggestion(); - ctx.emit_with_fix(&UNSAFE_TYPECAST, expr.span, suggestion); + ctx.emit_with_fix(&UNSAFE_TYPECAST, expr.span, get_suggestion()); } } } diff --git a/crates/lint/testdata/UnsafeTypecast.sol b/crates/lint/testdata/UnsafeTypecast.sol index 9c19c1515b221..2314ca2550865 100644 --- a/crates/lint/testdata/UnsafeTypecast.sol +++ b/crates/lint/testdata/UnsafeTypecast.sol @@ -1,3 +1,4 @@ +/// forge-lint: disable-start(mixed-case-variable) contract UnsafeTypecast { function upcastSafeUint() public pure { uint8 a = type(uint8).max; @@ -288,3 +289,4 @@ contract UnsafeTypecast { uint8 t = uint8(base); //~WARN: typecasts that can truncate values should be checked } } +/// forge-lint: disable-end(mixed-case-variable) diff --git a/crates/lint/testdata/UnsafeTypecast.stderr b/crates/lint/testdata/UnsafeTypecast.stderr index 4634d89f9ac92..f91ec0f6f40a7 100644 --- a/crates/lint/testdata/UnsafeTypecast.stderr +++ b/crates/lint/testdata/UnsafeTypecast.stderr @@ -1,223 +1,7 @@ -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -170 | uint248 a_u248 = uint248(a); - | ------ - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -171 | uint240 a_u240 = uint240(a); - | ------ - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -172 | uint224 a_u224 = uint224(a); - | ------ - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -173 | uint192 a_u192 = uint192(a); - | ------ - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -174 | uint160 a_u160 = uint160(a); - | ------ - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -175 | uint128 a_u128 = uint128(a); - | ------ - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -176 | uint64 a_u64 = uint64(a); - | ----- - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -177 | uint32 a_u32 = uint32(a); - | ----- - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -178 | uint16 a_u16 = uint16(a); - | ----- - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -179 | uint8 a_u8 = uint8(a); - | ---- - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -182 | int248 i_i248 = int248(i); - | ------ - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -183 | int240 i_i240 = int240(i); - | ------ - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -184 | int224 i_i224 = int224(i); - | ------ - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -185 | int192 i_i192 = int192(i); - | ------ - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -186 | int160 i_i160 = int160(i); - | ------ - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -187 | int128 i_i128 = int128(i); - | ------ - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -188 | int64 i_i64 = int64(i); - | ----- - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -189 | int32 i_i32 = int32(i); - | ----- - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -190 | int16 i_i16 = int16(i); - | ----- - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -191 | int8 i_i8 = int8(i); - | ---- - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -198 | uint128 s_u128 = 1234; - | ------ - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -199 | uint256 s_u256 = uint256(s_u128); // Safe - | ------ - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -201 | int128 s_i128 = -1234; - | ------ - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -202 | int256 s_i256 = int256(s_i128); // Safe - | ------ - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -204 | uint256 s_u256_copy = uint256(a); - | ----------- - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -205 | int256 s_i256_copy = int256(i); - | ----------- - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - -note[mixed-case-variable]: mutable variables should use mixedCase - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -244 | uint128 u_safe = uint128(safePos); - | ------ - | - = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable - warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -74 | uint248 b = uint248(a); +75 | uint248 b = uint248(a); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -230,7 +14,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -75 | uint240 c = uint240(b); +76 | uint240 c = uint240(b); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -243,7 +27,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -76 | uint232 d = uint232(c); +77 | uint232 d = uint232(c); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -256,7 +40,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -77 | uint224 e = uint224(d); +78 | uint224 e = uint224(d); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -269,7 +53,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -78 | uint216 f = uint216(e); +79 | uint216 f = uint216(e); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -282,7 +66,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -79 | uint208 g = uint208(f); +80 | uint208 g = uint208(f); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -295,7 +79,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -80 | uint200 h = uint200(g); +81 | uint200 h = uint200(g); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -308,7 +92,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -81 | uint192 i = uint192(h); +82 | uint192 i = uint192(h); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -321,7 +105,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -82 | uint184 j = uint184(i); +83 | uint184 j = uint184(i); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -334,7 +118,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -83 | uint176 k = uint176(j); +84 | uint176 k = uint176(j); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -347,7 +131,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -84 | uint168 l = uint168(k); +85 | uint168 l = uint168(k); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -360,7 +144,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -85 | uint160 m = uint160(l); +86 | uint160 m = uint160(l); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -373,7 +157,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -86 | uint152 n = uint152(m); +87 | uint152 n = uint152(m); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -386,7 +170,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -87 | uint144 o = uint144(n); +88 | uint144 o = uint144(n); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -399,7 +183,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -88 | uint136 p = uint136(o); +89 | uint136 p = uint136(o); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -412,7 +196,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -89 | uint128 q = uint128(p); +90 | uint128 q = uint128(p); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -425,7 +209,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -90 | uint120 r = uint120(q); +91 | uint120 r = uint120(q); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -438,7 +222,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -91 | uint112 s = uint112(r); +92 | uint112 s = uint112(r); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -451,7 +235,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -92 | uint104 t = uint104(s); +93 | uint104 t = uint104(s); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -464,7 +248,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -93 | uint96 u = uint96(t); +94 | uint96 u = uint96(t); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -477,7 +261,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -94 | uint88 v = uint88(u); +95 | uint88 v = uint88(u); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -490,7 +274,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -95 | uint80 w = uint80(v); +96 | uint80 w = uint80(v); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -503,7 +287,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -96 | uint72 x = uint72(w); +97 | uint72 x = uint72(w); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -516,7 +300,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -97 | uint64 y = uint64(x); +98 | uint64 y = uint64(x); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -529,7 +313,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -98 | uint56 z = uint56(y); +99 | uint56 z = uint56(y); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -540,22 +324,22 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -99 | uint48 A = uint48(z); - | --------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +100 | uint48 A = uint48(z); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + - // Cast is safe because [explain why] + - // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -100 | uint40 B = uint40(A); +101 | uint40 B = uint40(A); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -568,7 +352,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -101 | uint32 C = uint32(B); +102 | uint32 C = uint32(B); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -581,7 +365,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -102 | uint24 D = uint24(C); +103 | uint24 D = uint24(C); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -594,7 +378,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -103 | uint16 E = uint16(D); +104 | uint16 E = uint16(D); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -607,7 +391,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -104 | uint8 F = uint8(E); +105 | uint8 F = uint8(E); | -------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -620,7 +404,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -109 | int248 b = int248(a); +110 | int248 b = int248(a); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -633,7 +417,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -110 | int240 c = int240(b); +111 | int240 c = int240(b); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -646,7 +430,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -111 | int232 d = int232(c); +112 | int232 d = int232(c); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -659,7 +443,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -112 | int224 e = int224(d); +113 | int224 e = int224(d); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -672,7 +456,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -113 | int216 f = int216(e); +114 | int216 f = int216(e); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -685,7 +469,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -114 | int208 g = int208(f); +115 | int208 g = int208(f); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -698,7 +482,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -115 | int200 h = int200(g); +116 | int200 h = int200(g); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -711,7 +495,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -116 | int192 i = int192(h); +117 | int192 i = int192(h); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -724,7 +508,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -117 | int184 j = int184(i); +118 | int184 j = int184(i); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -737,7 +521,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -118 | int176 k = int176(j); +119 | int176 k = int176(j); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -750,7 +534,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -119 | int168 l = int168(k); +120 | int168 l = int168(k); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -763,7 +547,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -120 | int160 m = int160(l); +121 | int160 m = int160(l); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -776,7 +560,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -121 | int152 n = int152(m); +122 | int152 n = int152(m); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -789,7 +573,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -122 | int144 o = int144(n); +123 | int144 o = int144(n); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -802,7 +586,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -123 | int136 p = int136(o); +124 | int136 p = int136(o); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -815,7 +599,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -124 | int128 q = int128(p); +125 | int128 q = int128(p); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -828,7 +612,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -125 | int120 r = int120(q); +126 | int120 r = int120(q); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -841,7 +625,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -126 | int112 s = int112(r); +127 | int112 s = int112(r); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -854,7 +638,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -127 | int104 t = int104(s); +128 | int104 t = int104(s); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -867,7 +651,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -128 | int96 u = int96(t); +129 | int96 u = int96(t); | -------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -880,7 +664,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -129 | int88 v = int88(u); +130 | int88 v = int88(u); | -------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -893,7 +677,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -130 | int80 w = int80(v); +131 | int80 w = int80(v); | -------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -906,7 +690,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -131 | int72 x = int72(w); +132 | int72 x = int72(w); | -------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -919,7 +703,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -132 | int64 y = int64(x); +133 | int64 y = int64(x); | -------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -932,7 +716,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -133 | int56 z = int56(y); +134 | int56 z = int56(y); | -------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -945,7 +729,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -134 | int48 A = int48(z); +135 | int48 A = int48(z); | -------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -958,7 +742,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -135 | int40 B = int40(A); +136 | int40 B = int40(A); | -------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -971,7 +755,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -136 | int32 C = int32(B); +137 | int32 C = int32(B); | -------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -984,7 +768,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -137 | int24 D = int24(C); +138 | int24 D = int24(C); | -------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -997,7 +781,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -138 | int16 E = int16(D); +139 | int16 E = int16(D); | -------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1010,7 +794,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -139 | int8 F = int8(E); +140 | int8 F = int8(E); | ------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1023,7 +807,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -170 | uint248 a_u248 = uint248(a); +171 | uint248 a_u248 = uint248(a); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1036,7 +820,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -171 | uint240 a_u240 = uint240(a); +172 | uint240 a_u240 = uint240(a); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1049,7 +833,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -172 | uint224 a_u224 = uint224(a); +173 | uint224 a_u224 = uint224(a); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1062,7 +846,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -173 | uint192 a_u192 = uint192(a); +174 | uint192 a_u192 = uint192(a); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1075,7 +859,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -174 | uint160 a_u160 = uint160(a); +175 | uint160 a_u160 = uint160(a); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1088,7 +872,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -175 | uint128 a_u128 = uint128(a); +176 | uint128 a_u128 = uint128(a); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1101,7 +885,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -176 | uint64 a_u64 = uint64(a); +177 | uint64 a_u64 = uint64(a); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1114,7 +898,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -177 | uint32 a_u32 = uint32(a); +178 | uint32 a_u32 = uint32(a); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1127,7 +911,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -178 | uint16 a_u16 = uint16(a); +179 | uint16 a_u16 = uint16(a); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1140,7 +924,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -179 | uint8 a_u8 = uint8(a); +180 | uint8 a_u8 = uint8(a); | -------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1153,7 +937,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -182 | int248 i_i248 = int248(i); +183 | int248 i_i248 = int248(i); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1166,7 +950,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -183 | int240 i_i240 = int240(i); +184 | int240 i_i240 = int240(i); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1179,7 +963,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -184 | int224 i_i224 = int224(i); +185 | int224 i_i224 = int224(i); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1192,7 +976,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -185 | int192 i_i192 = int192(i); +186 | int192 i_i192 = int192(i); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1205,7 +989,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -186 | int160 i_i160 = int160(i); +187 | int160 i_i160 = int160(i); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1218,7 +1002,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -187 | int128 i_i128 = int128(i); +188 | int128 i_i128 = int128(i); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1231,7 +1015,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -188 | int64 i_i64 = int64(i); +189 | int64 i_i64 = int64(i); | -------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1244,7 +1028,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -189 | int32 i_i32 = int32(i); +190 | int32 i_i32 = int32(i); | -------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1257,7 +1041,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -190 | int16 i_i16 = int16(i); +191 | int16 i_i16 = int16(i); | -------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1270,7 +1054,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -191 | int8 i_i8 = int8(i); +192 | int8 i_i8 = int8(i); | ------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1283,7 +1067,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -211 | bytes31 b = bytes31(a); +212 | bytes31 b = bytes31(a); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1296,7 +1080,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -212 | bytes30 c = bytes30(b); +213 | bytes30 c = bytes30(b); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1309,7 +1093,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -213 | bytes28 d = bytes28(c); +214 | bytes28 d = bytes28(c); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1322,7 +1106,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -214 | bytes24 e = bytes24(d); +215 | bytes24 e = bytes24(d); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1335,7 +1119,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -215 | bytes20 f = bytes20(e); +216 | bytes20 f = bytes20(e); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1348,7 +1132,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -216 | bytes16 g = bytes16(f); +217 | bytes16 g = bytes16(f); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1361,7 +1145,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -217 | bytes12 h = bytes12(g); +218 | bytes12 h = bytes12(g); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1374,7 +1158,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -218 | bytes8 i = bytes8(h); +219 | bytes8 i = bytes8(h); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1387,7 +1171,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -219 | bytes4 j = bytes4(i); +220 | bytes4 j = bytes4(i); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1400,7 +1184,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -220 | bytes2 k = bytes2(j); +221 | bytes2 k = bytes2(j); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1413,7 +1197,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -221 | bytes1 l = bytes1(k); +222 | bytes1 l = bytes1(k); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1426,7 +1210,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -224 | bytes32 fromDyn = bytes32(dyn); +225 | bytes32 fromDyn = bytes32(dyn); | ------------ | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1439,7 +1223,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -227 | bytes32 fromStr = bytes32(bytes(s)); +228 | bytes32 fromStr = bytes32(bytes(s)); | ----------------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1452,7 +1236,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -232 | uint256 b = uint256(a); +233 | uint256 b = uint256(a); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1465,7 +1249,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -235 | uint128 b128 = uint128(a128); +236 | uint128 b128 = uint128(a128); | ------------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1478,7 +1262,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -238 | int256 d = int256(c); +239 | int256 d = int256(c); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1491,7 +1275,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -241 | int128 d128 = int128(c128); +242 | int128 d128 = int128(c128); | ------------ | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1504,7 +1288,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -244 | uint128 u_safe = uint128(safePos); +245 | uint128 u_safe = uint128(safePos); | ---------------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1517,7 +1301,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -247 | int8 signedSmall = int8(small); +248 | int8 signedSmall = int8(small); | ----------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1530,7 +1314,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -264 | uint152 b = uint152(base); +265 | uint152 b = uint152(base); | ------------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1543,7 +1327,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -265 | uint144 c = uint144(base); +266 | uint144 c = uint144(base); | ------------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1556,7 +1340,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -266 | uint136 d = uint136(base); +267 | uint136 d = uint136(base); | ------------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1569,7 +1353,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -267 | uint128 e = uint128(base); +268 | uint128 e = uint128(base); | ------------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1582,7 +1366,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -268 | uint120 f = uint120(base); +269 | uint120 f = uint120(base); | ------------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1595,7 +1379,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -269 | uint112 g = uint112(base); +270 | uint112 g = uint112(base); | ------------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1608,7 +1392,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -270 | uint104 h = uint104(base); +271 | uint104 h = uint104(base); | ------------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1621,7 +1405,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -271 | uint96 i = uint96(base); +272 | uint96 i = uint96(base); | ------------ | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1634,7 +1418,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -272 | uint88 j = uint88(base); +273 | uint88 j = uint88(base); | ------------ | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1647,7 +1431,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -279 | uint80 k = uint80(base); +280 | uint80 k = uint80(base); | ------------ | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1660,7 +1444,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -280 | uint72 l = uint72(base); +281 | uint72 l = uint72(base); | ------------ | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1673,7 +1457,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -281 | uint64 m = uint64(base); +282 | uint64 m = uint64(base); | ------------ | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1686,7 +1470,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -282 | uint56 n = uint56(base); +283 | uint56 n = uint56(base); | ------------ | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1699,7 +1483,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -283 | uint48 o = uint48(base); +284 | uint48 o = uint48(base); | ------------ | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1712,7 +1496,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -284 | uint40 p = uint40(base); +285 | uint40 p = uint40(base); | ------------ | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1725,7 +1509,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -285 | uint32 q = uint32(base); +286 | uint32 q = uint32(base); | ------------ | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1738,7 +1522,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -286 | uint24 r = uint24(base); +287 | uint24 r = uint24(base); | ------------ | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1751,7 +1535,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -287 | uint16 s = uint16(base); +288 | uint16 s = uint16(base); | ------------ | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1764,7 +1548,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -288 | uint8 t = uint8(base); +289 | uint8 t = uint8(base); | ----------- | = note: Consider disabling this lint if you're certain the cast is safe: From 4883cba5d15856f5c8e5ec0d3e9a8e3788756567 Mon Sep 17 00:00:00 2001 From: 0xrusowsky <0xrusowsky@proton.me> Date: Tue, 29 Jul 2025 15:27:09 +0200 Subject: [PATCH 12/20] fix: bless files + nits --- crates/lint/src/sol/med/unsafe_typecast.rs | 28 +- crates/lint/testdata/UnsafeTypecast.stderr | 480 ++++++++++----------- 2 files changed, 252 insertions(+), 256 deletions(-) diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs index 07d9fd6bbd50b..d73742f42fd28 100644 --- a/crates/lint/src/sol/med/unsafe_typecast.rs +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -26,19 +26,18 @@ impl<'hir> LateLintPass<'hir> for UnsafeTypecast { && let Some(first_arg) = args.exprs().next() && is_unsafe_typecast_hir(hir, first_arg, target_type) { - ctx.emit_with_fix(&UNSAFE_TYPECAST, expr.span, get_suggestion()); + ctx.emit_with_fix( + &UNSAFE_TYPECAST, + expr.span, + Snippet::Block { + desc: Some("Consider disabling this lint if you're certain the cast is safe:"), + code: "// Cast is safe because [explain why]\n// forge-lint: disable-next-line(unsafe-typecast)".into() + } + ); } } } -// Returns the suggested fix based on the unsafe typecast expression -fn get_suggestion() -> Snippet { - Snippet::Block { - desc: Some("Consider disabling this lint if you're certain the cast is safe:"), - code: "// Cast is safe because [explain why]\n// forge-lint: disable-next-line(unsafe-typecast)".to_string(), - } -} - /// Checks if a typecast from the source expression to target type is unsafe. fn is_unsafe_typecast_hir( hir: &hir::Hir<'_>, @@ -93,18 +92,15 @@ fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option Some(ElementaryType::Address(false)), - LitKind::Bool(_) => Some(ElementaryType::Bool), - // Unnecessary check, as assigning literal values which cannot fit into a type throws a compiler error. - LitKind::Number(_) => None, - LitKind::Rational(_) => None, - LitKind::Err(_) => None, + // Unnecessary to check numbers as assigning literal values which cannot fit into a type + // throws a compiler error. Reference: + _ => None, }, - // Unary operations (e.g. -x) + // Unary operations ExprKind::Unary(op, inner_expr) => match op.kind { solar_ast::UnOpKind::Neg => match infer_source_type(hir, inner_expr) { Some(ElementaryType::UInt(size)) => Some(ElementaryType::Int(size)), diff --git a/crates/lint/testdata/UnsafeTypecast.stderr b/crates/lint/testdata/UnsafeTypecast.stderr index f91ec0f6f40a7..e25c1bb24cc34 100644 --- a/crates/lint/testdata/UnsafeTypecast.stderr +++ b/crates/lint/testdata/UnsafeTypecast.stderr @@ -6,8 +6,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -19,8 +19,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -32,8 +32,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -45,8 +45,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -58,8 +58,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -71,8 +71,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -84,8 +84,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -97,8 +97,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -110,8 +110,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -123,8 +123,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -136,8 +136,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -149,8 +149,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -162,8 +162,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -175,8 +175,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -188,8 +188,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -201,8 +201,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -214,8 +214,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -227,8 +227,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -240,8 +240,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -253,8 +253,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -266,8 +266,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -279,8 +279,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -292,8 +292,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -305,8 +305,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -318,8 +318,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -331,8 +331,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -344,8 +344,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -357,8 +357,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -370,8 +370,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -383,8 +383,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -396,8 +396,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -409,8 +409,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -422,8 +422,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -435,8 +435,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -448,8 +448,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -461,8 +461,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -474,8 +474,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -487,8 +487,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -500,8 +500,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -513,8 +513,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -526,8 +526,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -539,8 +539,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -552,8 +552,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -565,8 +565,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -578,8 +578,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -591,8 +591,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -604,8 +604,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -617,8 +617,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -630,8 +630,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -643,8 +643,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -656,8 +656,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -669,8 +669,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -682,8 +682,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -695,8 +695,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -708,8 +708,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -721,8 +721,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -734,8 +734,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -747,8 +747,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -760,8 +760,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -773,8 +773,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -786,8 +786,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -799,8 +799,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -812,8 +812,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -825,8 +825,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -838,8 +838,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -851,8 +851,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -864,8 +864,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -877,8 +877,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -890,8 +890,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -903,8 +903,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -916,8 +916,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -929,8 +929,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -942,8 +942,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -955,8 +955,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -968,8 +968,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -981,8 +981,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -994,8 +994,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1007,8 +1007,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1020,8 +1020,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1033,8 +1033,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1046,8 +1046,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1059,8 +1059,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1072,8 +1072,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1085,8 +1085,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1098,8 +1098,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1111,8 +1111,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1124,8 +1124,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1137,8 +1137,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1150,8 +1150,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1163,8 +1163,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1176,8 +1176,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1189,8 +1189,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1202,8 +1202,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1215,8 +1215,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1228,8 +1228,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1241,8 +1241,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1254,8 +1254,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1267,8 +1267,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1280,8 +1280,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1293,8 +1293,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1306,8 +1306,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1319,8 +1319,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1332,8 +1332,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1345,8 +1345,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1358,8 +1358,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1371,8 +1371,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1384,8 +1384,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1397,8 +1397,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1410,8 +1410,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1423,8 +1423,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1436,8 +1436,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1449,8 +1449,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1462,8 +1462,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1475,8 +1475,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1488,8 +1488,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1501,8 +1501,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1514,8 +1514,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1527,8 +1527,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1540,8 +1540,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1553,8 +1553,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - - // Cast is safe because [explain why] - - // forge-lint: disable-next-line(unsafe-typecast) + // Cast is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast From f20127ba9654cd46293554ee2438d94acb3b3bdc Mon Sep 17 00:00:00 2001 From: 0xrusowsky <0xrusowsky@proton.me> Date: Wed, 30 Jul 2025 08:10:58 +0200 Subject: [PATCH 13/20] fix: infer_source_type for string literals --- crates/lint/src/sol/med/unsafe_typecast.rs | 8 +++----- crates/lint/testdata/UnsafeTypecast.sol | 4 ++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs index d73742f42fd28..033a32126645f 100644 --- a/crates/lint/src/sol/med/unsafe_typecast.rs +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -87,11 +87,9 @@ fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option match kind { - LitKind::Str(_, bytes, _) => { - let byte_len = bytes.len().try_into().unwrap(); - Some(ElementaryType::FixedBytes(solar_ast::TypeSize::new_fb_bytes(byte_len))) - } + ExprKind::Lit(hir::Lit { kind, .. }) => match kind { + LitKind::Str(StrKind::Hex, ..) => Some(ElementaryType::Bytes), + LitKind::Str(..) => Some(ElementaryType::String), LitKind::Address(_) => Some(ElementaryType::Address(false)), LitKind::Bool(_) => Some(ElementaryType::Bool), diff --git a/crates/lint/testdata/UnsafeTypecast.sol b/crates/lint/testdata/UnsafeTypecast.sol index 2314ca2550865..5174d08cdeae6 100644 --- a/crates/lint/testdata/UnsafeTypecast.sol +++ b/crates/lint/testdata/UnsafeTypecast.sol @@ -288,5 +288,9 @@ contract UnsafeTypecast { uint16 s = uint16(base); //~WARN: typecasts that can truncate values should be checked uint8 t = uint8(base); //~WARN: typecasts that can truncate values should be checked } + + function repro() public pure { + bytes memory stringToBytes = bytes("Initializable: contract is already initialized"); + } } /// forge-lint: disable-end(mixed-case-variable) From 30ee511e8becba11acbf478e9515763e613e81e0 Mon Sep 17 00:00:00 2001 From: 0xrusowsky <0xrusowsky@proton.me> Date: Wed, 30 Jul 2025 08:11:23 +0200 Subject: [PATCH 14/20] style: standardize imports --- crates/lint/src/sol/med/unsafe_typecast.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs index 033a32126645f..6cde2a49b13db 100644 --- a/crates/lint/src/sol/med/unsafe_typecast.rs +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -3,7 +3,8 @@ use crate::{ linter::{LateLintPass, LintContext, Snippet}, sol::{Severity, SolLint}, }; -use solar_sema::hir::{self, ExprKind, TypeKind}; +use solar_ast::{LitKind, StrKind}; +use solar_sema::hir::{self, ElementaryType, ExprKind, ItemId, Res, TypeKind}; declare_forge_lint!( UNSAFE_TYPECAST, @@ -59,10 +60,7 @@ fn is_unsafe_typecast_hir( /// Infers the elementary type of a source expression. /// For cast chains, returns the ultimate source type, not intermediate cast results. -fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option { - use hir::{ElementaryType, ItemId, Lit as HirLit, Res}; - use solar_ast::LitKind; - +fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option { match &expr.kind { // Recursive cast: Type(val) ExprKind::Call(call_expr, args, _) => { @@ -114,11 +112,9 @@ fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option bool { - use hir::ElementaryType; - match (source_type, target_type) { // Numeric downcasts (smaller target size) (ElementaryType::UInt(source_size), ElementaryType::UInt(target_size)) From 84f8f1b85fb01988683f49c276ed3aed69cdae8a Mon Sep 17 00:00:00 2001 From: 0xrusowsky <0xrusowsky@proton.me> Date: Wed, 30 Jul 2025 08:26:31 +0200 Subject: [PATCH 15/20] nit: improve lint msg --- crates/lint/src/sol/med/unsafe_typecast.rs | 22 +- crates/lint/testdata/UnsafeTypecast.stderr | 240 ++++++++++----------- 2 files changed, 130 insertions(+), 132 deletions(-) diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs index 6cde2a49b13db..5ae342cd00499 100644 --- a/crates/lint/src/sol/med/unsafe_typecast.rs +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -21,18 +21,21 @@ impl<'hir> LateLintPass<'hir> for UnsafeTypecast { expr: &'hir hir::Expr<'hir>, ) { // Check for type cast expressions: Type(value) - if let ExprKind::Call(call_expr, args, _) = &expr.kind - && let ExprKind::Type(target_type) = &call_expr.kind + if let ExprKind::Call(call, args, _) = &expr.kind + && let ExprKind::Type(hir::Type { kind: TypeKind::Elementary(ty), .. }) = &call.kind && args.len() == 1 - && let Some(first_arg) = args.exprs().next() - && is_unsafe_typecast_hir(hir, first_arg, target_type) + && let Some(call_arg) = args.exprs().next() + && is_unsafe_typecast_hir(hir, call_arg, ty) { ctx.emit_with_fix( &UNSAFE_TYPECAST, expr.span, Snippet::Block { desc: Some("Consider disabling this lint if you're certain the cast is safe:"), - code: "// Cast is safe because [explain why]\n// forge-lint: disable-next-line(unsafe-typecast)".into() + code: format!( + "// casting to '{abi_ty}' is safe because [explain why]\n// forge-lint: disable-next-line(unsafe-typecast)", + abi_ty = ty.to_abi_str() + ) } ); } @@ -43,19 +46,14 @@ impl<'hir> LateLintPass<'hir> for UnsafeTypecast { fn is_unsafe_typecast_hir( hir: &hir::Hir<'_>, source_expr: &hir::Expr<'_>, - target_type: &hir::Type<'_>, + target_type: &hir::ElementaryType, ) -> bool { - // Get target elementary type - let TypeKind::Elementary(target_elem_type) = &target_type.kind else { - return false; - }; - // Determine source type from the expression let Some(source_elem_type) = infer_source_type(hir, source_expr) else { return false; }; - is_unsafe_elementary_typecast(&source_elem_type, target_elem_type) + is_unsafe_elementary_typecast(&source_elem_type, target_type) } /// Infers the elementary type of a source expression. diff --git a/crates/lint/testdata/UnsafeTypecast.stderr b/crates/lint/testdata/UnsafeTypecast.stderr index e25c1bb24cc34..5948d2f8ad4ee 100644 --- a/crates/lint/testdata/UnsafeTypecast.stderr +++ b/crates/lint/testdata/UnsafeTypecast.stderr @@ -6,7 +6,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint248' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -19,7 +19,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint240' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -32,7 +32,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint232' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -45,7 +45,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint224' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -58,7 +58,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint216' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -71,7 +71,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint208' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -84,7 +84,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint200' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -97,7 +97,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint192' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -110,7 +110,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint184' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -123,7 +123,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint176' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -136,7 +136,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint168' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -149,7 +149,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint160' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -162,7 +162,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint152' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -175,7 +175,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint144' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -188,7 +188,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint136' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -201,7 +201,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint128' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -214,7 +214,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint120' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -227,7 +227,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint112' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -240,7 +240,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint104' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -253,7 +253,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint96' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -266,7 +266,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint88' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -279,7 +279,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint80' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -292,7 +292,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint72' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -305,7 +305,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint64' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -318,7 +318,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint56' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -331,7 +331,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint48' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -344,7 +344,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint40' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -357,7 +357,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint32' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -370,7 +370,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint24' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -383,7 +383,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint16' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -396,7 +396,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint8' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -409,7 +409,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int248' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -422,7 +422,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int240' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -435,7 +435,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int232' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -448,7 +448,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int224' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -461,7 +461,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int216' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -474,7 +474,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int208' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -487,7 +487,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int200' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -500,7 +500,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int192' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -513,7 +513,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int184' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -526,7 +526,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int176' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -539,7 +539,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int168' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -552,7 +552,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int160' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -565,7 +565,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int152' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -578,7 +578,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int144' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -591,7 +591,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int136' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -604,7 +604,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int128' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -617,7 +617,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int120' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -630,7 +630,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int112' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -643,7 +643,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int104' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -656,7 +656,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int96' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -669,7 +669,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int88' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -682,7 +682,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int80' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -695,7 +695,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int72' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -708,7 +708,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int64' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -721,7 +721,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int56' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -734,7 +734,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int48' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -747,7 +747,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int40' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -760,7 +760,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int32' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -773,7 +773,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int24' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -786,7 +786,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int16' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -799,7 +799,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int8' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -812,7 +812,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint248' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -825,7 +825,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint240' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -838,7 +838,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint224' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -851,7 +851,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint192' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -864,7 +864,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint160' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -877,7 +877,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint128' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -890,7 +890,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint64' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -903,7 +903,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint32' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -916,7 +916,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint16' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -929,7 +929,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint8' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -942,7 +942,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int248' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -955,7 +955,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int240' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -968,7 +968,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int224' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -981,7 +981,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int192' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -994,7 +994,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int160' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1007,7 +1007,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int128' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1020,7 +1020,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int64' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1033,7 +1033,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int32' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1046,7 +1046,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int16' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1059,7 +1059,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int8' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1072,7 +1072,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'bytes31' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1085,7 +1085,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'bytes30' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1098,7 +1098,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'bytes28' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1111,7 +1111,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'bytes24' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1124,7 +1124,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'bytes20' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1137,7 +1137,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'bytes16' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1150,7 +1150,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'bytes12' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1163,7 +1163,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'bytes8' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1176,7 +1176,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'bytes4' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1189,7 +1189,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'bytes2' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1202,7 +1202,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'bytes1' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1215,7 +1215,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'bytes32' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1228,7 +1228,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'bytes32' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1241,7 +1241,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint256' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1254,7 +1254,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint128' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1267,7 +1267,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int256' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1280,7 +1280,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int128' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1293,7 +1293,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint128' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1306,7 +1306,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'int8' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1319,7 +1319,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint152' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1332,7 +1332,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint144' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1345,7 +1345,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint136' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1358,7 +1358,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint128' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1371,7 +1371,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint120' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1384,7 +1384,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint112' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1397,7 +1397,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint104' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1410,7 +1410,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint96' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1423,7 +1423,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint88' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1436,7 +1436,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint80' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1449,7 +1449,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint72' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1462,7 +1462,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint64' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1475,7 +1475,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint56' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1488,7 +1488,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint48' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1501,7 +1501,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint40' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1514,7 +1514,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint32' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1527,7 +1527,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint24' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1540,7 +1540,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint16' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1553,7 +1553,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked | = note: Consider disabling this lint if you're certain the cast is safe: - // Cast is safe because [explain why] + // casting to 'uint8' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast From 6fc68668920d916a55ef4c28be133a42e546c811 Mon Sep 17 00:00:00 2001 From: 0xrusowsky <0xrusowsky@proton.me> Date: Thu, 31 Jul 2025 09:13:36 +0200 Subject: [PATCH 16/20] fix: resolve call type to properly solve cast chains --- crates/lint/src/sol/med/unsafe_typecast.rs | 18 ++++++---- crates/lint/testdata/UnsafeTypecast.sol | 11 +++++- crates/lint/testdata/UnsafeTypecast.stderr | 39 ++++++++++++++++++++++ 3 files changed, 61 insertions(+), 7 deletions(-) diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs index 5ae342cd00499..ed1bc1003d418 100644 --- a/crates/lint/src/sol/med/unsafe_typecast.rs +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -60,14 +60,14 @@ fn is_unsafe_typecast_hir( /// For cast chains, returns the ultimate source type, not intermediate cast results. fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option { match &expr.kind { - // Recursive cast: Type(val) - ExprKind::Call(call_expr, args, _) => { - if let ExprKind::Type(_ty) = &call_expr.kind - && args.len() == 1 - && let Some(first_arg) = args.exprs().next() + // A type cast call: Type(val) + ExprKind::Call(call_expr, _, _) => { + if let ExprKind::Type(hir::Type { kind: TypeKind::Elementary(elem_type), .. }) = + &call_expr.kind { - return infer_source_type(hir, first_arg); + return Some(*elem_type); } + // Do not attempt to guess the type of regular calls None } @@ -104,6 +104,12 @@ fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option infer_source_type(hir, inner_expr), }, + ExprKind::Binary(lhs, _, rhs) => { + if let Some(ty) = infer_source_type(hir, lhs) { + return Some(ty); + } + infer_source_type(hir, rhs) + } _ => None, } } diff --git a/crates/lint/testdata/UnsafeTypecast.sol b/crates/lint/testdata/UnsafeTypecast.sol index 5174d08cdeae6..2fd4eb67ceab0 100644 --- a/crates/lint/testdata/UnsafeTypecast.sol +++ b/crates/lint/testdata/UnsafeTypecast.sol @@ -288,9 +288,18 @@ contract UnsafeTypecast { uint16 s = uint16(base); //~WARN: typecasts that can truncate values should be checked uint8 t = uint8(base); //~WARN: typecasts that can truncate values should be checked } +} - function repro() public pure { +contract Repros { + function longDynamicBytesDoNotPanic() public pure { bytes memory stringToBytes = bytes("Initializable: contract is already initialized"); } + + function nestedCastsAreEvaluatedAtAllDepths(uint64 a, int128 b) internal pure returns (uint64) { + return uint64(uint128(int128(uint128(a)) + b)); + //~^WARN: typecasts that can truncate values should be checked + //~^^WARN: typecasts that can truncate values should be checked + //~^^^WARN: typecasts that can truncate values should be checked + } } /// forge-lint: disable-end(mixed-case-variable) diff --git a/crates/lint/testdata/UnsafeTypecast.stderr b/crates/lint/testdata/UnsafeTypecast.stderr index 5948d2f8ad4ee..d826de8f682b0 100644 --- a/crates/lint/testdata/UnsafeTypecast.stderr +++ b/crates/lint/testdata/UnsafeTypecast.stderr @@ -1558,3 +1558,42 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +299 | return uint64(uint128(int128(uint128(a)) + b)); + | --------------------------------------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint64' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +299 | return uint64(uint128(int128(uint128(a)) + b)); + | ------------------------------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint128' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +299 | return uint64(uint128(int128(uint128(a)) + b)); + | ------------------ + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int128' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + From 230e76280aa9a0fe57a22dffbcf725d70fa04ebe Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Sun, 10 Aug 2025 15:25:29 +0700 Subject: [PATCH 17/20] fix false positive --- crates/lint/src/sol/med/unsafe_typecast.rs | 23 +- crates/lint/testdata/UnsafeTypecast.sol | 466 ++++-- crates/lint/testdata/UnsafeTypecast.stderr | 1674 +++++++++++++------- 3 files changed, 1407 insertions(+), 756 deletions(-) diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs index ed1bc1003d418..a89cc131a6c18 100644 --- a/crates/lint/src/sol/med/unsafe_typecast.rs +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -42,17 +42,33 @@ impl<'hir> LateLintPass<'hir> for UnsafeTypecast { } } -/// Checks if a typecast from the source expression to target type is unsafe. fn is_unsafe_typecast_hir( hir: &hir::Hir<'_>, source_expr: &hir::Expr<'_>, target_type: &hir::ElementaryType, ) -> bool { - // Determine source type from the expression let Some(source_elem_type) = infer_source_type(hir, source_expr) else { return false; }; + if let ElementaryType::Int(tgt_size) = target_type { + if let ExprKind::Call(call_expr, args, _) = &source_expr.kind { + if let ExprKind::Type(hir::Type { + kind: TypeKind::Elementary(ElementaryType::UInt(src_bits)), + .. + }) = &call_expr.kind + { + if let Some(inner) = args.exprs().next() { + if let Some(ElementaryType::UInt(orig_bits)) = infer_source_type(hir, inner) { + if orig_bits.bits() < tgt_size.bits() { + return false; + } + } + } + } + } + } + is_unsafe_elementary_typecast(&source_elem_type, target_type) } @@ -61,13 +77,12 @@ fn is_unsafe_typecast_hir( fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option { match &expr.kind { // A type cast call: Type(val) - ExprKind::Call(call_expr, _, _) => { + ExprKind::Call(call_expr, args, _) => { if let ExprKind::Type(hir::Type { kind: TypeKind::Elementary(elem_type), .. }) = &call_expr.kind { return Some(*elem_type); } - // Do not attempt to guess the type of regular calls None } diff --git a/crates/lint/testdata/UnsafeTypecast.sol b/crates/lint/testdata/UnsafeTypecast.sol index 2fd4eb67ceab0..705a5d70d6060 100644 --- a/crates/lint/testdata/UnsafeTypecast.sol +++ b/crates/lint/testdata/UnsafeTypecast.sol @@ -1,5 +1,6 @@ /// forge-lint: disable-start(mixed-case-variable) contract UnsafeTypecast { + // Unsigned upcasts are always safe. function upcastSafeUint() public pure { uint8 a = type(uint8).max; uint16 b = uint16(a); @@ -35,6 +36,7 @@ contract UnsafeTypecast { uint256 F = uint256(E); } + // Signed upcasts are safe. function upcastSafeInt() public pure { int8 a = type(int8).max; int16 b = int16(a); @@ -70,6 +72,120 @@ contract UnsafeTypecast { int256 F = int256(E); } + function upcastSafeBytes() public pure { + bytes1 a = 0xFF; + bytes2 b = bytes2(a); + bytes3 c = bytes3(b); + bytes4 d = bytes4(c); + bytes5 e = bytes5(d); + bytes6 f = bytes6(e); + bytes7 g = bytes7(f); + bytes8 h = bytes8(g); + bytes9 i = bytes9(h); + bytes10 j = bytes10(i); + bytes11 k = bytes11(j); + bytes12 l = bytes12(k); + bytes13 m = bytes13(l); + bytes14 n = bytes14(m); + bytes15 o = bytes15(n); + bytes16 p = bytes16(o); + bytes17 q = bytes17(p); + bytes18 r = bytes18(q); + bytes19 s = bytes19(r); + bytes20 t = bytes20(s); + bytes21 u = bytes21(t); + bytes22 v = bytes22(u); + bytes23 w = bytes23(v); + bytes24 x = bytes24(w); + bytes25 y = bytes25(x); + bytes26 z = bytes26(y); + bytes27 A = bytes27(z); + bytes28 B = bytes28(A); + bytes29 C = bytes29(B); + bytes30 D = bytes30(C); + bytes31 E = bytes31(D); + bytes32 F = bytes32(E); + } + + function safeSizeUint() public pure { + uint256(type(uint256).max); + uint248(type(uint248).max); + uint240(type(uint240).max); + uint232(type(uint232).max); + uint224(type(uint224).max); + uint216(type(uint216).max); + uint208(type(uint208).max); + uint200(type(uint200).max); + uint192(type(uint192).max); + uint184(type(uint184).max); + uint176(type(uint176).max); + uint168(type(uint168).max); + uint160(type(uint160).max); + uint152(type(uint152).max); + uint144(type(uint144).max); + uint136(type(uint136).max); + uint128(type(uint128).max); + uint120(type(uint120).max); + uint112(type(uint112).max); + uint104(type(uint104).max); + uint96(type(uint96).max); + uint88(type(uint88).max); + uint80(type(uint80).max); + uint72(type(uint72).max); + uint64(type(uint64).max); + uint56(type(uint56).max); + uint48(type(uint48).max); + uint40(type(uint40).max); + uint32(type(uint32).max); + uint24(type(uint24).max); + uint16(type(uint16).max); + uint8(type(uint8).max); + } + + function safeSizeInt() public pure { + int256(type(int256).max); + int248(type(int248).max); + int240(type(int240).max); + int232(type(int232).max); + int224(type(int224).max); + int216(type(int216).max); + int208(type(int208).max); + int200(type(int200).max); + int192(type(int192).max); + int184(type(int184).max); + int176(type(int176).max); + int168(type(int168).max); + int160(type(int160).max); + int152(type(int152).max); + int144(type(int144).max); + int136(type(int136).max); + int128(type(int128).max); + int120(type(int120).max); + int112(type(int112).max); + int104(type(int104).max); + int96(type(int96).max); + int88(type(int88).max); + int80(type(int80).max); + int72(type(int72).max); + int64(type(int64).max); + int56(type(int56).max); + int48(type(int48).max); + int40(type(int40).max); + int32(type(int32).max); + int24(type(int24).max); + int16(type(int16).max); + int8(type(int8).max); + } + + function sameSizeAddressSafe() public pure { + address a = 0x1234567890123456789012345678901234567890; + uint160 b = uint160(a); + bytes20 c = bytes20(a); + address d = address(a); + // The following tests, `downcastUnsafeUint` and `downcastUnsafeBytes`, verify that other downcasts + // would also throw. Additionally, the compiler prevents direct casting of addresses to smaller types. + } + function downcastUnsafeUint() public pure { uint256 a = type(uint256).max; uint248 b = uint248(a); //~WARN: typecasts that can truncate values should be checked @@ -91,18 +207,18 @@ contract UnsafeTypecast { uint120 r = uint120(q); //~WARN: typecasts that can truncate values should be checked uint112 s = uint112(r); //~WARN: typecasts that can truncate values should be checked uint104 t = uint104(s); //~WARN: typecasts that can truncate values should be checked - uint96 u = uint96(t); //~WARN: typecasts that can truncate values should be checked - uint88 v = uint88(u); //~WARN: typecasts that can truncate values should be checked - uint80 w = uint80(v); //~WARN: typecasts that can truncate values should be checked - uint72 x = uint72(w); //~WARN: typecasts that can truncate values should be checked - uint64 y = uint64(x); //~WARN: typecasts that can truncate values should be checked - uint56 z = uint56(y); //~WARN: typecasts that can truncate values should be checked - uint48 A = uint48(z); //~WARN: typecasts that can truncate values should be checked - uint40 B = uint40(A); //~WARN: typecasts that can truncate values should be checked - uint32 C = uint32(B); //~WARN: typecasts that can truncate values should be checked - uint24 D = uint24(C); //~WARN: typecasts that can truncate values should be checked - uint16 E = uint16(D); //~WARN: typecasts that can truncate values should be checked - uint8 F = uint8(E); //~WARN: typecasts that can truncate values should be checked + uint96 u = uint96(t); //~WARN: typecasts that can truncate values should be checked + uint88 v = uint88(u); //~WARN: typecasts that can truncate values should be checked + uint80 w = uint80(v); //~WARN: typecasts that can truncate values should be checked + uint72 x = uint72(w); //~WARN: typecasts that can truncate values should be checked + uint64 y = uint64(x); //~WARN: typecasts that can truncate values should be checked + uint56 z = uint56(y); //~WARN: typecasts that can truncate values should be checked + uint48 A = uint48(z); //~WARN: typecasts that can truncate values should be checked + uint40 B = uint40(A); //~WARN: typecasts that can truncate values should be checked + uint32 C = uint32(B); //~WARN: typecasts that can truncate values should be checked + uint24 D = uint24(C); //~WARN: typecasts that can truncate values should be checked + uint16 E = uint16(D); //~WARN: typecasts that can truncate values should be checked + uint8 F = uint8(E); //~WARN: typecasts that can truncate values should be checked } function downcastUnsafeInt() public pure { @@ -126,167 +242,194 @@ contract UnsafeTypecast { int120 r = int120(q); //~WARN: typecasts that can truncate values should be checked int112 s = int112(r); //~WARN: typecasts that can truncate values should be checked int104 t = int104(s); //~WARN: typecasts that can truncate values should be checked - int96 u = int96(t); //~WARN: typecasts that can truncate values should be checked - int88 v = int88(u); //~WARN: typecasts that can truncate values should be checked - int80 w = int80(v); //~WARN: typecasts that can truncate values should be checked - int72 x = int72(w); //~WARN: typecasts that can truncate values should be checked - int64 y = int64(x); //~WARN: typecasts that can truncate values should be checked - int56 z = int56(y); //~WARN: typecasts that can truncate values should be checked - int48 A = int48(z); //~WARN: typecasts that can truncate values should be checked - int40 B = int40(A); //~WARN: typecasts that can truncate values should be checked - int32 C = int32(B); //~WARN: typecasts that can truncate values should be checked - int24 D = int24(C); //~WARN: typecasts that can truncate values should be checked - int16 E = int16(D); //~WARN: typecasts that can truncate values should be checked - int8 F = int8(E); //~WARN: typecasts that can truncate values should be checked - } - - function upcastSafeBytes() public pure { - bytes1 a = 0x12; - bytes2 b = bytes2(a); - bytes4 c = bytes4(b); - bytes8 d = bytes8(c); - bytes16 e = bytes16(d); - bytes24 f = bytes24(e); - bytes28 g = bytes28(f); - bytes30 h = bytes30(g); - bytes31 i = bytes31(h); - bytes32 j = bytes32(i); - - // Safe: same size copies - bytes1 aa = bytes1(a); - bytes2 bb = bytes2(b); - bytes4 cc = bytes4(c); - bytes8 dd = bytes8(d); - bytes16 ee = bytes16(e); - bytes24 ff = bytes24(f); - bytes28 gg = bytes28(g); - bytes30 hh = bytes30(h); - bytes31 ii = bytes31(i); - bytes32 jj = bytes32(j); - } - - function numericDowncastsUnsafe() public pure { - uint256 a = 2**255 + 1000; - - uint248 a_u248 = uint248(a); //~WARN: typecasts that can truncate values should be checked - uint240 a_u240 = uint240(a); //~WARN: typecasts that can truncate values should be checked - uint224 a_u224 = uint224(a); //~WARN: typecasts that can truncate values should be checked - uint192 a_u192 = uint192(a); //~WARN: typecasts that can truncate values should be checked - uint160 a_u160 = uint160(a); //~WARN: typecasts that can truncate values should be checked - uint128 a_u128 = uint128(a); //~WARN: typecasts that can truncate values should be checked - uint64 a_u64 = uint64(a); //~WARN: typecasts that can truncate values should be checked - uint32 a_u32 = uint32(a); //~WARN: typecasts that can truncate values should be checked - uint16 a_u16 = uint16(a); //~WARN: typecasts that can truncate values should be checked - uint8 a_u8 = uint8(a); //~WARN: typecasts that can truncate values should be checked - - int256 i = -2**255 + 1000; - int248 i_i248 = int248(i); //~WARN: typecasts that can truncate values should be checked - int240 i_i240 = int240(i); //~WARN: typecasts that can truncate values should be checked - int224 i_i224 = int224(i); //~WARN: typecasts that can truncate values should be checked - int192 i_i192 = int192(i); //~WARN: typecasts that can truncate values should be checked - int160 i_i160 = int160(i); //~WARN: typecasts that can truncate values should be checked - int128 i_i128 = int128(i); //~WARN: typecasts that can truncate values should be checked - int64 i_i64 = int64(i); //~WARN: typecasts that can truncate values should be checked - int32 i_i32 = int32(i); //~WARN: typecasts that can truncate values should be checked - int16 i_i16 = int16(i); //~WARN: typecasts that can truncate values should be checked - int8 i_i8 = int8(i); //~WARN: typecasts that can truncate values should be checked - } - - function numericUpcastsSafe() public pure { - int256 i = -2**255 + 1000; - uint256 a = 2**255 + 1000; - - uint128 s_u128 = 1234; - uint256 s_u256 = uint256(s_u128); // Safe - - int128 s_i128 = -1234; - int256 s_i256 = int256(s_i128); // Safe - - uint256 s_u256_copy = uint256(a); - int256 s_i256_copy = int256(i); + int96 u = int96(t); //~WARN: typecasts that can truncate values should be checked + int88 v = int88(u); //~WARN: typecasts that can truncate values should be checked + int80 w = int80(v); //~WARN: typecasts that can truncate values should be checked + int72 x = int72(w); //~WARN: typecasts that can truncate values should be checked + int64 y = int64(x); //~WARN: typecasts that can truncate values should be checked + int56 z = int56(y); //~WARN: typecasts that can truncate values should be checked + int48 A = int48(z); //~WARN: typecasts that can truncate values should be checked + int40 B = int40(A); //~WARN: typecasts that can truncate values should be checked + int32 C = int32(B); //~WARN: typecasts that can truncate values should be checked + int24 D = int24(C); //~WARN: typecasts that can truncate values should be checked + int16 E = int16(D); //~WARN: typecasts that can truncate values should be checked + int8 F = int8(E); //~WARN: typecasts that can truncate values should be checked } function downcastUnsafeBytes() public pure { - bytes32 a = "hello world"; - + bytes32 a = bytes32(type(uint256).max); bytes31 b = bytes31(a); //~WARN: typecasts that can truncate values should be checked bytes30 c = bytes30(b); //~WARN: typecasts that can truncate values should be checked - bytes28 d = bytes28(c); //~WARN: typecasts that can truncate values should be checked - bytes24 e = bytes24(d); //~WARN: typecasts that can truncate values should be checked - bytes20 f = bytes20(e); //~WARN: typecasts that can truncate values should be checked - bytes16 g = bytes16(f); //~WARN: typecasts that can truncate values should be checked - bytes12 h = bytes12(g); //~WARN: typecasts that can truncate values should be checked - bytes8 i = bytes8(h); //~WARN: typecasts that can truncate values should be checked - bytes4 j = bytes4(i); //~WARN: typecasts that can truncate values should be checked - bytes2 k = bytes2(j); //~WARN: typecasts that can truncate values should be checked - bytes1 l = bytes1(k); //~WARN: typecasts that can truncate values should be checked - - bytes memory dyn = "hello world"; - bytes32 fromDyn = bytes32(dyn); //~WARN: typecasts that can truncate values should be checked + bytes29 d = bytes29(c); //~WARN: typecasts that can truncate values should be checked + bytes28 e = bytes28(d); //~WARN: typecasts that can truncate values should be checked + bytes27 f = bytes27(e); //~WARN: typecasts that can truncate values should be checked + bytes26 g = bytes26(f); //~WARN: typecasts that can truncate values should be checked + bytes25 h = bytes25(g); //~WARN: typecasts that can truncate values should be checked + bytes24 i = bytes24(h); //~WARN: typecasts that can truncate values should be checked + bytes23 j = bytes23(i); //~WARN: typecasts that can truncate values should be checked + bytes22 k = bytes22(j); //~WARN: typecasts that can truncate values should be checked + bytes21 l = bytes21(k); //~WARN: typecasts that can truncate values should be checked + bytes20 m = bytes20(l); //~WARN: typecasts that can truncate values should be checked + bytes19 n = bytes19(m); //~WARN: typecasts that can truncate values should be checked + bytes18 o = bytes18(n); //~WARN: typecasts that can truncate values should be checked + bytes17 p = bytes17(o); //~WARN: typecasts that can truncate values should be checked + bytes16 q = bytes16(p); //~WARN: typecasts that can truncate values should be checked + bytes15 r = bytes15(q); //~WARN: typecasts that can truncate values should be checked + bytes14 s = bytes14(r); //~WARN: typecasts that can truncate values should be checked + bytes13 t = bytes13(s); //~WARN: typecasts that can truncate values should be checked + bytes12 u = bytes12(t); //~WARN: typecasts that can truncate values should be checked + bytes11 v = bytes11(u); //~WARN: typecasts that can truncate values should be checked + bytes10 w = bytes10(v); //~WARN: typecasts that can truncate values should be checked + bytes9 x = bytes9(w); //~WARN: typecasts that can truncate values should be checked + bytes8 y = bytes8(x); //~WARN: typecasts that can truncate values should be checked + bytes7 z = bytes7(y); //~WARN: typecasts that can truncate values should be checked + bytes6 A = bytes6(z); //~WARN: typecasts that can truncate values should be checked + bytes5 B = bytes5(A); //~WARN: typecasts that can truncate values should be checked + bytes4 C = bytes4(B); //~WARN: typecasts that can truncate values should be checked + bytes3 D = bytes3(C); //~WARN: typecasts that can truncate values should be checked + bytes2 E = bytes2(D); //~WARN: typecasts that can truncate values should be checked + bytes1 F = bytes1(E); //~WARN: typecasts that can truncate values should be checked + } - string memory s = "hello world"; - bytes32 fromStr = bytes32(bytes(s)); //~WARN: typecasts that can truncate values should be checked + function unsignedSignedUnsafe() public pure { + uint256 a = type(uint256).max; + int256 b = int256(a); //~WARN: typecasts that can truncate values should be checked + uint248 c = type(uint248).max; + int248 d = int248(c); //~WARN: typecasts that can truncate values should be checked + uint240 e = type(uint240).max; + int240 f = int240(e); //~WARN: typecasts that can truncate values should be checked + uint232 g = type(uint232).max; + int232 h = int232(g); //~WARN: typecasts that can truncate values should be checked + uint224 i = type(uint224).max; + int224 j = int224(i); //~WARN: typecasts that can truncate values should be checked + uint216 k = type(uint216).max; + int216 l = int216(k); //~WARN: typecasts that can truncate values should be checked + uint208 m = type(uint208).max; + int208 n = int208(m); //~WARN: typecasts that can truncate values should be checked + uint200 o = type(uint200).max; + int200 p = int200(o); //~WARN: typecasts that can truncate values should be checked + uint192 q = type(uint192).max; + int192 r = int192(q); //~WARN: typecasts that can truncate values should be checked + uint184 s = type(uint184).max; + int184 t = int184(s); //~WARN: typecasts that can truncate values should be checked + uint176 u = type(uint176).max; + int176 v = int176(u); //~WARN: typecasts that can truncate values should be checked + uint168 w = type(uint168).max; + int168 x = int168(w); //~WARN: typecasts that can truncate values should be checked + uint160 y = type(uint160).max; + int160 z = int160(y); //~WARN: typecasts that can truncate values should be checked + uint152 A = type(uint152).max; + int152 B = int152(A); //~WARN: typecasts that can truncate values should be checked + uint144 C = type(uint144).max; + int144 D = int144(C); //~WARN: typecasts that can truncate values should be checked + uint136 E = type(uint136).max; + int136 F = int136(E); //~WARN: typecasts that can truncate values should be checked + uint128 G = type(uint128).max; + int128 H = int128(G); //~WARN: typecasts that can truncate values should be checked + uint120 I = type(uint120).max; + int120 J = int120(I); //~WARN: typecasts that can truncate values should be checked + uint112 K = type(uint112).max; + int112 L = int112(K); //~WARN: typecasts that can truncate values should be checked + uint104 M = type(uint104).max; + int104 N = int104(M); //~WARN: typecasts that can truncate values should be checked + uint96 O = type(uint96).max; + int96 P = int96(O); //~WARN: typecasts that can truncate values should be checked + uint88 Q = type(uint88).max; + int88 R = int88(Q); //~WARN: typecasts that can truncate values should be checked + uint80 S = type(uint80).max; + int80 T = int80(S); //~WARN: typecasts that can truncate values should be checked + uint72 U = type(uint72).max; + int72 V = int72(U); //~WARN: typecasts that can truncate values should be checked + uint64 W = type(uint64).max; + int64 X = int64(W); //~WARN: typecasts that can truncate values should be checked + uint56 Y = type(uint56).max; + int56 Z = int56(Y); //~WARN: typecasts that can truncate values should be checked + uint48 AA = type(uint48).max; + int48 BB = int48(AA); //~WARN: typecasts that can truncate values should be checked + uint40 CC = type(uint40).max; + int40 DD = int40(CC); //~WARN: typecasts that can truncate values should be checked + uint32 EE = type(uint32).max; + int32 FF = int32(EE); //~WARN: typecasts that can truncate values should be checked + uint24 GG = type(uint24).max; + int24 HH = int24(GG); //~WARN: typecasts that can truncate values should be checked + uint16 II = type(uint16).max; + int16 JJ = int16(II); //~WARN: typecasts that can truncate values should be checked + uint8 KK = type(uint8).max; + int8 LL = int8(KK); //~WARN: typecasts that can truncate values should be checked } - function signedUnsignedConversions() public pure { + function signedUnsignedUnsafe() public pure { int256 a = -1; uint256 b = uint256(a); //~WARN: typecasts that can truncate values should be checked - - int128 a128 = -500; - uint128 b128 = uint128(a128); //~WARN: typecasts that can truncate values should be checked - - uint256 c = type(uint256).max; - int256 d = int256(c); //~WARN: typecasts that can truncate values should be checked - - uint128 c128 = type(uint128).max; - int128 d128 = int128(c128); //~WARN: typecasts that can truncate values should be checked - - int128 safePos = 1234; - uint128 u_safe = uint128(safePos); //~WARN: typecasts that can truncate values should be checked - - uint8 small = 5; - int8 signedSmall = int8(small); //~WARN: typecasts that can truncate values should be checked - } - - function upcastSafeAddress() public pure { - address a = 0x1234567890123456789012345678901234567890; - - uint160 b = uint160(a); // Safe - uint176 c = uint176(b); // Safe - uint192 d = uint192(c); // Safe - uint224 e = uint224(d); // Safe - uint256 f = uint256(e); // Safe + int248 c = -1; + uint248 d = uint248(c); //~WARN: typecasts that can truncate values should be checked + int240 e = -1; + uint240 f = uint240(e); //~WARN: typecasts that can truncate values should be checked + int232 g = -1; + uint232 h = uint232(g); //~WARN: typecasts that can truncate values should be checked + int224 i = -1; + uint224 j = uint224(i); //~WARN: typecasts that can truncate values should be checked + int216 k = -1; + uint216 l = uint216(k); //~WARN: typecasts that can truncate values should be checked + int208 m = -1; + uint208 n = uint208(m); //~WARN: typecasts that can truncate values should be checked + int200 o = -1; + uint200 p = uint200(o); //~WARN: typecasts that can truncate values should be checked + int192 q = -1; + uint192 r = uint192(q); //~WARN: typecasts that can truncate values should be checked + int184 s = -1; + uint184 t = uint184(s); //~WARN: typecasts that can truncate values should be checked + int176 u = -1; + uint176 v = uint176(u); //~WARN: typecasts that can truncate values should be checked + int168 w = -1; + uint168 x = uint168(w); //~WARN: typecasts that can truncate values should be checked + int160 y = -1; + uint160 z = uint160(y); //~WARN: typecasts that can truncate values should be checked + int152 A = -1; + uint152 B = uint152(A); //~WARN: typecasts that can truncate values should be checked + int144 C = -1; + uint144 D = uint144(C); //~WARN: typecasts that can truncate values should be checked + int136 E = -1; + uint136 F = uint136(E); //~WARN: typecasts that can truncate values should be checked + int128 G = -1; + uint128 H = uint128(G); //~WARN: typecasts that can truncate values should be checked + int120 I = -1; + uint120 J = uint120(I); //~WARN: typecasts that can truncate values should be checked + int112 K = -1; + uint112 L = uint112(K); //~WARN: typecasts that can truncate values should be checked + int104 M = -1; + uint104 N = uint104(M); //~WARN: typecasts that can truncate values should be checked + int96 O = -1; + uint96 P = uint96(O); //~WARN: typecasts that can truncate values should be checked + int88 Q = -1; + uint88 R = uint88(Q); //~WARN: typecasts that can truncate values should be checked + int80 S = -1; + uint80 T = uint80(S); //~WARN: typecasts that can truncate values should be checked + int72 U = -1; + uint72 V = uint72(U); //~WARN: typecasts that can truncate values should be checked + int64 W = -1; + uint64 X = uint64(W); //~WARN: typecasts that can truncate values should be checked + int56 Y = -1; + uint56 Z = uint56(Y); //~WARN: typecasts that can truncate values should be checked + int48 AA = -1; + uint48 BB = uint48(AA); //~WARN: typecasts that can truncate values should be checked + int40 CC = -1; + uint40 DD = uint40(CC); //~WARN: typecasts that can truncate values should be checked + int32 EE = -1; + uint32 FF = uint32(EE); //~WARN: typecasts that can truncate values should be checked + int24 GG = -1; + uint24 HH = uint24(GG); //~WARN: typecasts that can truncate values should be checked + int16 II = -1; + uint16 JJ = uint16(II); //~WARN: typecasts that can truncate values should be checked + int8 KK = -1; + uint8 LL = uint8(KK); //~WARN: typecasts that can truncate values should be checked } - function downcastUnsafeAddress() public pure { - address a = 0x1234567890123456789012345678901234567890; - uint160 base = uint160(a); - - uint152 b = uint152(base); //~WARN: typecasts that can truncate values should be checked - uint144 c = uint144(base); //~WARN: typecasts that can truncate values should be checked - uint136 d = uint136(base); //~WARN: typecasts that can truncate values should be checked - uint128 e = uint128(base); //~WARN: typecasts that can truncate values should be checked - uint120 f = uint120(base); //~WARN: typecasts that can truncate values should be checked - uint112 g = uint112(base); //~WARN: typecasts that can truncate values should be checked - uint104 h = uint104(base); //~WARN: typecasts that can truncate values should be checked - uint96 i = uint96(base); //~WARN: typecasts that can truncate values should be checked - uint88 j = uint88(base); //~WARN: typecasts that can truncate values should be checked - } - - function downcastUnsafeAddress2() public pure { - address a = 0x1234567890123456789012345678901234567890; - uint160 base = uint160(a); - - uint80 k = uint80(base); //~WARN: typecasts that can truncate values should be checked - uint72 l = uint72(base); //~WARN: typecasts that can truncate values should be checked - uint64 m = uint64(base); //~WARN: typecasts that can truncate values should be checked - uint56 n = uint56(base); //~WARN: typecasts that can truncate values should be checked - uint48 o = uint48(base); //~WARN: typecasts that can truncate values should be checked - uint40 p = uint40(base); //~WARN: typecasts that can truncate values should be checked - uint32 q = uint32(base); //~WARN: typecasts that can truncate values should be checked - uint24 r = uint24(base); //~WARN: typecasts that can truncate values should be checked - uint16 s = uint16(base); //~WARN: typecasts that can truncate values should be checked - uint8 t = uint8(base); //~WARN: typecasts that can truncate values should be checked + function downcastDynamicUnsafe() public pure { + bytes memory data = "hello world"; + bytes32 dataSlice = bytes32(data); //~WARN: typecasts that can truncate values should be checked + string memory str = "hello world"; + bytes32 strSlice = bytes32(bytes(str)); //~WARN: typecasts that can truncate values should be checked } } @@ -299,7 +442,6 @@ contract Repros { return uint64(uint128(int128(uint128(a)) + b)); //~^WARN: typecasts that can truncate values should be checked //~^^WARN: typecasts that can truncate values should be checked - //~^^^WARN: typecasts that can truncate values should be checked } } /// forge-lint: disable-end(mixed-case-variable) diff --git a/crates/lint/testdata/UnsafeTypecast.stderr b/crates/lint/testdata/UnsafeTypecast.stderr index d826de8f682b0..ba6af8ef807ba 100644 --- a/crates/lint/testdata/UnsafeTypecast.stderr +++ b/crates/lint/testdata/UnsafeTypecast.stderr @@ -1,337 +1,558 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -75 | uint248 b = uint248(a); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint248' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -76 | uint240 c = uint240(b); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint240' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -77 | uint232 d = uint232(c); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint232' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -78 | uint224 e = uint224(d); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint224' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -79 | uint216 f = uint216(e); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint216' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -80 | uint208 g = uint208(f); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint208' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -81 | uint200 h = uint200(g); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint200' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -82 | uint192 i = uint192(h); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint192' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -83 | uint184 j = uint184(i); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint184' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -84 | uint176 k = uint176(j); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint176' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -85 | uint168 l = uint168(k); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint168' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -86 | uint160 m = uint160(l); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint160' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -87 | uint152 n = uint152(m); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint152' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -88 | uint144 o = uint144(n); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint144' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -89 | uint136 p = uint136(o); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint136' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -90 | uint128 q = uint128(p); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint128' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -91 | uint120 r = uint120(q); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint120' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -92 | uint112 s = uint112(r); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint112' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -93 | uint104 t = uint104(s); - | ---------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint104' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -94 | uint96 u = uint96(t); - | --------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint96' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -95 | uint88 v = uint88(u); - | --------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint88' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -96 | uint80 w = uint80(v); - | --------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint80' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -97 | uint72 x = uint72(w); - | --------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint72' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -98 | uint64 y = uint64(x); - | --------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint64' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -99 | uint56 z = uint56(y); - | --------- - | - = note: Consider disabling this lint if you're certain the cast is safe: - - // casting to 'uint56' is safe because [explain why] - // forge-lint: disable-next-line(unsafe-typecast) - - = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast - -warning[unsafe-typecast]: typecasts that can truncate values should be checked - --> ROOT/testdata/UnsafeTypecast.sol:LL:CC - | -100 | uint48 A = uint48(z); + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +191 | uint248 b = uint248(a); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint248' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +192 | uint240 c = uint240(b); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint240' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +193 | uint232 d = uint232(c); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint232' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +194 | uint224 e = uint224(d); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint224' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +195 | uint216 f = uint216(e); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint216' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +196 | uint208 g = uint208(f); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint208' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +197 | uint200 h = uint200(g); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint200' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +198 | uint192 i = uint192(h); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint192' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +199 | uint184 j = uint184(i); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint184' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +200 | uint176 k = uint176(j); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint176' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +201 | uint168 l = uint168(k); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint168' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +202 | uint160 m = uint160(l); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint160' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +203 | uint152 n = uint152(m); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint152' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +204 | uint144 o = uint144(n); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint144' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +205 | uint136 p = uint136(o); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint136' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +206 | uint128 q = uint128(p); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint128' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +207 | uint120 r = uint120(q); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint120' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +208 | uint112 s = uint112(r); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint112' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +209 | uint104 t = uint104(s); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint104' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +210 | uint96 u = uint96(t); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint96' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +211 | uint88 v = uint88(u); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint88' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +212 | uint80 w = uint80(v); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint80' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +213 | uint72 x = uint72(w); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint72' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +214 | uint64 y = uint64(x); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint64' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +215 | uint56 z = uint56(y); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint56' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +216 | uint48 A = uint48(z); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint48' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +217 | uint40 B = uint40(A); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint40' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +218 | uint32 C = uint32(B); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint32' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +219 | uint24 D = uint24(C); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint24' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +220 | uint16 E = uint16(D); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint16' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +221 | uint8 F = uint8(E); + | -------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint8' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +226 | int248 b = int248(a); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int248' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +227 | int240 c = int240(b); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int240' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +228 | int232 d = int232(c); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int232' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +229 | int224 e = int224(d); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int224' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +230 | int216 f = int216(e); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int216' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +231 | int208 g = int208(f); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int208' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +232 | int200 h = int200(g); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int200' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +233 | int192 i = int192(h); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int192' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +234 | int184 j = int184(i); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int184' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +235 | int176 k = int176(j); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int176' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +236 | int168 l = int168(k); + | --------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int168' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +237 | int160 m = int160(l); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint48' is safe because [explain why] + // casting to 'int160' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -339,12 +560,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -101 | uint40 B = uint40(A); +238 | int152 n = int152(m); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint40' is safe because [explain why] + // casting to 'int152' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -352,12 +573,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -102 | uint32 C = uint32(B); +239 | int144 o = int144(n); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint32' is safe because [explain why] + // casting to 'int144' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -365,12 +586,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -103 | uint24 D = uint24(C); +240 | int136 p = int136(o); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint24' is safe because [explain why] + // casting to 'int136' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -378,12 +599,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -104 | uint16 E = uint16(D); +241 | int128 q = int128(p); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint16' is safe because [explain why] + // casting to 'int128' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -391,12 +612,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -105 | uint8 F = uint8(E); - | -------- +242 | int120 r = int120(q); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint8' is safe because [explain why] + // casting to 'int120' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -404,12 +625,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -110 | int248 b = int248(a); +243 | int112 s = int112(r); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int248' is safe because [explain why] + // casting to 'int112' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -417,12 +638,272 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -111 | int240 c = int240(b); +244 | int104 t = int104(s); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int240' is safe because [explain why] + // casting to 'int104' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +245 | int96 u = int96(t); + | -------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int96' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +246 | int88 v = int88(u); + | -------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int88' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +247 | int80 w = int80(v); + | -------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int80' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +248 | int72 x = int72(w); + | -------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int72' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +249 | int64 y = int64(x); + | -------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int64' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +250 | int56 z = int56(y); + | -------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int56' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +251 | int48 A = int48(z); + | -------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int48' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +252 | int40 B = int40(A); + | -------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int40' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +253 | int32 C = int32(B); + | -------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int32' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +254 | int24 D = int24(C); + | -------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int24' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +255 | int16 E = int16(D); + | -------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int16' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +256 | int8 F = int8(E); + | ------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'int8' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +261 | bytes31 b = bytes31(a); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'bytes31' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +262 | bytes30 c = bytes30(b); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'bytes30' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +263 | bytes29 d = bytes29(c); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'bytes29' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +264 | bytes28 e = bytes28(d); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'bytes28' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +265 | bytes27 f = bytes27(e); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'bytes27' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +266 | bytes26 g = bytes26(f); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'bytes26' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +267 | bytes25 h = bytes25(g); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'bytes25' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +268 | bytes24 i = bytes24(h); + | ---------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'bytes24' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -430,12 +911,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -112 | int232 d = int232(c); - | --------- +269 | bytes23 j = bytes23(i); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int232' is safe because [explain why] + // casting to 'bytes23' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -443,12 +924,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -113 | int224 e = int224(d); - | --------- +270 | bytes22 k = bytes22(j); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int224' is safe because [explain why] + // casting to 'bytes22' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -456,12 +937,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -114 | int216 f = int216(e); - | --------- +271 | bytes21 l = bytes21(k); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int216' is safe because [explain why] + // casting to 'bytes21' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -469,12 +950,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -115 | int208 g = int208(f); - | --------- +272 | bytes20 m = bytes20(l); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int208' is safe because [explain why] + // casting to 'bytes20' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -482,12 +963,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -116 | int200 h = int200(g); - | --------- +273 | bytes19 n = bytes19(m); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int200' is safe because [explain why] + // casting to 'bytes19' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -495,12 +976,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -117 | int192 i = int192(h); - | --------- +274 | bytes18 o = bytes18(n); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int192' is safe because [explain why] + // casting to 'bytes18' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -508,12 +989,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -118 | int184 j = int184(i); - | --------- +275 | bytes17 p = bytes17(o); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int184' is safe because [explain why] + // casting to 'bytes17' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -521,12 +1002,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -119 | int176 k = int176(j); - | --------- +276 | bytes16 q = bytes16(p); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int176' is safe because [explain why] + // casting to 'bytes16' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -534,12 +1015,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -120 | int168 l = int168(k); - | --------- +277 | bytes15 r = bytes15(q); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int168' is safe because [explain why] + // casting to 'bytes15' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -547,12 +1028,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -121 | int160 m = int160(l); - | --------- +278 | bytes14 s = bytes14(r); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int160' is safe because [explain why] + // casting to 'bytes14' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -560,12 +1041,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -122 | int152 n = int152(m); - | --------- +279 | bytes13 t = bytes13(s); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int152' is safe because [explain why] + // casting to 'bytes13' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -573,12 +1054,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -123 | int144 o = int144(n); - | --------- +280 | bytes12 u = bytes12(t); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int144' is safe because [explain why] + // casting to 'bytes12' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -586,12 +1067,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -124 | int136 p = int136(o); - | --------- +281 | bytes11 v = bytes11(u); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int136' is safe because [explain why] + // casting to 'bytes11' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -599,12 +1080,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -125 | int128 q = int128(p); - | --------- +282 | bytes10 w = bytes10(v); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int128' is safe because [explain why] + // casting to 'bytes10' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -612,12 +1093,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -126 | int120 r = int120(q); +283 | bytes9 x = bytes9(w); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int120' is safe because [explain why] + // casting to 'bytes9' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -625,12 +1106,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -127 | int112 s = int112(r); +284 | bytes8 y = bytes8(x); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int112' is safe because [explain why] + // casting to 'bytes8' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -638,12 +1119,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -128 | int104 t = int104(s); +285 | bytes7 z = bytes7(y); | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int104' is safe because [explain why] + // casting to 'bytes7' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -651,12 +1132,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -129 | int96 u = int96(t); - | -------- +286 | bytes6 A = bytes6(z); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int96' is safe because [explain why] + // casting to 'bytes6' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -664,12 +1145,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -130 | int88 v = int88(u); - | -------- +287 | bytes5 B = bytes5(A); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int88' is safe because [explain why] + // casting to 'bytes5' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -677,12 +1158,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -131 | int80 w = int80(v); - | -------- +288 | bytes4 C = bytes4(B); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int80' is safe because [explain why] + // casting to 'bytes4' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -690,12 +1171,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -132 | int72 x = int72(w); - | -------- +289 | bytes3 D = bytes3(C); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int72' is safe because [explain why] + // casting to 'bytes3' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -703,12 +1184,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -133 | int64 y = int64(x); - | -------- +290 | bytes2 E = bytes2(D); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int64' is safe because [explain why] + // casting to 'bytes2' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -716,12 +1197,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -134 | int56 z = int56(y); - | -------- +291 | bytes1 F = bytes1(E); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int56' is safe because [explain why] + // casting to 'bytes1' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -729,12 +1210,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -135 | int48 A = int48(z); - | -------- +296 | int256 b = int256(a); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int48' is safe because [explain why] + // casting to 'int256' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -742,12 +1223,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -136 | int40 B = int40(A); - | -------- +298 | int248 d = int248(c); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int40' is safe because [explain why] + // casting to 'int248' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -755,12 +1236,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -137 | int32 C = int32(B); - | -------- +300 | int240 f = int240(e); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int32' is safe because [explain why] + // casting to 'int240' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -768,12 +1249,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -138 | int24 D = int24(C); - | -------- +302 | int232 h = int232(g); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int24' is safe because [explain why] + // casting to 'int232' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -781,12 +1262,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -139 | int16 E = int16(D); - | -------- +304 | int224 j = int224(i); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int16' is safe because [explain why] + // casting to 'int224' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -794,12 +1275,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -140 | int8 F = int8(E); - | ------- +306 | int216 l = int216(k); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int8' is safe because [explain why] + // casting to 'int216' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -807,12 +1288,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -171 | uint248 a_u248 = uint248(a); - | ---------- +308 | int208 n = int208(m); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint248' is safe because [explain why] + // casting to 'int208' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -820,12 +1301,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -172 | uint240 a_u240 = uint240(a); - | ---------- +310 | int200 p = int200(o); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint240' is safe because [explain why] + // casting to 'int200' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -833,12 +1314,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -173 | uint224 a_u224 = uint224(a); - | ---------- +312 | int192 r = int192(q); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint224' is safe because [explain why] + // casting to 'int192' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -846,12 +1327,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -174 | uint192 a_u192 = uint192(a); - | ---------- +314 | int184 t = int184(s); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint192' is safe because [explain why] + // casting to 'int184' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -859,12 +1340,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -175 | uint160 a_u160 = uint160(a); - | ---------- +316 | int176 v = int176(u); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint160' is safe because [explain why] + // casting to 'int176' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -872,12 +1353,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -176 | uint128 a_u128 = uint128(a); - | ---------- +318 | int168 x = int168(w); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint128' is safe because [explain why] + // casting to 'int168' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -885,12 +1366,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -177 | uint64 a_u64 = uint64(a); - | --------- +320 | int160 z = int160(y); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint64' is safe because [explain why] + // casting to 'int160' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -898,12 +1379,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -178 | uint32 a_u32 = uint32(a); - | --------- +322 | int152 B = int152(A); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint32' is safe because [explain why] + // casting to 'int152' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -911,12 +1392,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -179 | uint16 a_u16 = uint16(a); - | --------- +324 | int144 D = int144(C); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint16' is safe because [explain why] + // casting to 'int144' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -924,12 +1405,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -180 | uint8 a_u8 = uint8(a); - | -------- +326 | int136 F = int136(E); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint8' is safe because [explain why] + // casting to 'int136' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -937,12 +1418,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -183 | int248 i_i248 = int248(i); - | --------- +328 | int128 H = int128(G); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int248' is safe because [explain why] + // casting to 'int128' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -950,12 +1431,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -184 | int240 i_i240 = int240(i); - | --------- +330 | int120 J = int120(I); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int240' is safe because [explain why] + // casting to 'int120' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -963,12 +1444,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -185 | int224 i_i224 = int224(i); - | --------- +332 | int112 L = int112(K); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int224' is safe because [explain why] + // casting to 'int112' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -976,12 +1457,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -186 | int192 i_i192 = int192(i); - | --------- +334 | int104 N = int104(M); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int192' is safe because [explain why] + // casting to 'int104' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -989,12 +1470,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -187 | int160 i_i160 = int160(i); - | --------- +336 | int96 P = int96(O); + | -------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int160' is safe because [explain why] + // casting to 'int96' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1002,12 +1483,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -188 | int128 i_i128 = int128(i); - | --------- +338 | int88 R = int88(Q); + | -------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int128' is safe because [explain why] + // casting to 'int88' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1015,12 +1496,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -189 | int64 i_i64 = int64(i); - | -------- +340 | int80 T = int80(S); + | -------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int64' is safe because [explain why] + // casting to 'int80' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1028,12 +1509,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -190 | int32 i_i32 = int32(i); - | -------- +342 | int72 V = int72(U); + | -------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int32' is safe because [explain why] + // casting to 'int72' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1041,12 +1522,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -191 | int16 i_i16 = int16(i); - | -------- +344 | int64 X = int64(W); + | -------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int16' is safe because [explain why] + // casting to 'int64' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1054,12 +1535,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -192 | int8 i_i8 = int8(i); - | ------- +346 | int56 Z = int56(Y); + | -------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int8' is safe because [explain why] + // casting to 'int56' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1067,12 +1548,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -212 | bytes31 b = bytes31(a); - | ---------- +348 | int48 BB = int48(AA); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'bytes31' is safe because [explain why] + // casting to 'int48' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1080,12 +1561,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -213 | bytes30 c = bytes30(b); - | ---------- +350 | int40 DD = int40(CC); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'bytes30' is safe because [explain why] + // casting to 'int40' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1093,12 +1574,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -214 | bytes28 d = bytes28(c); - | ---------- +352 | int32 FF = int32(EE); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'bytes28' is safe because [explain why] + // casting to 'int32' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1106,12 +1587,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -215 | bytes24 e = bytes24(d); - | ---------- +354 | int24 HH = int24(GG); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'bytes24' is safe because [explain why] + // casting to 'int24' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1119,12 +1600,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -216 | bytes20 f = bytes20(e); - | ---------- +356 | int16 JJ = int16(II); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'bytes20' is safe because [explain why] + // casting to 'int16' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1132,12 +1613,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -217 | bytes16 g = bytes16(f); - | ---------- +358 | int8 LL = int8(KK); + | -------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'bytes16' is safe because [explain why] + // casting to 'int8' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1145,12 +1626,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -218 | bytes12 h = bytes12(g); +363 | uint256 b = uint256(a); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'bytes12' is safe because [explain why] + // casting to 'uint256' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1158,12 +1639,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -219 | bytes8 i = bytes8(h); - | --------- +365 | uint248 d = uint248(c); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'bytes8' is safe because [explain why] + // casting to 'uint248' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1171,12 +1652,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -220 | bytes4 j = bytes4(i); - | --------- +367 | uint240 f = uint240(e); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'bytes4' is safe because [explain why] + // casting to 'uint240' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1184,12 +1665,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -221 | bytes2 k = bytes2(j); - | --------- +369 | uint232 h = uint232(g); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'bytes2' is safe because [explain why] + // casting to 'uint232' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1197,12 +1678,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -222 | bytes1 l = bytes1(k); - | --------- +371 | uint224 j = uint224(i); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'bytes1' is safe because [explain why] + // casting to 'uint224' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1210,12 +1691,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -225 | bytes32 fromDyn = bytes32(dyn); - | ------------ +373 | uint216 l = uint216(k); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'bytes32' is safe because [explain why] + // casting to 'uint216' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1223,12 +1704,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -228 | bytes32 fromStr = bytes32(bytes(s)); - | ----------------- +375 | uint208 n = uint208(m); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'bytes32' is safe because [explain why] + // casting to 'uint208' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1236,12 +1717,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -233 | uint256 b = uint256(a); +377 | uint200 p = uint200(o); | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint256' is safe because [explain why] + // casting to 'uint200' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1249,12 +1730,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -236 | uint128 b128 = uint128(a128); - | ------------- +379 | uint192 r = uint192(q); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint128' is safe because [explain why] + // casting to 'uint192' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1262,12 +1743,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -239 | int256 d = int256(c); - | --------- +381 | uint184 t = uint184(s); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int256' is safe because [explain why] + // casting to 'uint184' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1275,12 +1756,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -242 | int128 d128 = int128(c128); - | ------------ +383 | uint176 v = uint176(u); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int128' is safe because [explain why] + // casting to 'uint176' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1288,12 +1769,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -245 | uint128 u_safe = uint128(safePos); - | ---------------- +385 | uint168 x = uint168(w); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint128' is safe because [explain why] + // casting to 'uint168' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1301,12 +1782,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -248 | int8 signedSmall = int8(small); - | ----------- +387 | uint160 z = uint160(y); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int8' is safe because [explain why] + // casting to 'uint160' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1314,8 +1795,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -265 | uint152 b = uint152(base); - | ------------- +389 | uint152 B = uint152(A); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1327,8 +1808,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -266 | uint144 c = uint144(base); - | ------------- +391 | uint144 D = uint144(C); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1340,8 +1821,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -267 | uint136 d = uint136(base); - | ------------- +393 | uint136 F = uint136(E); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1353,8 +1834,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -268 | uint128 e = uint128(base); - | ------------- +395 | uint128 H = uint128(G); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1366,8 +1847,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -269 | uint120 f = uint120(base); - | ------------- +397 | uint120 J = uint120(I); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1379,8 +1860,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -270 | uint112 g = uint112(base); - | ------------- +399 | uint112 L = uint112(K); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1392,8 +1873,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -271 | uint104 h = uint104(base); - | ------------- +401 | uint104 N = uint104(M); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1405,8 +1886,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -272 | uint96 i = uint96(base); - | ------------ +403 | uint96 P = uint96(O); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1418,8 +1899,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -273 | uint88 j = uint88(base); - | ------------ +405 | uint88 R = uint88(Q); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1431,8 +1912,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -280 | uint80 k = uint80(base); - | ------------ +407 | uint80 T = uint80(S); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1444,8 +1925,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -281 | uint72 l = uint72(base); - | ------------ +409 | uint72 V = uint72(U); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1457,8 +1938,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -282 | uint64 m = uint64(base); - | ------------ +411 | uint64 X = uint64(W); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1470,8 +1951,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -283 | uint56 n = uint56(base); - | ------------ +413 | uint56 Z = uint56(Y); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1483,8 +1964,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -284 | uint48 o = uint48(base); - | ------------ +415 | uint48 BB = uint48(AA); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1496,8 +1977,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -285 | uint40 p = uint40(base); - | ------------ +417 | uint40 DD = uint40(CC); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1509,8 +1990,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -286 | uint32 q = uint32(base); - | ------------ +419 | uint32 FF = uint32(EE); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1522,8 +2003,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -287 | uint24 r = uint24(base); - | ------------ +421 | uint24 HH = uint24(GG); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1535,8 +2016,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -288 | uint16 s = uint16(base); - | ------------ +423 | uint16 JJ = uint16(II); + | ---------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1548,8 +2029,8 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -289 | uint8 t = uint8(base); - | ----------- +425 | uint8 LL = uint8(KK); + | --------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -1561,12 +2042,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -299 | return uint64(uint128(int128(uint128(a)) + b)); - | --------------------------------------- +430 | bytes32 dataSlice = bytes32(data); + | ------------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint64' is safe because [explain why] + // casting to 'bytes32' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1574,12 +2055,12 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -299 | return uint64(uint128(int128(uint128(a)) + b)); - | ------------------------------- +432 | bytes32 strSlice = bytes32(bytes(str)); + | ------------------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'uint128' is safe because [explain why] + // casting to 'bytes32' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast @@ -1587,12 +2068,25 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -299 | return uint64(uint128(int128(uint128(a)) + b)); - | ------------------ +442 | return uint64(uint128(int128(uint128(a)) + b)); + | --------------------------------------- | = note: Consider disabling this lint if you're certain the cast is safe: - // casting to 'int128' is safe because [explain why] + // casting to 'uint64' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +442 | return uint64(uint128(int128(uint128(a)) + b)); + | ------------------------------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint128' is safe because [explain why] // forge-lint: disable-next-line(unsafe-typecast) = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast From 172310667da55c4c3cb09bc253f71f9691f7508b Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Tue, 12 Aug 2025 01:21:25 +0700 Subject: [PATCH 18/20] lint --- crates/lint/src/sol/med/unsafe_typecast.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs index a89cc131a6c18..31df1830b641e 100644 --- a/crates/lint/src/sol/med/unsafe_typecast.rs +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -54,7 +54,7 @@ fn is_unsafe_typecast_hir( if let ElementaryType::Int(tgt_size) = target_type { if let ExprKind::Call(call_expr, args, _) = &source_expr.kind { if let ExprKind::Type(hir::Type { - kind: TypeKind::Elementary(ElementaryType::UInt(src_bits)), + kind: TypeKind::Elementary(ElementaryType::UInt(_src_bits)), .. }) = &call_expr.kind { @@ -77,7 +77,7 @@ fn is_unsafe_typecast_hir( fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option { match &expr.kind { // A type cast call: Type(val) - ExprKind::Call(call_expr, args, _) => { + ExprKind::Call(call_expr, _args, _) => { if let ExprKind::Type(hir::Type { kind: TypeKind::Elementary(elem_type), .. }) = &call_expr.kind { From 3c31934f8e4015e076320de1cf7c7decd135b25c Mon Sep 17 00:00:00 2001 From: 0xrusowsky <0xrusowsky@proton.me> Date: Thu, 14 Aug 2025 13:04:31 +0200 Subject: [PATCH 19/20] fix: account for all types found rather than being limited to just one --- crates/lint/src/sol/med/unsafe_typecast.rs | 99 ++++++++++++---------- crates/lint/testdata/UnsafeTypecast.sol | 8 ++ crates/lint/testdata/UnsafeTypecast.stderr | 30 ++++++- 3 files changed, 91 insertions(+), 46 deletions(-) diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs index 31df1830b641e..d0142b2b72ee7 100644 --- a/crates/lint/src/sol/med/unsafe_typecast.rs +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -42,46 +42,60 @@ impl<'hir> LateLintPass<'hir> for UnsafeTypecast { } } +/// Determines if a typecast is potentially unsafe (could lose data or precision). fn is_unsafe_typecast_hir( hir: &hir::Hir<'_>, source_expr: &hir::Expr<'_>, target_type: &hir::ElementaryType, ) -> bool { - let Some(source_elem_type) = infer_source_type(hir, source_expr) else { + let mut source_types = Vec::::new(); + infer_source_types(Some(&mut source_types), hir, source_expr); + + if source_types.is_empty() { return false; }; - if let ElementaryType::Int(tgt_size) = target_type { - if let ExprKind::Call(call_expr, args, _) = &source_expr.kind { - if let ExprKind::Type(hir::Type { - kind: TypeKind::Elementary(ElementaryType::UInt(_src_bits)), - .. - }) = &call_expr.kind - { - if let Some(inner) = args.exprs().next() { - if let Some(ElementaryType::UInt(orig_bits)) = infer_source_type(hir, inner) { - if orig_bits.bits() < tgt_size.bits() { - return false; - } - } - } - } + for source_ty in source_types { + if is_unsafe_elementary_typecast(&source_ty, target_type) { + return true; } } - is_unsafe_elementary_typecast(&source_elem_type, target_type) + false } -/// Infers the elementary type of a source expression. -/// For cast chains, returns the ultimate source type, not intermediate cast results. -fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option { +/// Infers the elementary source type(s) of an expression. +/// +/// This function traverses an expression tree to find the original "source" types. +/// For cast chains, it returns the ultimate source type, not intermediate cast results. +/// For binary operations, it collects types from both sides into the `output` vector. +/// +/// # Returns +/// An `Option` containing the inferred type of the expression if it can be +/// resolved to a single source (like variables, literals, or unary expressions). +/// Returns `None` for expressions complex expressions (like binary operations). +fn infer_source_types( + mut output: Option<&mut Vec>, + hir: &hir::Hir<'_>, + expr: &hir::Expr<'_>, +) -> Option { + let mut track = |ty: ElementaryType| -> Option { + if let Some(output) = output.as_mut() { + output.push(ty); + } + Some(ty) + }; + match &expr.kind { - // A type cast call: Type(val) - ExprKind::Call(call_expr, _args, _) => { - if let ExprKind::Type(hir::Type { kind: TypeKind::Elementary(elem_type), .. }) = + // A type cast call: `Type(val)` + ExprKind::Call(call_expr, args, ..) => { + // Check if the called expression is a type, which indicates a cast. + if let ExprKind::Type(hir::Type { kind: TypeKind::Elementary(..), .. }) = &call_expr.kind + && let Some(inner) = args.exprs().next() { - return Some(*elem_type); + // Recurse to find the original (inner-most) source type. + return infer_source_types(output, hir, inner); } None } @@ -91,40 +105,37 @@ fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option match kind { - LitKind::Str(StrKind::Hex, ..) => Some(ElementaryType::Bytes), - LitKind::Str(..) => Some(ElementaryType::String), - LitKind::Address(_) => Some(ElementaryType::Address(false)), - LitKind::Bool(_) => Some(ElementaryType::Bool), - - // Unnecessary to check numbers as assigning literal values which cannot fit into a type + LitKind::Str(StrKind::Hex, ..) => track(ElementaryType::Bytes), + LitKind::Str(..) => track(ElementaryType::String), + LitKind::Address(_) => track(ElementaryType::Address(false)), + LitKind::Bool(_) => track(ElementaryType::Bool), + // Unnecessary to check numbers as assigning literal values that cannot fit into a type // throws a compiler error. Reference: _ => None, }, - // Unary operations - ExprKind::Unary(op, inner_expr) => match op.kind { - solar_ast::UnOpKind::Neg => match infer_source_type(hir, inner_expr) { - Some(ElementaryType::UInt(size)) => Some(ElementaryType::Int(size)), - Some(signed_type @ ElementaryType::Int(_)) => Some(signed_type), - _ => Some(ElementaryType::Int(solar_ast::TypeSize::ZERO)), - }, - _ => infer_source_type(hir, inner_expr), - }, + // Unary operations: Recurse to find the source type of the inner expression. + ExprKind::Unary(_, inner_expr) => infer_source_types(output, hir, inner_expr), + // Binary operations ExprKind::Binary(lhs, _, rhs) => { - if let Some(ty) = infer_source_type(hir, lhs) { - return Some(ty); + if let Some(mut output) = output { + // Recurse on both sides to find and collect all source types. + infer_source_types(Some(&mut output), hir, lhs); + infer_source_types(Some(&mut output), hir, rhs); } - infer_source_type(hir, rhs) + None } + + // Complex expressions are not evaluated _ => None, } } diff --git a/crates/lint/testdata/UnsafeTypecast.sol b/crates/lint/testdata/UnsafeTypecast.sol index 705a5d70d6060..52e90aed4b283 100644 --- a/crates/lint/testdata/UnsafeTypecast.sol +++ b/crates/lint/testdata/UnsafeTypecast.sol @@ -439,6 +439,14 @@ contract Repros { } function nestedCastsAreEvaluatedAtAllDepths(uint64 a, int128 b) internal pure returns (uint64) { + uint64 aAloneIsSafe = uint64(uint128(int128(uint128(a)))); + + uint128 aPlusB = uint128(int128(a) + b); + //~^WARN: typecasts that can truncate values should be checked + + uint64 unsafe = uint64(aPlusB); + //~^WARN: typecasts that can truncate values should be checked + return uint64(uint128(int128(uint128(a)) + b)); //~^WARN: typecasts that can truncate values should be checked //~^^WARN: typecasts that can truncate values should be checked diff --git a/crates/lint/testdata/UnsafeTypecast.stderr b/crates/lint/testdata/UnsafeTypecast.stderr index ba6af8ef807ba..1bf3b9c7bdcb6 100644 --- a/crates/lint/testdata/UnsafeTypecast.stderr +++ b/crates/lint/testdata/UnsafeTypecast.stderr @@ -2068,7 +2068,33 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -442 | return uint64(uint128(int128(uint128(a)) + b)); +444 | uint128 aPlusB = uint128(int128(a) + b); + | ---------------------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint128' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +447 | uint64 unsafe = uint64(aPlusB); + | -------------- + | + = note: Consider disabling this lint if you're certain the cast is safe: + + // casting to 'uint64' is safe because [explain why] + // forge-lint: disable-next-line(unsafe-typecast) + + = help: https://book.getfoundry.sh/reference/forge/forge-lint#unsafe-typecast + +warning[unsafe-typecast]: typecasts that can truncate values should be checked + --> ROOT/testdata/UnsafeTypecast.sol:LL:CC + | +450 | return uint64(uint128(int128(uint128(a)) + b)); | --------------------------------------- | = note: Consider disabling this lint if you're certain the cast is safe: @@ -2081,7 +2107,7 @@ warning[unsafe-typecast]: typecasts that can truncate values should be checked warning[unsafe-typecast]: typecasts that can truncate values should be checked --> ROOT/testdata/UnsafeTypecast.sol:LL:CC | -442 | return uint64(uint128(int128(uint128(a)) + b)); +450 | return uint64(uint128(int128(uint128(a)) + b)); | ------------------------------- | = note: Consider disabling this lint if you're certain the cast is safe: From 8769762546abc5b597ebcf10c9887895893e9ffb Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Fri, 15 Aug 2025 04:14:28 +0700 Subject: [PATCH 20/20] use iter --- crates/lint/src/sol/med/unsafe_typecast.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/crates/lint/src/sol/med/unsafe_typecast.rs b/crates/lint/src/sol/med/unsafe_typecast.rs index d0142b2b72ee7..6bced97d5c108 100644 --- a/crates/lint/src/sol/med/unsafe_typecast.rs +++ b/crates/lint/src/sol/med/unsafe_typecast.rs @@ -55,13 +55,7 @@ fn is_unsafe_typecast_hir( return false; }; - for source_ty in source_types { - if is_unsafe_elementary_typecast(&source_ty, target_type) { - return true; - } - } - - false + source_types.iter().any(|source_ty| is_unsafe_elementary_typecast(source_ty, target_type)) } /// Infers the elementary source type(s) of an expression.