solc "TypeError: not implicitly convertible" in CI
solc type-checked an expression and found a value whose type cannot be implicitly converted to the expected type. Solidity does not perform many implicit conversions, so a mismatch like uint256 to address is an error.
What this error means
Compilation fails with "TypeError: Type X is not implicitly convertible to expected type Y" pointing at an assignment, argument, or return.
TypeError: Type uint256 is not implicitly convertible to expected type address.
--> contracts/Vault.sol:14:9:
|
14 | owner = ownerId;
| ^^^^^^^^^^^^^^^Common causes
Incompatible types in an assignment or call
A value of one type is assigned, passed, or returned where a different, non-convertible type is expected.
A literal or width mismatch
An integer literal too large for the target width, or a signed/unsigned mismatch, cannot be implicitly converted.
How to fix it
Use the correct type or an explicit conversion
- Read the expected versus actual type in the error.
- Change the value to the expected type, or convert explicitly where it is safe.
- Re-run the compile to confirm the type checks.
owner = address(uint160(ownerId));Correct the declared type instead
If the variable type is wrong, change the declaration to match the value rather than forcing a conversion.
How to prevent it
- Keep variable and parameter types consistent with their values.
- Convert between numeric and address types explicitly and deliberately.
- Compile locally to catch type errors before CI.