-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
What version of Bun is running?
1.3.10
What platform is your computer?
Darwin 25.3.0 arm64 arm
What steps can reproduce the bug?
-
Open a terminal and start the Bun REPL:
bun repl
-
Enter an empty object literal and press Tab to trigger autocomplete:
{}.to[TAB]
-
Observe the completion suggestions that appear in the terminal.
What is the expected behavior?
When using tab completion in the REPL, each property name should appear only once in the completion list. For example, when completing {}.to, the suggestions should be:
toString
toLocaleString
Each unique property name should be displayed exactly once, regardless of how many times it appears in the prototype chain.
What do you see instead?
Instead of unique property names, the completion list shows duplicate entries:
toString
toLocaleString
toString
toLocaleString
Additional information
The same property names are repeated multiple times because they appear at multiple levels in the JavaScript prototype chain (e.g., toString exists in both Function.prototype and Object.prototype), and the current implementation doesn't filter out duplicates when collecting completion suggestions from the prototype chain.
This issue is particularly noticeable when working with:
- Empty objects
{} - Functions or class instances
- Objects with deep prototype chains
The duplicate entries clutter the completion list and make it harder to quickly identify and select the desired property name.