Closed Bug 604971 Opened 15 years ago Closed 15 years ago

array.sort compare-function gets incorrect this

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
blocking2.0 --- beta7+

People

(Reporter: evilpies, Assigned: evilpies)

References

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(2 files)

Since the es5 and strict mode, "null" and "undefined" this is observable. As defined by es5 compare function should get "null" as their |this| value; Test: [1, 2].sort(function () { "use strict"; if (this === undefined) throw; });
Did you mean that the compare function should be passed undefined as |this|? That's what I'm reading in 15.4.4.11: "Return the result of calling the [[Call]] internal method of comparefn passing undefined as the this value and with arguments x and y." Regardless, the bug summary is correct: we are currently passing null instead of undefined.
Right totally messed it up, but i originally meant the right thing. Currently the compare-function gets "null" but it should be "undefined".
Attached file tescase
Attached patch micro fixSplinter Review
Attachment #483856 - Flags: review?
Attachment #483856 - Flags: review? → review?(lw)
Comment on attachment 483856 [details] [diff] [review] micro fix Stealing, this micro-fix is easy enough. Looks like I forgot about this instance of this-passing when I wrote the strict-this patches... I'll push this into TM tomorrow morning. I can imagine we might want this for the beta release, on the principle of avoiding pointless dups for a very obvious mistake in new functionality for anyone looking, but I'm not going to push it.
Attachment #483856 - Attachment is patch: true
Attachment #483856 - Attachment mime type: application/octet-stream → text/plain
Attachment #483856 - Flags: review?(lw) → review+
Assignee: general → evilpies
Status: NEW → ASSIGNED
blocking2.0: --- → ?
OS: Windows XP → All
Hardware: x86 → All
Whiteboard: fixed-in-tracemonkey
(Thanks for the patch!)
blocking2.0: ? → beta8+
Blocks: strictThis
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: