You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Property access on a primitive number with .constructor returns undefined instead of the Number builtin. Found while filing the regression test for #2128 (number-receiver property-get safety guard) — fixing the segfault revealed this latent gap: the new guard correctly returns undefined for unknown keys, but .constructor (and other inherited Number.prototype methods like .toFixed, .toString) on a primitive should auto-box to Number.prototype and resolve.
Most code uses typeof x === "number" rather than x.constructor === Number, so this is low-impact, but date-fns / lodash-style runtime type discrimination via .constructor benefits from it.
A targeted fix would intercept b"constructor" (and well-known Number.prototype methods) for primitive-number receivers in js_object_get_field_by_name, returning the corresponding global or prototype-method value.
Summary
Property access on a primitive number with
.constructorreturnsundefinedinstead of theNumberbuiltin. Found while filing the regression test for #2128 (number-receiver property-get safety guard) — fixing the segfault revealed this latent gap: the new guard correctly returnsundefinedfor unknown keys, but.constructor(and other inheritedNumber.prototypemethods like.toFixed,.toString) on a primitive should auto-box toNumber.prototypeand resolve.Repro
Notes
undefined, which is strictly better but still doesn't match Node.typeof x === "number"rather thanx.constructor === Number, so this is low-impact, but date-fns / lodash-style runtime type discrimination via.constructorbenefits from it.b"constructor"(and well-knownNumber.prototypemethods) for primitive-number receivers injs_object_get_field_by_name, returning the corresponding global or prototype-method value.