Isn’t it quite subjective? Like you could be missing the end to that if statement you just wrote, or you could be missing the end to the first function, with the second function assumed to be nested inside.
Without strictly enforcing indentation it’s kind of impossible to know which block you intended to close but didn’t.
There’s 4 possible blocks that could be considered the unclosed block in this example.
Personally, I think asking engineers to do “black magic” instead of just sticking to a indentation style is a bit unnecessary. That missing end would be blatantly obvious if you indented it the same as you did for every other if statement you wrote. Inconsistent styling is bad practice on your end, no offense.
It would be nice to have better error detection, sure, but it’s not as vital as you seem to be making of it.
I don’t think Visual Studio really detects cases like this for C++ or C#. C# has a stricter syntactic structure than Lua which means that in some cases the errors can be caught early, e.g. just because it’s invalid to say private void foo() inside another method’s body. (that’s not a universally accepted or favorable syntactic property btw, JS for example doesn’t have that, and the errors there due to missing } are obtuse, typically inferior to what we have)
But of course this doesn’t stop us from trying to make this even better.