Having a semicolon after do seems to have the same effect as commenting out the entire statement containing the do.
It doesn't comment out the entire statement. The problem is that without the statement being in a "begin"/"end" pair then the "do" executes an empty statement (which is what the ";" indicates -> an empty statement.)
I’d like to suggest that putting a semicolon after do should generate a compile error or at least a warning about the fact that the code is useless and will never have any affect on the statement that follows it.
It would be incorrect for the compiler to generate an error because the construction "while <someboolean> do ;" is perfectly valid and sometimes _useful_. The case in which it may be useful is when the "while" expression may be changed by code that executes independently of the "while", for instance code in another thread that may be part of the program or the O/S. In that case the <expression> acts as a barrier to the execution of the code that follows it.
Considering that it is a somewhat uncommon construction, it might be reasonable for the compiler to emit a hint in that case but, it's not a really easy thing for the compiler to do because the hint would be valid only when the expression is entirely made of local variables (since those cannot be changed by external code, therefore the "while <expression> do ;" may effectively be an infinite loop (if <expression> happens to be true.)
IMO, while it would be nice to get a hint from the compiler, I would be inclined to leave the responsibility entirely on the programmer's shoulders (unless it happens to be easy for the compiler to correctly detect the case and emit the hint only when it is appropriate.)
I think @Martin_fr's suggestion to have the IDE highlight the construction is an excellent substitute for the hint you are requesting.
It would also be nice if the semicolon was not automatically placed after the do in the auto completion of Lazarus ide.
If you have the IDE do auto completion for you, you have to accept that there will be times when the IDE will "complete" something in a way that is not quite the way you want. It's a downside that comes with the territory.
HTH.