This behavior currently happens by default for Record wrappers because they have a null prototype.
#{} == Object(#{}) // throws
It seems more future-proof to allow Record wrappers to safely pass ToPrimitive by unwrapping to their record primitive content. ToString and ToNumber can still throw.
We could add support for this either by adding a direct case for handing records to ToPrimitive, or always add a non-enumerable Symbol.toPrimitive to Record wrappers - though this would add a new hidden intrinsic.
ToPrimitive of an object relies on looking up methods on the value, there is no default behavior:
This behavior currently happens by default for Record wrappers because they have a null prototype.
It seems more future-proof to allow Record wrappers to safely pass
ToPrimitive
by unwrapping to their record primitive content.ToString
andToNumber
can still throw.We could add support for this either by adding a direct case for handing records to
ToPrimitive
, or always add a non-enumerableSymbol.toPrimitive
to Record wrappers - though this would add a new hidden intrinsic.