repl: do not insert duplicates into completions

Fix invalid `hasOwnProperty` function usage.

Fixes #6255.

cc @bnoordhuis @auds1n