Semantic Diff

#9420 Keep tagged template calls whose result is unused

1 commit

45dba2c9137d6be765c1d8d45f287d739e028498..pr-9420

da4bea816 · illusionalsagacity · Nov 23, 2026, 20:40 UTC

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
Before
After
function unusedResult() {function unusedResult() { tag`a ${1}`;}}

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
Before
After
function useFunction() {function useFunction() { return (_s, _v) => 1`x${1}`; return ((_s, _v) => 1)`x${1}`;}} function useConditional(c, a, b) {function useConditional(c, a, b) { return c ? a : b`x${1}`; return ( c ? a : b )`x${1}`;}} async function useAwaited(p) {async function useAwaited(p) { return await p`x${1}`; return (await p)`x${1}`;}}

modifiedJS interpolated values of tagged templates

let f = (tag: taggedTemplate<int, int>, c) => tag`x${c ? 1 : 2}` + 1
js
Before
After
function f(tag, c) {function f(tag, c) { return tag`x${( c ? 1 : 2 )}` + 1 | 0; return tag`x${c ? 1 : 2}` + 1 | 0; }}

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.