Skip to content

Commit b080069

Browse files
proggeramlugRalph
andauthored
fix(runtime): narrow Function.prototype fallback digit-key guard to canonical array indices (#5842 follow-up) (#5881)
Address CodeRabbit minor finding on PR #5863: the guard excluding digit-shaped keys from the Function.prototype descriptor fallback used prop.as_bytes().first().is_ascii_digit(), which also excludes non-index names like "1x" or "2things" — a user-defined Function.prototype property with such a key would never be found through a closure receiver. Use the canonical array-index helper so only true index keys ("0", "1", "42", ...) are excluded. Pre-existing behavior (this exact check predates this PR; only relocated during the earlier dedup refactor), fixed here since it's directly adjacent to code this PR already touches. Verified: cargo test -p perry-runtime (1108 passed, 0 failed). Co-authored-by: Ralph <ralph@skelpo.com>
1 parent 94e9bc7 commit b080069

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

crates/perry-runtime/src/closure/dynamic_props.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ pub(crate) fn function_prototype_fallback_target(ptr: usize, prop: &str) -> Opti
543543
// S15.2.4.7_A8 regressions caught after the initial fix).
544544
| "toString" | "valueOf" | "hasOwnProperty" | "isPrototypeOf"
545545
| "propertyIsEnumerable" | "toLocaleString"
546-
) || prop.as_bytes().first().is_some_and(|b| b.is_ascii_digit())
546+
) || crate::object::canonical_array_index(prop).is_some()
547547
|| crate::object::reified_function_method_name(prop).is_some()
548548
{
549549
return None;

0 commit comments

Comments
 (0)