Repository navigation
fix(runtime): reduce test262 built-ins/Object failures (#5588) #5792
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -227,9 +227,20 @@ pub extern "C" fn js_object_set_prototype_of(obj_value: f64, proto: f64) -> f64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if tortoise == TAG_NULL_U64 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Advance tortoise one step, hare two steps. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Advance tortoise one step, hare two steps. Guard the second | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // advance: if the first step lands on null, calling advance(null) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // would invoke js_object_get_prototype_of(null) which throws | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // "Cannot convert undefined or null to object" (test262 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // setPrototypeOf/success.js — plain object proto chain ends at null). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tortoise = advance(tortoise); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hare = advance(advance(hare)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hare = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let h1 = advance(hare); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if h1 == TAG_NULL_U64 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TAG_NULL_U64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| advance(h1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+230
to
+243
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Re-check If Proposed fix tortoise = advance(tortoise);
hare = {
let h1 = advance(hare);
if h1 == TAG_NULL_U64 {
TAG_NULL_U64
} else {
advance(h1)
}
};
+ if tortoise == obj_bits {
+ throw_object_type_error(b"Cyclic __proto__ value");
+ }
// If they meet, the existing chain already has a cycle — the walk
// will never reach null, so we also can never form a new one by
// setting obj's proto. Just break; the set is safe.
if hare == tortoise {
break;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // If they meet, the existing chain already has a cycle — the walk | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // will never reach null, so we also can never form a new one by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // setting obj's proto. Just break; the set is safe. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Use an own-index check here, not
array_spec_has_index.array_spec_has_indexalso returnstruefor inherited numeric properties on a custom prototype,Array.prototype, orObject.prototype.Object.assignmust copy only own enumerable properties, so this will incorrectly copy prototype-filled holes from sparse arrays. Please switch this guard to an own-index predicate instead of the full array lookup helper.🤖 Prompt for AI Agents