repl: do not insert duplicates into completions

Fix invalid `hasOwnProperty` function usage.

Fixes #6255.