-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1281 from cxielarko/bigint-bool-eq
ToPrimitive called without hint for boolean equality
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-abstract-equality-comparison | ||
description: Object operands coerced without ToPrimitive hint | ||
info: > | ||
7.2.14 Abstract Equality Comparison | ||
... | ||
6. If Type(x) is Boolean, return the result of the comparison ! | ||
ToNumber(x) == y. | ||
7. If Type(y) is Boolean, return the result of the comparison x == ! | ||
ToNumber(y). | ||
8. If Type(x) is either String, Number, or Symbol and Type(y) is | ||
Object, return the result of the comparison x == ToPrimitive(y). | ||
9. If Type(x) is Object and Type(y) is either String, Number, or | ||
Symbol, return the result of the comparison ToPrimitive(x) == y. | ||
... | ||
features: [Symbol.toPrimitive] | ||
---*/ | ||
|
||
let count = 0; | ||
let obj = { | ||
[Symbol.toPrimitive](hint) { | ||
count += 1; | ||
assert.sameValue(hint, "default"); | ||
return 1; | ||
} | ||
}; | ||
|
||
assert.sameValue(true == obj, true); | ||
assert.sameValue(count, 1); | ||
assert.sameValue(obj == true, true); | ||
assert.sameValue(count, 2); |
772fb79
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍