Typing issue with captures from Regex Builder

I am having a problem with named captures when build with a Regex Builder. The following code is a simplistic example of the problem that works using an "ordinary" Regex. but when the same regular regex is created with a Regex Builder, it works when using group numbers, but it raises the following typing problem when using capture names (last lines)

Cannot infer type of closure parameter 'm' without a type annotation

// named captures and use with a Regex string to twiggle every alternate chars
let pat = /(?P<a>.)(?P<b>.)/
"abcdef".replacing(pat,with:{m in "\(m.b)\(m.a)"})

// the same Regex but using a Regex Builder
let a = Reference(Substring.self)
let b = Reference(Substring.self)
let patRB = Regex {
    Capture(as: a) {.any}
    Capture(as: b) {.any}
}
// OK when using capture group numbers
"abcdef".replacing(patRB,with:{m in "\(m.2)\(m.1)"})
// compile error when using group names
"abcdef".replacing(patRB,with:{m in "\(m.b)\(m.a)"})

The following shows the output strings in a Playground

Any hints on what is wrong or on the correct way to add typing information to the closure.

Thanks

Could you provide complete example so we can reproduce ?

The original post does provide a complete example: both as a code snippet and an image showing the error message output in a Swift Playground

Typing issue with captures from Regex Builder
 
 
Q