Closed andersk closed 4 weeks ago
This relates to #12
Oh I see the polyfill checks typeof result === "object"
before recursing. That’s not clear from the description but this hasn’t reached the stage where specification wordsmithing is helpful, so closing for now.
The meanings of
Symbol.result
inobj[Symbol.result]
andfunc[Symbol.result]
are very different.obj[Symbol.result]()
is a result corresponding toobj
itself, whilefunc[Symbol.result]()
is a result corresponding to the return value offunc
.Using the same symbol for both of these meanings, along with recursive unwrapping (#6), completely breaks functions that return other functions.
This evaluates as
outer[Symbol.result]()
→inner[Symbol.result]()
→[null, console.log("inner called")]
.Even if you think recursive unwrapping is a good idea, it should only recurse through
obj[Symbol.result]
, notfunc[Symbol.result]
. So we need to use two different symbols for these different meanings.