`^10.0.0-alpha.1` template literals output "regression"
The compiler started adding empty strings around values in template literals. Technically doesn't break anything, but adds a redundant operation.
Example:
Js.log(`${1->Js.Int.toString}${2->Js.Int.toString}`)
Output:
console.log("" + (1).toString() + "" + (2).toString() + "");
Before:
console.log((1).toString() + (2).toString());
Context: https://github.com/DZakh/rescript-struct/pull/1#discussion_r914182947, https://github.com/rescript-lang/rescript-compiler/issues/5514#issuecomment-1176231169
@DZakh see here: https://github.com/rescript-lang/syntax/pull/602
That attempt at the syntax level is no good. Some cleanup is needed first. Then it should be doable in the compiler back-end.
It's actually not clear how to do it in the compiler back-end without invasive changes.
The code generated for normal (default "js") and "j" interpolation is the same: appending strings together.
In the back-end, one cannot distinguish them.
And only for "js" it is safe to remove "" + .
So we won't try to do this optimisation for this version of the compiler.
What about the trailing empty string + ""?
Same
Putting this under milestone 10.1.
If anyone is interested in contributing a PR meanwhile, that's great.
That PR should be considered an optimisation, which should not fire for j`stuff` template expressions.