I enabled the compiler to throw errors on shadow variable errors:
<?xml version="1.0" encoding="utf-8" ?>
<Configuration xmlns="https://www.unrealengine.com/BuildConfiguration">
<BuildConfiguration>
<ProcessorCountMultiplier>1</ProcessorCountMultiplier>
<bShadowVariableErrors>true</bShadowVariableErrors>
</BuildConfiguration>
</Configuration>
After making this change and hitting F5 there are no compilation errors. Then I added a new UPROPERTY and initialized it in the cpp file and then suddenly that file and another file (which remained completely unchanged by me) threw shadow variable compiler errors. The code that that the shadow-errors applied to was not changed between the working compile and the one that threw errors.
So why did the compiler not throw me this error when I pressed F5 the first time? Well… I assume that this is related to this: Object finder: cannot convert 'UStaticMesh ' to 'UObject ' - Programming & Scripting - Epic Developer Community Forums
And why does it also not compile anymore when I hit ctrl+z until it reverts back to the original state? It still does not compile even though the code is now EXACTLY THE SAME as when it used to compile. BUT when I use SourceControl to revert the exact same change, then it compiles.
and How can a forward declaration cause "undefined" - C++ - Epic Developer Community Forums and some other posts that I forgot.
I believe that the compiler/UHT don’t check files that were already compiled successfully previously and stores/caches those in some way. Files are probably grouped together for compilation and if even one of those files is changed (even if it’s a useless comment that was added), the whole group get’s recompiled or at least re-checked. That would explain why ctrl+z spamming the code back to the original state were it used to compile doesn’t compile.
This mechanic may be good for saving on compilation time for big projects but it also causes the compiler to not throw errors when it should. And sometimes I even see old files that should no longer compile (but they do as long as I never touch them nor the ‘group’ they belong to anymore) due to missing includes or more graves mistakes from me. But in the past I got them to compile and then they are never checked anymore by the compiler/UHT?
I’m posting this in the bug reports section. My apologies if this is intended behavior but then please let me know why. So far nobody could answer it. I have heard various wild theories but nobody could tell me what exactly is happening.