-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"cannot coerce undefined to object" - Spread into array syntax issues #140
Comments
PS: I'll keep debugging and if I can't think of anything else create a runnable example to send you. EDIT: Blocked by #141 in this attempt. EDIT ²: Unblocked by manifest.json entry `"strip": "[]", but the minimal examples keep working.... :( |
An update: When I replace the |
Reproducible exampleThe error is connected to array spread syntax. Everything works if I replace it with I ran it on Linux, but I discovered the issue originally on ESP32. There are two different errors. To discover the first one just uncomment the code marked 'use strict';
function isString (thing) {
return typeof thing === 'string';
}
function ensureRecipeRule (thing) {
if (thing.referenceTo instanceof Set) {
[...thing.referenceTo].every(type => isString(type));
}
// ERROR #1
// THE EXACT SAME THING AS ABOVE REPEATED: "callback is no function"
// if (thing.referenceTo instanceof Set) {
// [...thing.referenceTo].every(type => isString(type));
// }
// ERROR #2
// "cannot coerce undefined to object"
if (thing.idReferenceTo instanceof Set) {
[...thing.idReferenceTo].every(type => isString(type));
}
}
trace('Start\n');
[
{
referenceTo: new Set(['Person']),
},
{
idReferenceTo: new Set(['Group'])
}
]
.map(rule => ensureRecipeRule(rule));
trace('End\n'); Result (Error 2): The "callback is no function" error can also be reproduced simply by function isString (s) {
return typeof s === 'string';
}
const s1 = new Set('s1');
[...s1].every(isString);
[...s1].every(isString); // the 2nd call fails |
Another possibly related example: Test performed on Linux. Codeconst a1 = [1,2,3];
const a2 = [];
const result = [...a1, ...a2]; Expected Result
Actual Result
|
This was fixed a while back. |
EDIT Very small reproducible example added in a comment below.
I have a weird problem that running in isolation works just fine.
Code
(Excerpt)
thing.referenceTo
is aSet
with a single string value"*"
inside as shown by thetrace
output below.Output
I wish I could copy & paste from the console in xsbug....
The same thing happens in another place (the
case
is resched becauseObject.prototype.toString.call
returned string "Set", which was extracted, soobj
is sure to be aSet
):Just for the record, all of that is well-tested, the exact same code, just a mini-example of our stuff, runs on node.js browser, react-native - and even low.js (on this board).
Works when run in isolation
I tried to run this as an isolated example:
but this worked fine.
The text was updated successfully, but these errors were encountered: