You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When the pre-processor is being used to switch between code that e.g. starts a block with different code, the braces are being counted in both branches, causing it to expect two closing braces.
To Reproduce
#if WINDOWS
intWinMain(HINSTANCE hinstance, HINSTANCE, LPSTR cmdline, int showCmd) {
#elsevoidmain(int argc, char** argv) {
#endif
// do something cool
}
gives
scratch.cpp2(8,0): error: end of file reached with 1 missing } to match earlier { on line 2
Additional context
Hit this porting some real code (that I didn't write), so this is a potential migration stumbling block.
I don't think it's plausible to catch everything a pre-processor can do, of course, but perhaps some form of pass-through for old syntax so long as the braces in both branches are equal would be fine.
The text was updated successfully, but these errors were encountered:
Thanks! That's good practical feedback and a pragmatic solution proposal. I do care about real-world code and want to reduce adoption friction, even if it can't be bulletproof without implementing the preprocessor and doing macro expansion (which I don't want to do that this point).
perhaps some form of pass-through for old syntax so long as the braces in both branches are equal
OK, that seems like a reasonable heuristic... done, see above commit. It should now handle a net-positive number of braces introduced in both branches. I didn't try to deal with branches that introduce the same net-negative number of braces; that would require a bit more work.
Describe the bug
When the pre-processor is being used to switch between code that e.g. starts a block with different code, the braces are being counted in both branches, causing it to expect two closing braces.
To Reproduce
gives
Additional context
Hit this porting some real code (that I didn't write), so this is a potential migration stumbling block.
I don't think it's plausible to catch everything a pre-processor can do, of course, but perhaps some form of pass-through for old syntax so long as the braces in both branches are equal would be fine.
The text was updated successfully, but these errors were encountered: