In a TikZ pic, the combination of -- cycle, \coordinates, and the name key (or using parenthesis) only works sometimes.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikzset{
mypic/.pic = {
\coordinate (a) at (0,0);
\coordinate (b) at (1,0);
\coordinate (c) at (1,1);
\coordinate (d) at (0,1);
\path[draw,fill=yellow] (a) -- (b) -- (c) -- (d) -- cycle;
},
}
try 1: \tikz \pic (k) {mypic};
try 2: \tikz \pic[name=l] {mypic};
without name: \tikz \pic {mypic};
try 3: \tikz \pic (m) {mypic};
\end{document}
Gives:
Dropping the coordinates and using \path[draw,fill=yellow] (0,0) -- (1,0) -- (1,1) -- (0,1) -- cycle; works as expected, all squares are closed and filled.

minimalclass, which is not intended for making minimal examples. – egreg Mar 15 '17 at 12:15cyclewith the first coord(a), at least you get all four sides drawn, but still without color. – Nicolás Ozimica Mar 15 '17 at 14:34