-
Notifications
You must be signed in to change notification settings - Fork 247
Closed
Description
The template literal expression here throws; is that by design? I'm looking thru various specs and docs and stuff and I can't quite tell whether this OK. The diagnostic is misleading, since neither Object(undefined) nor String(undefined) throws.
export default function main() {
const undef = undefined;
const o = Object(undefined);
const s0 = String(undefined);
const s = `undef:${undef}`;
trace(s + '\n');
}If I try to make my own template tag, the 2nd arg seems to get undefined rather than an array of values. The exception comes on the parts.push line, presumably when evaluating args[i - 1]:
export default function main() {
const undef = undefined;
const o = Object(undefined);
const s0 = String(undefined);
const s = allstr`undef:${undef}`;
trace(s + '\n');
}
function allstr(quasis, args) {
const parts = [quasis[0]];
for (let i = 1; i < quasis.length; i += 1) {
parts.push(String(args[i - 1]), quasis[i]);
}
return parts.join('');
}Metadata
Metadata
Assignees
Labels
No labels