Skip to content
Latchkey

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.

solc
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

  1. Read the expected versus actual type in the error.
  2. Change the value to the expected type, or convert explicitly where it is safe.
  3. Re-run the compile to confirm the type checks.
contracts/Vault.sol
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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →