# Can I .search also a path that .search also another path?

(This is inspired by Problem between keys, paths with two macros and pgfkeys)

The following code

\documentclass[tikz]{standalone}
\begin{document}
\pgfkeys{
%/foo/.search also={/bar,/tikz},
%/foo/.search also={/bar},
/bar/.search also={/tikz}
}
\tikz\draw[/foo/.cd,fill=red]circle(1);
\end{document}


produces error

Package pgfkeys Error: I do not know the key '/foo/fill', to which you passed 'red', and I am going to ignore it. Perhaps you misspelled it.

This is not surprising, because there is nothing under /foo.

The following code

\documentclass[tikz]{standalone}
\begin{document}
\pgfkeys{
/foo/.search also={/bar,/tikz},
%/foo/.search also={/bar},
/bar/.search also={/tikz}
}
\tikz\draw[/foo/.cd,fill=red]circle(1);
\end{document}


produces a picture successfully

This is not surprising either, because /foo tries to search fill under /bar and /tikz, and finds that /tikz/fill is defined.

The following code

\documentclass[tikz]{standalone}
\begin{document}
\pgfkeys{
%/foo/.search also={/bar,/tikz},
/foo/.search also={/bar},
/bar/.search also={/tikz}
}
\tikz\draw[/foo/.cd,fill=red]circle(1);
\end{document}


surprisingly, produces no error but a naïve picture.

It seems like /foo asks /bar to find fill under /tikz, and they success (hence no error). But for some reason the style failed to apply.

Why is this happening? Can I somehow make one of these happen:

• raise an error; or
• apply the style successfully; or even better
• apply the style successfully and raise a warning?
• Did you try without the =red part? It should give an unknown handler something error. I remember working with this at some point but don't remember what the issue was. – percusse Apr 28 '17 at 14:27
• @percusse Yes, indeed. If I try without the fill= part, it raises the same error. (I do not know the key '/handlers/.unknown/.@cmd') I highly suspect that it has something to do with the default treatment of TikZ that test whether an unknown key is actually a color (mixed or pure). In this sense, it is clear that fill=red is not a color so TikZ did not bother to test it. (This is purely guess, otherwise things just got more complicated. – Symbol 1 Apr 28 '17 at 15:17