# E4161

Compiler diagnostic name: `mismatch_with_declare`.

Declaration does not match its implementation.

This error happens when a `declare` item and the item that implements it describe
different APIs. MoonBit checks declarations against implementations so that a
forward declaration, abstract type declaration, or declared implementation
relation cannot silently drift from the actual definition.

For functions and methods, the implementation must match the declared name,
visibility, type parameters, parameter types, return type, constraints, and
effects. For declared types, the implementation must match the declared
visibility and type parameter list. For declared implementation relations, the
implemented trait, target type, visibility, and type parameters must match.

## Erroneous example

```{literalinclude} /sources/error_codes/4161_error/top.mbt
:language: moonbit
```

The declaration says `declared_increment` returns `Int`, but the implementation
returns `Double`.

## Suggestion

Change either the declaration or the implementation so that the public contract
is written only one way.

```{literalinclude} /sources/error_codes/4161_fixed/top.mbt
:language: moonbit
```
