This matches the behaviour of `toPropertyKey`, which is a soft spec
prerequisite (`SetFunctionName` takes a property key argument).
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
-import { ITERATOR } from "./value.js";
+import { ITERATOR, toPrimitive } from "./value.js";
});
},
toFunctionName: ($, prefix = undefined) => {
});
},
toFunctionName: ($, prefix = undefined) => {
+ const key = toPrimitive($, "string");
- if (typeof $ === "symbol") {
+ if (typeof key === "symbol") {
// The provided value is a symbol; format its description.
// The provided value is a symbol; format its description.
- const description = call(getSymbolDescription, $, []);
+ const description = call(getSymbolDescription, key, []);
return description === undefined ? "" : `[${description}]`;
} else {
// The provided value not a symbol; convert it to a string
// property key.
return description === undefined ? "" : `[${description}]`;
} else {
// The provided value not a symbol; convert it to a string
// property key.
}
})();
return prefix !== undefined ? `${prefix} ${name}` : name;
}
})();
return prefix !== undefined ? `${prefix} ${name}` : name;