Thanks to Orc/Arc cursors and COW string literals in this example you can
likely use the following:
import sugar
import strutils
template test2(src:string, lab: string = "Inner tmpl") =
let s {.cursor.} = src
# This works for let values but fails for expressions
let pi1 = cast[int](addr(s))
let pa1 = pi1.toHex
debugEcho lab, ": ", src, " <= ", $pa1
var s1 = "Test string"
# The following works because it is a let variable
test2 s1, "Original s1"
prepareMutation(s1) # This rewrites the literal so we can see cursors in
action.
let s2 = s1
# The following also works because it is also a let variable
test2 s2, "Copy s1"
# The following works because it is trapped by the when branch as a literal
test2 "Literal abc", "Literal template"
test2 "--- $1" % s1, "Expression"
Run