I don't get it. This question was tagged as unclear, but it is perfectly clear to me. OP says here is code that gives me an error: ... but this code does not give me an error: ... why? OP even properly tagged and formatted his code.
To be perfectly upfront, when he first wrote the question, the "why" was at the very start of his post, and his post was just one very long sentence, broken only by his properly formatted code samples. In other languages, long sentences like this are preferred (my own native language included), so ESL speakers are quite comfortable with such sentences. But I went ahead and edited to make it a little more clear. My only edit was to move the "why" to the end and make it a separate sentence.
The question was so clear to me that I even did a fiddle to illustrate the problem, and the fiddle contains only the information provided by OP.
I even asked for moderator attention after it had been closed as unclear, to no avail. What am I missing here?