-
-
Notifications
You must be signed in to change notification settings - Fork 431
Auto Format makes functional changes to sketch code #1674
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
Comments
Thanks for your report @Pexje.
Although I am able to reproduce the formatting change you describe: before #define DEBUG_SERIAL if (DEBUG) Serial after #define DEBUG_SERIAL \
if (DEBUG) Serial I am not able to reproduce the compilation error you claim. I will need you to provide enough information for me to reproduce it:
InvestigationI looked for a setting in the ClangFormat options (ClangFormat is the tool used by the Arduino IDE "Auto Format" feature) that would cause it to not add this line break. I did not find any. It is not clear whether the addition of this break is intentional behavior of the formatter or a bug. I found this similar bug report: llvm/llvm-project#53180. I also found this related bug report llvm/llvm-project#49164, which has been fixed, but that fix did not fix the problem you report here. A more minimal demonstration code: #define FOO if(true) {}
#define BAR while(true) {}
#define BAZ for(;;) {} Formats to: #define FOO \
if (true) {}
#define BAR \
while (true) {}
#define BAZ \
for (;;) {} WorkaroundYou can selectively disable formatting by adding special comments to your sketch code: So if you don't like the line break, you can do this: // clang-format off
#define DEBUG_SERIAL if (DEBUG) Serial
// clang-format on |
Hi @Pexje. We are still waiting for you to provide the information requested in the previous reply so that we can proceed with the investigation or evaluation of this. |
Since the requested code demonstrating a functional change to the code was never provided, and since the formatting style is not objectively bad from an aesthetic standpoint, I will close this as declined/invalid. If someone can provide a sketch that demonstrates the changed formatting causing a functional change to the code then we will investigate further. |
Describe the problem
When using Auto Format in Arduino IDE 2.0.1 some code in beginning of sketch goes wrong:
This gives Compilation error.
To reproduce
Please fix this bug.
Expected behavior
This is good working code before using Auto Format:
Arduino IDE version
2.0.1
Operating system
Windows
Operating system version
11
Additional context
No response
Issue checklist
The text was updated successfully, but these errors were encountered: