DiagnosticsError codes
M0007 mismatched types
Both operands of a binary operator must have identical types (untyped constants convert implicitly).
example $ marmot build . error[M0007]: invalid operation: n + f (mismatched types int and float64) --> ./main.go:6:8 | 4 | var n int | - `n` is `int` from here 5 | var f float64 | - `f` is `float64` from here 6 | _ = n + f | - ^ - `float64` | | | `int` | = help: convert one operand, for example `float64(n) + f` error: build failed with 1 error for more about an error, run `marmot explain M0007`
The program that produced it
package main
func main() {
var n int
var f float64
_ = n + f
}
The mistake and the fix
var n int
var f float64
_ = n + f_ = float64(n) + f The fix
Convert one operand to the type of the other.
See also all error codes and marmot explain.