E003: Invalid Binary Operator
Severity: Error
cannot apply `+` to `string` and `int`
A binary operator was applied to operands whose types don’t support that operation. Nix’s + is overloaded (works on ints, floats, strings, and paths), but the two operands must be compatible.
Common causes
- Mixing strings and numbers with
+without converting:"count: " + 42 # string + int is not allowed - Using arithmetic operators (
-,*,/) on non-numeric types. - Using
//(attribute set merge) where+(addition or concatenation) was intended, or vice versa.
How to fix
- For string concatenation with non-strings, use string interpolation:
"count: ${toString 42}" - Make sure both operands of arithmetic operators are numeric (
intorfloat). - Use
++for list concatenation,//for attribute set merging.