https://github.com/morpho-org/forge-lint-bug-repro
https://github.com/morpho-org/forge-lint-bug-repro
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/morpho-org/forge-lint-bug-repro
- Owner: morpho-org
- Created: 2026-03-24T18:41:20.000Z (2 months ago)
- Default Branch: repro
- Last Pushed: 2026-03-25T07:20:41.000Z (2 months ago)
- Last Synced: 2026-03-26T11:50:08.933Z (2 months ago)
- Language: Solidity
- Size: 133 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# forge lint `unsafe-typecast` false negative
`forge lint` catches `uint128(x)` when `x` is a local variable, but silently
misses the exact same narrowing cast when the argument is a function return value.
**forge 1.5.1-stable** (b0a9dd9ced 2025-12-22)
## Reproduce
```
forge lint --only-lint unsafe-typecast
```
**Expected:** 2 warnings (lines 7 and 17).
**Actual:** 1 warning (line 7 only). The cast at line 17 is silently skipped.
## Root cause
`infer_source_types` in `crates/lint/src/sol/med/unsafe_typecast.rs` only
resolves types for `Ident`, `Lit`, cast-`Call`, `Unary`, and `Binary`
expressions. Any other `ExprKind` (including non-cast function calls, member
access, index, ternary, globals) falls through `_ => None`, making the
source-type vec empty and the cast appear safe.