Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment missing in while loop #252

Closed
aboyton opened this issue Mar 25, 2018 · 3 comments
Closed

Comment missing in while loop #252

aboyton opened this issue Mar 25, 2018 · 3 comments
Assignees

Comments

@aboyton
Copy link

aboyton commented Mar 25, 2018

I think I'm on the tip of master (speaking of which, is there any playground for testing)?

When I try to run prettier on the follow code

<?php

for ($i  = 0; $i < 10; $i++) {
    while ($row = $result->nextRow()) {
        // A comment
    }
}

I get the error Error: Comment "// A comment" was not printed. Please report this error!.

This was a minimal(ish) reproduction of the problem.

@aboyton aboyton mentioned this issue Mar 25, 2018
@aboyton
Copy link
Author

aboyton commented Mar 28, 2018

This has now been "fixed" in terms of that I no longer get the error, it instead is moved to the wrong place. This was even more confusing when I first saw it as there was a lot more code between my for loop and my while statement than there is in this example.

Input:

<?php

for ($i = 0; $i < 10; $i++) {
    $a = 1;
    $b = 2;

    while (true) {
        // Some comment
    }
}

Output:

<?php
for ($i = 0; $i < 10; $i++) {
    // Some comment
    $a = 1;
    $b = 2;

    while (true) {
    }
}

@mgrip
Copy link
Contributor

mgrip commented Mar 28, 2018

Thanks @aboyton thats helpful. Think this should be an easy fix

@mgrip
Copy link
Contributor

mgrip commented Mar 29, 2018

Fixed with #261

@mgrip mgrip closed this as completed Mar 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants