I do understand how this pattern is evaluated:
template t{0|1}(): untyped = 3
But I can't figure out how this one is processed:
template t{x = (~x){y} and (~x){z}}(x, y, z: bool) =
x = y
if x: x = z
var
a = false
b = true
c = false
a = b and c
echo a
Mostly the heading of the template
(~x){y} seems to mean "capture y as long as it is not x". So
template foo{x = (~x){y}}(x, y: untyped) =
echo "got ", astToStr(x), " and ", astToStr(y)
var a = 1
var b = 2
a = b
a = a
b = a
b = b
outputs
got a and b
got b and a
Beyond this, it is just matching any expression x = y and z, where x, y and z are booleans.