Build environment: macOS 26.5.2
Moddable SDK version:
- Installed via jsvu, so there is no SDK source tree /
git describe.
- Engine reports:
XS 17.9.3, slot 32 bytes, ID 4 bytes
Target device: desktop (host xs)
Description
The first step of Symbol.for is ToString(key). With no argument, key is undefined and ToString yields "undefined", so the registry is consulted for that key and a Symbol with description "undefined" is returned. XS rejects the call instead.
Steps to Reproduce
$ xst -e 'print(String(Symbol.for()));'
SyntaxError: no key (in Symbol.for)
Expected behavior
Symbol(undefined)
For comparison, V8 (15.6.20):
$ v8 -e 'print(String(Symbol.for()));'
Symbol(undefined)
Other information
Symbol.for has no step that distinguishes a missing argument from an explicit undefined, and nothing before ToString can raise a SyntaxError. JavaScriptCore, SpiderMonkey, GraalJS and QuickJS-ng all return Symbol(undefined), and all of them register it under the key "undefined", so Symbol.keyFor(Symbol.for()) is "undefined" and Symbol.for() === Symbol.for("undefined").
Build environment: macOS 26.5.2
Moddable SDK version:
git describe.XS 17.9.3, slot 32 bytes, ID 4 bytesTarget device: desktop (host
xs)Description
The first step of
Symbol.forisToString(key). With no argument,keyisundefinedandToStringyields"undefined", so the registry is consulted for that key and a Symbol with description"undefined"is returned. XS rejects the call instead.Steps to Reproduce
$ xst -e 'print(String(Symbol.for()));' SyntaxError: no key (in Symbol.for)Expected behavior
Symbol(undefined)For comparison, V8 (15.6.20):
$ v8 -e 'print(String(Symbol.for()));' Symbol(undefined)Other information
Symbol.forhas no step that distinguishes a missing argument from an explicitundefined, and nothing beforeToStringcan raise a SyntaxError. JavaScriptCore, SpiderMonkey, GraalJS and QuickJS-ng all returnSymbol(undefined), and all of them register it under the key"undefined", soSymbol.keyFor(Symbol.for())is"undefined"andSymbol.for() === Symbol.for("undefined").