decode_varbind in 'w' mode opens a conversion around an assignment target -
"x = AsSmallInt(" - and its ')' mode closes it. The LET path does both; RUN ...
RETURNING only ever opened one, so the statement was written a bracket short:
L_stat = AsSmallInt(Fgl.ExecuteCmd(L_cmd);
That is a parse error, so it took the whole module's diagnostics with it and
showed up as a scatter of unrelated-looking syntax errors rather than as one
obvious fault.