You're right. I pasted your comment to aider and it fixed it on the spot :).
EDIT: see https://git.sr.ht/~temporal/aider-2048/commit/9e24c20fc7145c....
A bit lazy approach, but also quite obvious. Pretty much what you'd get from a junior dev.
(Also if you're wondering about "// end of function ..." comments, I asked the AI to add those at some point, to serve as anchors, as the diffs generated by GPT-4o started becoming ambiguous and would add code in wrong places.)
(This kind of feedback driven generation is one of the things I do find very impressive about LLMs. But it's currently more or less the only thing.)