This could be cleaned up by either using a `do...while` or initializing `primitive` to `undefined`.