Keep tagged template calls whose result is unused
Why
Js_analyzer.no_side_effect_expression treated a tagged template as pure when its tag and interpolated values were pure, so a tagged template whose result is unused (let _ =, ->ignore, an unused binding, a discarded array) was removed and the tag function never ran. A tagged template is a call of its tag, so it is now treated like a call.
Js_dump printed the tag at the level of the surrounding expression. A tag that inlining replaced with a function, a conditional or an await had no parentheses: the template bound to the last branch of the conditional and to the awaited promise, and a function was a syntax error. The tag is now printed as a callee is. The interpolated values, which ${} encloses, are printed without parentheses.
modifiedJS unused tagged templates
let tag: taggedTemplate<int, int> = Obj.magic(() => 1) let unusedResult = () => { let _ = tag`a ${1}`}
js
modifiedJS tags of tagged templates
let use = (tag: taggedTemplate<int, int>) => tag`x${1}`let useFunction = () => use(Obj.magic((_s, _v) => 1))let useConditional = (c, a, b) => use(c ? a : b)let useAwaited = async p => use(await p)
js
modifiedJS interpolated values of tagged templates
let f = (tag: taggedTemplate<int, int>, c) => tag`x${c ? 1 : 2}` + 1js
Review
- Are tagged templates whose result is used affected? Only in how their tag and interpolated values are parenthesised.
- Which checked-in outputs change? Only the new test's snapshot.