Optional argument not getting set to \makebox through expl3 key assignment

I would streamline the business. ;-)

\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn

\tl_new:N  \l_aefl_position_tl
\tl_set:Nn \l_aefl_position_tl { \makebox[0pt][l] }

\keys_define:nn { aefl }
 {
  pos .choice:,
  pos / left   .code:n = \tl_set:Nn \l_aefl_position_tl { \makebox[0pt][l] },
  pos / right  .code:n = \tl_set:Nn \l_aefl_position_tl { \makebox[0pt][r] },
  pos / center .code:n = \tl_set:Nn \l_aefl_position_tl { \makebox[0pt]    },
 }

\NewDocumentCommand{\aecurrfile}{ O{} }
 {
  \group_begin:
  \keys_set:nn { aefl } { #1 }
  \tl_use:N \l_aefl_position_tl { contents ~ of ~ my ~ box }
  \group_end:
 }

\ExplSyntaxOff
\pagestyle{empty}
\begin{document}
\begin{center}
\parbox{10cm}{
Default:\\
\aecurrfile

Left:\\
\aecurrfile[pos=left]

Center:\\
\aecurrfile[pos=center]

Right:\\
\aecurrfile[pos=right]

}
\end{center}
\end{document}

enter image description here


Your problem is that when LaTeX looks for an optional argument, it needs to find a literal [ and not one stored inside anything. So you need to expand \l_aefl_position_tl before \makebox looks for it. I'd probably go for something like

\use:x { \exp_not:N \makebox [0pt] \l_aefl_position_tl }

as you know that the content of \l_aefl_position_tl is 'safe'.