From the YANG spec, i.e. RFC 6020, 9.9.2. The path Statement:
The syntax for a path argument is a subset of the XPath abbreviated
syntax. Predicates are used only for constraining the values for the
key nodes for list entries. Each predicate consists of exactly one
equality test per key, and multiple adjacent predicates MAY be
present if a list has multiple keys. The syntax is formally defined
by the rule "path-arg" in Section 12.
And through that rule, you find:
path-predicate = "[" *WSP path-equality-expr *WSP "]"
path-equality-expr = node-identifier *WSP "=" *WSP path-key-expr
path-key-expr = current-function-invocation *WSP "/" *WSP
rel-path-keyexpr
current-function-invocation = current-keyword *WSP "(" *WSP ")"
rel-path-keyexpr = 1*(".." *WSP "/" *WSP)
*(node-identifier *WSP "/" *WSP)
node-identifier
I.e. the key predicates are restricted to [<key-name> = current()/…/<path-without-predicates>], which your path argument doesn’t adhere to. I’m not sure I understand exactly what you are trying to achieve, but I think it should be possible by using a simpler leafref path combined with a ‘must’ expression.