Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

E004: Invalid Attribute Set Merge

Severity: Error

cannot merge `int` with `{ name: string }`: both sides must be attribute sets

The // (update) operator requires both operands to be attribute sets. This error appears when one or both sides have a non-attrset type.

Common causes

  • Using // on a value that isn’t an attribute set:
    42 // { x = 1; }   # int is not an attrset
    
  • A variable intended to hold an attrset actually holds a different type due to a logic error upstream.
  • Merging the return value of a function that doesn’t return an attrset.

How to fix

  • Verify that both sides of // are attribute sets.
  • If one side is conditional, make sure all branches return an attrset:
    (if cond then { a = 1; } else {}) // { b = 2; }
    
  • Check whether you meant + (concatenation/addition) instead of // (merge).