-
Notifications
You must be signed in to change notification settings - Fork 20
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
Hoisting breaks array initialization #56
Comments
Indeed, there should be an edge case in the hoist formatter for this or we could remove the hoist formatter completly and let the people do it themself |
Thank for your help ! 🥳 @cacharle Unfortunately, we have a new problem now: When we do this code: the formatter formats the code like that: But this version of formated code is not OK for Norminette. |
Could you try the version I just pushed on your local machine, to make sure the bug is fixed?
|
Unfortunately I have tested but I think is an issue with Norminette now |
Even if the norminette fails, do you have the behavior you desire when you try it out? |
Maybe we can implement a solution to be Norminette friendly: int main(int argc, char const *argv[])
{
int length;
int array[3] = {3, 5, 7};
length = sizeof(array) / sizeof(array[0]);
return (0);
} Formmating to: int main(int argc, char const *argv[])
{
int length;
int array[3];
array[0] = 3;
array[1] = 5;
array[2] = 7;
length = sizeof(array) / sizeof(array[0]);
return (0);
} Maybe this solution is a little bit hard to implement, but if you want, I can give some help to you if you explain how to do it. What do you think about this solution? |
I don't like that, it will fill all the lines with a bigger array. This edge case is too specific to have a complex logic to handle it I think that if the norminette doesn't allow array initialization, we shouldn't find a way to make it work, the user should be the one that doesn't use that feature. Leaving array assignment alone is ok imo |
Introduction
Currently, I'm trying to initialize an array that has a fixed length like that:
This code is ok for Norminette and is compilable:
![image](https://private-user-images.githubusercontent.com/43273304/259458745-b090fdb1-dec2-4cb9-a5d8-b2105d873ee6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyMzcxOTQsIm5iZiI6MTczOTIzNjg5NCwicGF0aCI6Ii80MzI3MzMwNC8yNTk0NTg3NDUtYjA5MGZkYjEtZGVjMi00Y2I5LWE1ZDgtYjIxMDVkODczZWU2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDAxMjEzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTlhYzI0NjdkNWFjYmRhOGY4OTQ4MDMzNzJjNDQ2NjY1Y2U1NzIzY2Y4YjA0MTI5YWQ4Njk2YTY2NzM2MzBlNDImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0._sth48C7F8SRG_5pJF4ubAM4JIyssld0S6PxyYDiMmQ)
Problem
The formatter, formats the code like that:
And this version of the code is not compilable:
![image](https://private-user-images.githubusercontent.com/43273304/259491615-c58fc8c5-0713-47ac-8b46-5c9e8877c3d6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyMzcxOTQsIm5iZiI6MTczOTIzNjg5NCwicGF0aCI6Ii80MzI3MzMwNC8yNTk0OTE2MTUtYzU4ZmM4YzUtMDcxMy00N2FjLThiNDYtNWM5ZTg4NzdjM2Q2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDAxMjEzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY2MjFiNGVmNzRlYmQwN2YzMTEwYmZmMzE0ZjFmOGZjNjI0NjdlOWMyMDNiNmQyMTk4NTkyZTk1YjU4OGVhMzAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.0yI4qo3sm722bSCba3iz_khY5mW7o17GFRsRDtwMioM)
The text was updated successfully, but these errors were encountered: