Skip to content

Write back every element in Array.prototype.sort - #579

Closed
theaddonn wants to merge 2 commits into
bellard:masterfrom
theaddonn:fix-sort-write-back
Closed

theaddonn wants to merge 2 commits into
bellard:masterfrom
theaddonn:fix-sort-write-back

Conversation

@theaddonn

Copy link
Copy Markdown

sort skipped writing elements that were already in place, so Array.prototype.sort.call("aa") and Object.freeze([1, 2]).sort() didn't throw like the spec (and other engines) do.

Port of quickjs-ng/quickjs#1843

sort skipped the write for elements that were already in place. The
spec writes every sorted value back with Set(obj, j, v, true), so a
read-only receiver such as a String or a frozen array must throw.

Port of quickjs-ng/quickjs#1843
@bellard

bellard commented Oct 26, 2026

Copy link
Copy Markdown
Owner

applied

@bellard bellard closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants