cs50 / style50

https://cs50.readthedocs.io/style50/
GNU General Public License v3.0
61 stars 29 forks source link

[style] [C] top-level && followed by an expression is styled incorrectly #108

Open Starwort opened 2 years ago

Starwort commented 2 years ago

Simplified, minimal code example:

int do_work()
{
    int rv;
    should_do_work() && (rv = some_parenthetical_work_doer() + 1);
    return rv;
}

Style50 wants it reformatted to:

int do_work()
{
    int rv;
    should_do_work() &&(rv = some_parenthetical_work_doer() + 1);
    //               ^^^ space removed here
    return rv;
}

This is clearly an incorrect suggestion.

EDIT: Occurs also without the brackets, as in should_do_thing() && thing_doer();

BenTaylor25 commented 2 years ago

diff: && ( -> &&(

Starwort commented 2 years ago

My guess as to why this happens is that it believes the && operator to be acting as a reference here, despite that not making much sense