42School / norminette

Official 42 norminette
MIT License
956 stars 140 forks source link

bug on structure control by norminette #436

Closed CruorDei closed 1 year ago

CruorDei commented 1 year ago

Describe the bug A clear and concise description of what the bug is. When using a while with a single instruction and without brackets, if this instruction is an "if" with its brackets, the norminette returns an error on the opening line of the condition instructions in column 1 ( or there are only tabs).

Error returned Error: MULT_IN_SINGLE_INSTR (line: XX, col: 1): Multiple instructions in single line control structure

Example code triggering the error

while (++j < size)
            if (tab[i] > tab[j])
            {
                tmp = tab[i];
                tab[i] = tab[j];
                tab[j] = tmp;
            }

the error appears on line 3 of this example

Screenshot from 2023-09-21 16-49-00

matthieu42Network commented 1 year ago

Hello, I don't think there is a bug here. When using a single-line control block, all of your following control blocks must be single lines. Maybe the error is not clear enough.

What you need to do is:

while (++j < size)
{
    if (tab[i] > tab[j])
    {
        tmp = tab[i];
        tab[i] = tab[j];
        tab[j] = tmp;
    }
}