Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(assert): make prototype of Object.prototype not equal undefined prototype #6484

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

WWRS
Copy link
Contributor

@WWRS WWRS commented Mar 17, 2025

Fixes #6334

These were previously hardcoded to be equal, and I'm not completely sure why. I hope I'm not missing something.

It's not mentioned in the PR when it was added (#6153). I suspect it was a port of the old system, where constructors were checked rather than prototypes: Undefined constructor could equal Object constructor. But undefined prototype should not equal Object prototype.

@WWRS WWRS requested a review from kt3k as a code owner March 17, 2025 15:32
@CLAassistant
Copy link

CLAassistant commented Mar 17, 2025

CLA assistant check
All committers have signed the CLA.

@@ -383,6 +383,18 @@ Deno.test("equal() with constructor and prototype", async (t) => {
});
});

Deno.test("equal() considers object with prototype Object.prototype not equal to object with no prototype", () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this too long a name? Suggestions on making it shorter?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks just fine to me

@WWRS WWRS marked this pull request as draft March 17, 2025 15:39
@WWRS
Copy link
Contributor Author

WWRS commented Mar 17, 2025

Changed to draft because I realized this makes behavior different when objects have properties: #6334 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@std/assert/equals considers Object.create(null) and {} to be equal
3 participants