Closed jbt closed 7 years ago
Thanks. It was operating under the incorrect assumption that if the first statement of the body was an EmptyStatement, the body itself was empty. It should really remove empty statements altogether — will get to that soon — but #59 generates correct if suboptimal code
e.g.
while (a) { ; b(); }
->while(a);;
(link)I tried making some test-cases + fixing up the check for empty nodes by checking over every descendent node rather than just the first, but my do-while case is failing completely for magic-string reasons I don't fully understand.
Additionally, all cases where a curly-braced loop could be reduced to a single-statement body aren't working because I can't figure out how to trim leading/trailing
EmptyStatement
s.Incidentally it looks like there's a few more cases where leading empty statements in a block change the output (e.g.
if (a) { b(); }
vsif (a) { ; b(); }
) but the loops are the only case where it's doing something it definitely shouldn't.