Open overlookmotel opened 6 months ago
NB: The tokens array is lexically bound to the tagged template.
const tag = tokens => tokens;
const makeRunTag = () => () => tag`a${1}b${2}c`;
const tokens1 = makeRunTag()();
const tokens2 = makeRunTag()();
console.log(tokens1 === tokens2); // true
i.e. A single tagged template in source code corresponds to a single tokens array, regardless of how many function instances it's in.
From MDN:
Input:
In the source code,
compare()
returnstrue
. But in output it returnsfalse
because Livepack does not understand the link betweentokens
and the template literal inrunTag()
.Output:
This would be annoying to solve.
Instrumentation would need to replace the
tag
function with a wrapper which records:raw
property of the tokens arrayIf the tokens array/raw tokens array and the function are both included in output, it'd need to rewrite the
runTag
function as: